Compartmentalize plugin initialization
This commit is contained in:
parent
ee9f962fac
commit
da495eb88a
@ -25,16 +25,27 @@ public final class InvTweaksPlugin extends JavaPlugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
logger.info(LOG_PLUGIN_NAME + " Plugin enabled");
|
logger.info(LOG_PLUGIN_NAME + " Plugin enabled");
|
||||||
|
|
||||||
final PluginManager pluginManager = getServer().getPluginManager();
|
initCommands();
|
||||||
|
initEvents();
|
||||||
pluginManager.registerEvents(new StackReplaceListener(), this);
|
|
||||||
pluginManager.registerEvents(new SortListener(), this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
logger.info(LOG_PLUGIN_NAME + " Plugin disabled");
|
logger.info(LOG_PLUGIN_NAME + " Plugin disabled");
|
||||||
|
|
||||||
|
// Un-register all listeners
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void initCommands() {
|
||||||
|
Objects.requireNonNull(getCommand("sort")).setExecutor(new SortCommandExecutor());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initEvents() {
|
||||||
|
final PluginManager pluginManager = getServer().getPluginManager();
|
||||||
|
|
||||||
|
pluginManager.registerEvents(new StackReplaceListener(), this);
|
||||||
|
pluginManager.registerEvents(new SortListener(), this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user