From 81cb364ddcaaf256479236ecfaa2dad47cf2316c Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 18 Nov 2018 02:58:26 +0100 Subject: [PATCH] Fixes, should be ready to merge --- ButtonCore/lombok.config | 1 + ButtonCore/pom.xml | 8 ++++++++ .../component/commands/CommandComponent.java | 5 ++--- .../component/restart/RestartComponent.java | 11 +++++------ .../updater/PluginUpdaterComponent.java | 7 +++---- .../java/buttondevteam/core/MainPlugin.java | 5 +++++ .../lib/architecture/Component.java | 19 +++++++++++-------- ButtonProcessor/pom.xml | 8 ++++++++ 8 files changed, 43 insertions(+), 21 deletions(-) create mode 100644 ButtonCore/lombok.config diff --git a/ButtonCore/lombok.config b/ButtonCore/lombok.config new file mode 100644 index 0000000..d959b09 --- /dev/null +++ b/ButtonCore/lombok.config @@ -0,0 +1 @@ +lombok.var.flagUsage = ALLOW diff --git a/ButtonCore/pom.xml b/ButtonCore/pom.xml index 3750f03..2ae8ac3 100755 --- a/ButtonCore/pom.xml +++ b/ButtonCore/pom.xml @@ -72,6 +72,14 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + false + + + diff --git a/ButtonCore/src/main/java/buttondevteam/component/commands/CommandComponent.java b/ButtonCore/src/main/java/buttondevteam/component/commands/CommandComponent.java index b3f1059..b85ad34 100644 --- a/ButtonCore/src/main/java/buttondevteam/component/commands/CommandComponent.java +++ b/ButtonCore/src/main/java/buttondevteam/component/commands/CommandComponent.java @@ -1,16 +1,15 @@ package buttondevteam.component.commands; import buttondevteam.lib.architecture.Component; -import org.bukkit.plugin.java.JavaPlugin; public class CommandComponent extends Component { //TODO: Do we just move everything here? @Override - public void register(JavaPlugin plugin) { + public void enable() { } @Override - public void unregister(JavaPlugin plugin) { + public void disable() { } } diff --git a/ButtonCore/src/main/java/buttondevteam/component/restart/RestartComponent.java b/ButtonCore/src/main/java/buttondevteam/component/restart/RestartComponent.java index 3061824..8184b8a 100644 --- a/ButtonCore/src/main/java/buttondevteam/component/restart/RestartComponent.java +++ b/ButtonCore/src/main/java/buttondevteam/component/restart/RestartComponent.java @@ -4,18 +4,17 @@ import buttondevteam.core.PrimeRestartCommand; import buttondevteam.core.ScheduledRestartCommand; import buttondevteam.lib.architecture.Component; import buttondevteam.lib.chat.TBMCChatAPI; -import org.bukkit.plugin.java.JavaPlugin; public class RestartComponent extends Component { @Override - public void register(JavaPlugin plugin) { - //TODO: Separately (dis)allow commands - TBMCChatAPI.AddCommand(plugin, ScheduledRestartCommand.class); - TBMCChatAPI.AddCommand(plugin, PrimeRestartCommand.class); + public void enable() { + //TODO: Permissions for the commands + TBMCChatAPI.AddCommand(getPlugin(), ScheduledRestartCommand.class); + TBMCChatAPI.AddCommand(getPlugin(), PrimeRestartCommand.class); } @Override - public void unregister(JavaPlugin plugin) { + public void disable() { } } diff --git a/ButtonCore/src/main/java/buttondevteam/component/updater/PluginUpdaterComponent.java b/ButtonCore/src/main/java/buttondevteam/component/updater/PluginUpdaterComponent.java index 1427927..2425631 100644 --- a/ButtonCore/src/main/java/buttondevteam/component/updater/PluginUpdaterComponent.java +++ b/ButtonCore/src/main/java/buttondevteam/component/updater/PluginUpdaterComponent.java @@ -2,16 +2,15 @@ package buttondevteam.component.updater; import buttondevteam.lib.architecture.Component; import buttondevteam.lib.chat.TBMCChatAPI; -import org.bukkit.plugin.java.JavaPlugin; public class PluginUpdaterComponent extends Component { @Override - public void register(JavaPlugin plugin) { - TBMCChatAPI.AddCommand(plugin, UpdatePluginCommand.class); + public void enable() { + TBMCChatAPI.AddCommand(getPlugin(), UpdatePluginCommand.class); } @Override - public void unregister(JavaPlugin plugin) { + public void disable() { //TODO: Unregister commands and such } } diff --git a/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java b/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java index ec130f1..9de7993 100755 --- a/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java +++ b/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java @@ -1,7 +1,10 @@ package buttondevteam.core; +import buttondevteam.component.restart.RestartComponent; import buttondevteam.component.updater.PluginUpdater; +import buttondevteam.component.updater.PluginUpdaterComponent; import buttondevteam.lib.TBMCCoreAPI; +import buttondevteam.lib.architecture.Component; import buttondevteam.lib.chat.Channel; import buttondevteam.lib.chat.ChatRoom; import buttondevteam.lib.chat.Color; @@ -40,6 +43,8 @@ public class MainPlugin extends JavaPlugin { setupPermissions(); Test = getConfig().getBoolean("test", true); saveConfig(); + Component.registerComponent(this, new PluginUpdaterComponent()); + Component.registerComponent(this, new RestartComponent()); ComponentManager.enableComponents(); TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this); TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class); diff --git a/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java b/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java index d59cbd9..faeb6a8 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java @@ -144,20 +144,23 @@ public abstract class Component { } /** - * Registers the module, when called by the JavaPlugin class. Call - * registerCommand() and registerListener() within this method. + * Registers the module, when called by the JavaPlugin class. + * This gets fired when the plugin is enabled. Use {@link #enable()} to register commands and such. * - * @param plugin Plugin class called to register commands and listeners + * @param plugin Plugin object */ - protected abstract void register(JavaPlugin plugin); + protected void register(JavaPlugin plugin) { + } /** - * Unregisters the module, when called by the JavaPlugin class. Do - * any cleanups needed within this method. + * Unregisters the module, when called by the JavaPlugin class. + * This gets fired when the plugin is disabled. + * Do any cleanups needed within this method. * - * @param plugin Plugin class called to register commands and listeners + * @param plugin Plugin object */ - protected abstract void unregister(JavaPlugin plugin); + protected void unregister(JavaPlugin plugin) { + } /** * Enables the module, when called by the JavaPlugin class. Call diff --git a/ButtonProcessor/pom.xml b/ButtonProcessor/pom.xml index 6a14248..a4ce7fa 100755 --- a/ButtonProcessor/pom.xml +++ b/ButtonProcessor/pom.xml @@ -23,6 +23,14 @@ -proc:none + + org.apache.maven.plugins + maven-surefire-plugin + + false + + +