From e6bac8b13ec6ab992c49e6d6e9c94ac1d7752fea Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 27 Sep 2017 18:44:06 +0300 Subject: [PATCH] Bungee reload functionality --- .../main/java/com/djrapitops/plan/PlanBungee.java | 13 +++++++++++-- .../main/java/com/djrapitops/plan/api/IPlan.java | 2 ++ .../plan/command/commands/ReloadCommand.java | 13 ++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index 3563d9e40..d62d2a273 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -8,6 +8,7 @@ import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.settings.ColorScheme; import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException; +import main.java.com.djrapitops.plan.command.commands.ReloadCommand; import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.databases.MySQLDB; import main.java.com.djrapitops.plan.locale.Locale; @@ -63,10 +64,12 @@ public class PlanBungee extends BungeePlugin implements IPlan { Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString()); initDatabase(); + registerCommand(new ReloadCommand(this)); + String ip = variableHolder.getIp(); if ("0.0.0.0".equals(ip)) { - Log.error("IP setting still 0.0.0.0 - Config AlternativeIP/IP that connects to the Proxy server."); - disablePlugin(); + Log.error("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server."); + Log.info("Player Analytics partially enabled (Use /planbungee to reload config)"); return; } @@ -172,4 +175,10 @@ public class PlanBungee extends BungeePlugin implements IPlan { public UUID getServerUuid() { return serverInfoManager.getServerUUID(); } + + @Override + public void restart() { + onDisable(); + onEnable(); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/IPlan.java b/Plan/src/main/java/com/djrapitops/plan/api/IPlan.java index 40e869ad8..8511827ff 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/IPlan.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/IPlan.java @@ -43,4 +43,6 @@ public interface IPlan extends IPlugin { InputStream getResource(String resource); IConfig getIConfig() throws IOException; + + void restart(); } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java index 2aefcc4da..1b676b71f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java @@ -5,6 +5,8 @@ import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.SubCommand; import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Plan; +import main.java.com.djrapitops.plan.PlanBungee; +import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Msg; @@ -16,7 +18,7 @@ import main.java.com.djrapitops.plan.locale.Msg; */ public class ReloadCommand extends SubCommand { - private final Plan plugin; + private final IPlan plugin; /** * Subcommand constructor. @@ -32,6 +34,15 @@ public class ReloadCommand extends SubCommand { this.plugin = plugin; } + public ReloadCommand(PlanBungee plugin) { + super("planbungee", + CommandType.CONSOLE, + Permissions.MANAGE.getPermission(), + Locale.get(Msg.CMD_USG_RELOAD).toString()); + + this.plugin = plugin; + } + @Override public boolean onCommand(ISender sender, String commandLabel, String[] args) { plugin.restart();