ButtonArchives/src/alisolarflare/Module.java

48 lines
2 KiB
Java
Raw Normal View History

2016-11-03 11:35:25 +00:00
package alisolarflare;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.lib.chat.TBMCChatAPI;
import buttondevteam.lib.chat.TBMCCommandBase;
/**
* A Module class is a helper class that allows the compacting of projects into one single package.
* Each feature, whether game, arrow trail listener, or command tool, can have its command and listener
* registration coded into the Module class, as well as any other pointers to memory units, or other
* classes in the package.
*
* This package can then be moved from eclipse project to eclipse project smoothly,
* as long as the destination project has the Module abstract class, and as long as all dependencies are either
* contained in the moved package, or moved along with it.
* @author Alisolarflare
*
*/
2016-11-03 11:35:25 +00:00
public abstract class Module{
/**
* Registers the project, when called by the Main JavaPlugin class that handles
* the main plugin.
*
* To register a command, call plugin.getCommand(//label).setExecutor(//commandExecutor); where
* label is a string containing the name of the command in plugin.yml, and where commandExecutor
* is a class implementing command executor
*
* To register a listener,
* @param plugin Plugin class called to register commands and listeners
*/
public abstract void register(JavaPlugin plugin);
/**
* Lazy route to type plugin.getCommand("label").setExecutor
* @param plugin Main plugin responsible for stuff
* @param label Name of the command in plugin.yml
* @param commandExecutor Custom coded CommandExecutor class
*/
protected <T extends TBMCCommandBase> void registerCommand(JavaPlugin plugin, String label, Class<T> commandExecutor){
TBMCChatAPI.AddCommands(plugin, commandExecutor);
}
protected Listener registerListener(JavaPlugin plugin, Listener listener){
plugin.getServer().getPluginManager().registerEvents(listener, plugin);
return listener;
}
}