Skip to content

Instantly share code, notes, and snippets.

@willies952002
Last active April 2, 2017 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willies952002/999d1c8ee2c98b32c41999aa4091dfbc to your computer and use it in GitHub Desktop.
Save willies952002/999d1c8ee2c98b32c41999aa4091dfbc to your computer and use it in GitHub Desktop.
Wrapper for Bukkit's JavaPlugin to include TaskChain methods - Requires TaskChain: https://taskchain.emc.gs
/*
* Copyright (c) 2017 willies952002 <admin@domnian.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.domnian.mcutils; // Feel free to change this to your package
import co.aikar.taskchain.BukkitTaskChainFactory;
import co.aikar.taskchain.TaskChain;
import co.aikar.taskchain.TaskChainFactory;
import org.bukkit.plugin.java.JavaPlugin;
/**
* Wrapper for Bukkit's JavaPlugin to include TaskChain methods
* Important: Extend this class instead of JavaPlugin!
* Requires https://taskchain.emc.gs to function
*/
public class TaskChainedJavaPlugin extends JavaPlugin {
/**
* Instance of the TaskChain Factory
*/
private static TaskChainFactory taskchain;
/**
* Initialize the TaskChainFactory instance
* Call this in {@link #onEnable()}
*/
public void initTaskChain() {
taskchain = BukkitTaskChainFactory.create(this);
}
/**
* Get a New Task Chain
* @return A new Task Chain
*/
public static TaskChain<Object> newTaskChain() {
return taskchain.newChain();
}
/**
* Get a Shared Task Chain by Name
* @return An existing Shared Chain if found, else a new Shared Chain
*/
public static TaskChain<Object> newSharedChain(String name) {
return taskchain.newSharedChain(name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment