From 049ad551689ac56e19be3713c95d60dfe659b3a9 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 16 Mar 2019 14:33:03 +0100 Subject: [PATCH] Town/nation color fixes, reload command --- .../java/buttondevteam/chat/PluginMain.java | 2 ++ .../chat/commands/ucmds/ReloadCommand.java | 20 +++++++++++++++++++ .../towncolors/TownColorComponent.java | 1 + .../towncolors/admin/NationColorCommand.java | 2 +- .../towncolors/admin/TownColorCommand.java | 2 +- 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 src/main/java/buttondevteam/chat/commands/ucmds/ReloadCommand.java diff --git a/src/main/java/buttondevteam/chat/PluginMain.java b/src/main/java/buttondevteam/chat/PluginMain.java index ad7efb5..f35261b 100644 --- a/src/main/java/buttondevteam/chat/PluginMain.java +++ b/src/main/java/buttondevteam/chat/PluginMain.java @@ -4,6 +4,7 @@ import buttondevteam.chat.commands.MWikiCommand; import buttondevteam.chat.commands.ucmds.HelpCommand; import buttondevteam.chat.commands.ucmds.HistoryCommand; import buttondevteam.chat.commands.ucmds.InfoCommand; +import buttondevteam.chat.commands.ucmds.ReloadCommand; import buttondevteam.chat.commands.ucmds.admin.DebugCommand; import buttondevteam.chat.components.announce.AnnouncerComponent; import buttondevteam.chat.components.appendext.AppendTextComponent; @@ -77,6 +78,7 @@ public class PluginMain extends ButtonPlugin { // Translated to Java: 2015.07.15 getCommand2MC().registerCommand(new HistoryCommand()); getCommand2MC().registerCommand(new InfoCommand()); getCommand2MC().registerCommand(new MWikiCommand()); + getCommand2MC().registerCommand(new ReloadCommand()); } public static Essentials essentials = null; diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/ReloadCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/ReloadCommand.java new file mode 100644 index 0000000..e5b5ef4 --- /dev/null +++ b/src/main/java/buttondevteam/chat/commands/ucmds/ReloadCommand.java @@ -0,0 +1,20 @@ +package buttondevteam.chat.commands.ucmds; + +import buttondevteam.chat.PluginMain; +import buttondevteam.lib.chat.Command2; +import buttondevteam.lib.chat.CommandClass; +import org.bukkit.command.CommandSender; + +@CommandClass(helpText = { + "Reload", + "Reloads Thorpe-Chat" +}, modOnly = true) +public class ReloadCommand extends UCommandBase { + @Command2.Subcommand + public void def(CommandSender sender) { + if (PluginMain.Instance.tryReloadConfig()) + sender.sendMessage("§bReloaded config"); + else + sender.sendMessage("§cFailed to reload config."); + } +} diff --git a/src/main/java/buttondevteam/chat/components/towncolors/TownColorComponent.java b/src/main/java/buttondevteam/chat/components/towncolors/TownColorComponent.java index ab41374..00c92ac 100644 --- a/src/main/java/buttondevteam/chat/components/towncolors/TownColorComponent.java +++ b/src/main/java/buttondevteam/chat/components/towncolors/TownColorComponent.java @@ -113,6 +113,7 @@ public class TownColorComponent extends Component implements Listene if (useNationColors().get()) registerCommand(new buttondevteam.chat.components.towncolors.admin.NationColorCommand()); registerCommand(new TCCount()); + registerCommand(new NColorCommand()); registerListener(new TownyListener()); registerListener(this); } diff --git a/src/main/java/buttondevteam/chat/components/towncolors/admin/NationColorCommand.java b/src/main/java/buttondevteam/chat/components/towncolors/admin/NationColorCommand.java index 963cb05..77bba40 100644 --- a/src/main/java/buttondevteam/chat/components/towncolors/admin/NationColorCommand.java +++ b/src/main/java/buttondevteam/chat/components/towncolors/admin/NationColorCommand.java @@ -35,7 +35,7 @@ public class NationColorCommand extends AdminCommandBase { if (!c.get().getName().equals(Color.White.getName())) { //Default nation color for (val e : TownColorComponent.NationColor.entrySet()) { if (e.getValue().getName().equals(c.get().getName())) { - sender.sendMessage("§The nation " + e.getKey() + " already uses this color!"); + sender.sendMessage("§cThe nation " + e.getKey() + " already uses this color!"); return true; } } diff --git a/src/main/java/buttondevteam/chat/components/towncolors/admin/TownColorCommand.java b/src/main/java/buttondevteam/chat/components/towncolors/admin/TownColorCommand.java index 618ef06..288447e 100644 --- a/src/main/java/buttondevteam/chat/components/towncolors/admin/TownColorCommand.java +++ b/src/main/java/buttondevteam/chat/components/towncolors/admin/TownColorCommand.java @@ -41,7 +41,7 @@ public class TownColorCommand extends AdminCommandBase { //TODO: Command path al val c = getColorOrSendError(colors[i], sender); if (!c.isPresent()) return true; - clrs[i - 1] = c.get(); + clrs[i] = c.get(); } Color tnc; boolean usenc = TownColorComponent.getComponent().useNationColors().get();