diff --git a/src/dev/w1zzrd/invtweaks/InvTweaksPlugin.java b/src/dev/w1zzrd/invtweaks/InvTweaksPlugin.java index 8f8d8e1..a842612 100644 --- a/src/dev/w1zzrd/invtweaks/InvTweaksPlugin.java +++ b/src/dev/w1zzrd/invtweaks/InvTweaksPlugin.java @@ -25,16 +25,27 @@ public final class InvTweaksPlugin extends JavaPlugin { public void onEnable() { logger.info(LOG_PLUGIN_NAME + " Plugin enabled"); - final PluginManager pluginManager = getServer().getPluginManager(); - - pluginManager.registerEvents(new StackReplaceListener(), this); - pluginManager.registerEvents(new SortListener(), this); + initCommands(); + initEvents(); } @Override public void onDisable() { logger.info(LOG_PLUGIN_NAME + " Plugin disabled"); + // Un-register all listeners 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); + } }