From 7defe7129f265b4af40a5ba8b29759a86f19e46a Mon Sep 17 00:00:00 2001 From: Hugo Kerstens Date: Fri, 1 Apr 2016 17:31:44 +0200 Subject: [PATCH] Implement subcommand to reload the config --- .../commands/ViaCommandHandler.java | 1 + .../commands/defaultsubs/ReloadSubCmd.java | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/main/java/us/myles/ViaVersion/commands/defaultsubs/ReloadSubCmd.java diff --git a/src/main/java/us/myles/ViaVersion/commands/ViaCommandHandler.java b/src/main/java/us/myles/ViaVersion/commands/ViaCommandHandler.java index 46880b3fe..4b44868c5 100644 --- a/src/main/java/us/myles/ViaVersion/commands/ViaCommandHandler.java +++ b/src/main/java/us/myles/ViaVersion/commands/ViaCommandHandler.java @@ -135,6 +135,7 @@ public class ViaCommandHandler implements ViaVersionCommand, CommandExecutor, Ta registerSubCommand(new DontBugMeSubCmd()); registerSubCommand(new AutoTeamSubCmd()); registerSubCommand(new HelpSubCmd()); + registerSubCommand(new ReloadSubCmd()); } public static String color(String string) { diff --git a/src/main/java/us/myles/ViaVersion/commands/defaultsubs/ReloadSubCmd.java b/src/main/java/us/myles/ViaVersion/commands/defaultsubs/ReloadSubCmd.java new file mode 100644 index 000000000..d335f8566 --- /dev/null +++ b/src/main/java/us/myles/ViaVersion/commands/defaultsubs/ReloadSubCmd.java @@ -0,0 +1,27 @@ +package us.myles.ViaVersion.commands.defaultsubs; + +import org.bukkit.command.CommandSender; +import us.myles.ViaVersion.ViaVersionPlugin; +import us.myles.ViaVersion.api.ViaVersion; +import us.myles.ViaVersion.api.command.ViaSubCommand; + +public class ReloadSubCmd extends ViaSubCommand { + @Override + public String name() { + return "reload"; + } + + @Override + public String description() { + return "Reload the config from the disk"; + } + + @Override + public boolean execute(CommandSender sender, String[] args) { + ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance(); + + plugin.generateConfig(); + sender.sendMessage(color("&6Configuration successfully reloaded! Some features may need a restart.")); + return true; + } +}