From 718f43e303d6028ba2a53753beab5e6877ecf7d3 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 25 Jun 2016 02:02:38 +0200 Subject: [PATCH] The command system works! Kinda... --- plugin.yml | 7 - pom.xml | 134 +++++++++--------- .../norbipeti/thebuttonmcchat/PluginMain.java | 18 +-- .../commands/CommandCaller.java | 55 ++++++- .../commands/TBMCCommandBase.java | 11 -- .../commands/ucmds/HelpCommand.java | 29 ++-- .../commands/ucmds/UCommand.java | 8 +- .../commands/ucmds/UCommandBase.java | 6 - .../commands/ucmds/admin/AdminCommand.java | 8 +- .../ucmds/admin/AdminCommandBase.java | 10 +- .../commands/ucmds/admin/ConfirmCommand.java | 4 +- .../ucmds/admin/GetLastErrorCommand.java | 4 +- .../ucmds/admin/PlayerInfoCommand.java | 4 +- .../commands/ucmds/admin/ReloadCommand.java | 4 +- .../commands/ucmds/admin/SaveCommand.java | 4 +- .../commands/ucmds/admin/SetFlairCommand.java | 4 +- .../commands/ucmds/admin/UpdatePlugin.java | 4 +- .../commands/ucmds/announce/AddCommand.java | 4 +- .../ucmds/announce/AnnounceCommand.java | 9 +- .../ucmds/announce/AnnounceCommandBase.java | 19 +-- .../commands/ucmds/announce/EditCommand.java | 4 +- .../commands/ucmds/announce/ListCommand.java | 4 +- .../ucmds/announce/RemoveCommand.java | 4 +- .../ucmds/announce/SetTimeCommand.java | 4 +- 24 files changed, 189 insertions(+), 173 deletions(-) diff --git a/plugin.yml b/plugin.yml index 6b5d833..d25bbc3 100644 --- a/plugin.yml +++ b/plugin.yml @@ -4,30 +4,23 @@ version: 4.0 commands: u: description: Auto-flair system. Accept or ignore flair. - usage: "&cUsage: /u accept|ignore|opme&r" ooc: description: Send message in Out-of-Character. - usage: "&cUsage: /ooc &r" alias: nrp unlol: description: Unlaugh the last laugh. alias: unlaugh mwiki: description: Search the wiki. - usage: "&cUsage: /mwiki [query]&r" dontrunthiscmd: tableflip: description: Flip a table. - usage: "&cUsage: /tableflip [message]&r" unflip: description: Unflip a flip. - usage: "&cUsage: /unflip [message]&r" chatonly: description: Enable chat only mode. Useful for chat clients. - usage: "&cUsage: /chatonly&r" shrug: description: Shrug. - usage: "&cUsage: /shrug [message]&r" author: NorbiPeti depend: [Essentials, Towny, Minigames, Votifier, WorldGuard, WorldEdit, ProtocolLib, FastLogin, Vault, AuthMe] permissions: diff --git a/pom.xml b/pom.xml index d6b51a7..28ec1c6 100644 --- a/pom.xml +++ b/pom.xml @@ -1,68 +1,74 @@ 4.0.0 - TheButtonMCPlugin - 0.0.1-SNAPSHOT - The Button Minecraft Plugin - The Button Minecraft Plugin - - src - - - src - - **/*.java - - - - - - maven-compiler-plugin - 3.3 - - 1.7 - 1.7 - - - - org.apache.maven.plugins - maven-shade-plugin - 2.4.2 - - - package - - shade - - - - - classworlds:classworlds - junit:junit - jmock:* - *:xml-apis - org.apache.maven:lib:tests - log4j:log4j:jar: - - - - - - - - - tk.sznp - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - - - org.reflections - reflections - 0.9.10 - - + TheButtonMCPlugin + 0.0.1-SNAPSHOT + The Button Minecraft Plugin + The Button Minecraft Plugin + + src + + + src + + **/*.java + + + + + + maven-compiler-plugin + 3.3 + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-shade-plugin + 2.4.2 + + + package + + shade + + + + + classworlds:classworlds + junit:junit + jmock:* + *:xml-apis + org.apache.maven:lib:tests + log4j:log4j:jar: + + + + + + + + + + + + + + tk.sznp + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + + + org.reflections + reflections + 0.9.10 + runtime + + \ No newline at end of file diff --git a/src/io/github/norbipeti/thebuttonmcchat/PluginMain.java b/src/io/github/norbipeti/thebuttonmcchat/PluginMain.java index 945966a..183b4af 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/PluginMain.java +++ b/src/io/github/norbipeti/thebuttonmcchat/PluginMain.java @@ -25,8 +25,7 @@ import com.palmergames.bukkit.towny.object.Nation; import com.palmergames.bukkit.towny.object.Town; import com.palmergames.bukkit.towny.object.TownyUniverse; -import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase; - +import io.github.norbipeti.thebuttonmcchat.commands.CommandCaller; import java.io.*; import java.lang.String; import java.lang.reflect.Method; @@ -57,8 +56,10 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. public void onEnable() { try { System.out.println("Extracting necessary libraries..."); - final File[] libs = new File[] { new File(getDataFolder(), - "htmlcleaner-2.16.jar") }; + final File[] libs = new File[] { + new File(getDataFolder(), "htmlcleaner-2.16.jar"), + new File(getDataFolder(), "reflections-0.9.10.jar"), + new File(getDataFolder(), "javassist-3.19.0-GA.jar") }; for (final File lib : libs) { if (!lib.exists()) { JarUtils.extractFromJar(lib.getName(), @@ -81,7 +82,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. getServer().getPluginManager().registerEvents(new PlayerListener(), this); - TBMCCommandBase.RegisterCommands(this); + CommandCaller.RegisterCommands(this); Instance = this; Console = this.getServer().getConsoleSender(); LoadFiles(false); @@ -305,12 +306,11 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. public static void LoadFiles(boolean reload) { if (reload) { - System.out - .println("The Button Minecraft plugin cleanup for reloading..."); + System.out.println("TBMC chat plugin cleanup for reloading..."); MaybeOfflinePlayer.AllPlayers.clear(); AnnounceMessages.clear(); } - System.out.println("Loading files for The Button Minecraft plugin..."); + System.out.println("Loading files for TBMC chat plugin..."); try { File file = new File("thebuttonmc.yml"); if (file.exists()) { @@ -325,7 +325,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. AnnounceMessages.addAll(yc.getStringList("announcements")); PlayerListener.AlphaDeaths = yc.getInt("alphadeaths"); } - System.out.println("The Button Minecraft plugin loaded files!"); + System.out.println("TBMC plugin loaded files!"); } catch (IOException e) { System.out.println("Error!\n" + e); LastException = e; diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/CommandCaller.java b/src/io/github/norbipeti/thebuttonmcchat/commands/CommandCaller.java index 76f0e91..4ad27fb 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/CommandCaller.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/CommandCaller.java @@ -2,6 +2,7 @@ package io.github.norbipeti.thebuttonmcchat.commands; import io.github.norbipeti.thebuttonmcchat.PluginMain; +import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.HashMap; import java.util.Set; @@ -10,23 +11,62 @@ import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.command.PluginCommand; import org.reflections.Reflections; +import org.reflections.scanners.SubTypesScanner; +import org.reflections.util.ClasspathHelper; +import org.reflections.util.ConfigurationBuilder; public class CommandCaller implements CommandExecutor { + private CommandCaller() { + } + private static HashMap commands = new HashMap(); - public void RegisterCommands(PluginMain plugin) { + public static HashMap GetCommands() { + return commands; + } + + private static CommandCaller instance; + + public static void RegisterCommands(PluginMain plugin) { + if (instance != null) { + new Exception("Only one instance of CommandCaller is allowed") + .printStackTrace(); + return; + } System.out.println("Registering commands..."); + + CommandCaller cc = new CommandCaller(); + instance = cc; Reflections rf = new Reflections( - "io.github.norbipeti.thebuttonmcchat.commands"); + new ConfigurationBuilder() + .setUrls( + ClasspathHelper.forClassLoader(plugin + .getClass().getClassLoader())) + .addClassLoader(plugin.getClass().getClassLoader()) + .addScanners(new SubTypesScanner()) + .filterInputsBy( + (String pkg) -> pkg + .contains("io.github.norbipeti.thebuttonmcchat.commands"))); Set> cmds = rf .getSubTypesOf(TBMCCommandBase.class); for (Class cmd : cmds) { try { + if (Modifier.isAbstract(cmd.getModifiers())) + continue; TBMCCommandBase c = cmd.newInstance(); commands.put(c.GetCommandPath(), c); - plugin.getCommand(c.GetCommandPath()).setExecutor(this); + if (!c.GetCommandPath().contains("/")) // Top-level command + { + PluginCommand pc = plugin.getCommand(c.GetCommandPath()); + if (pc == null) + System.out.println("Can't find top-level command: " + + c.GetCommandPath()); + else + pc.setExecutor(cc); + } } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { @@ -50,6 +90,7 @@ public class CommandCaller implements CommandExecutor { path = path.substring(0, path.indexOf('/')); argc++; cmd = commands.get(path); + System.out.println(path); } if (cmd == null) { sender.sendMessage("§cInternal error: Command not registered to CommandCaller"); @@ -59,8 +100,12 @@ public class CommandCaller implements CommandExecutor { "§cInternal error: Command not registered to CommandCaller"); return true; } - cmd.OnCommand(sender, alias, - Arrays.copyOfRange(args, argc, args.length - 1)); + if (!cmd.OnCommand( + sender, + alias, + (args.length > 0 ? Arrays.copyOfRange(args, argc, + args.length - 1) : args))) + sender.sendMessage(cmd.GetHelpText(alias)); return true; } } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/TBMCCommandBase.java b/src/io/github/norbipeti/thebuttonmcchat/commands/TBMCCommandBase.java index ea94901..6fe9a64 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/TBMCCommandBase.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/TBMCCommandBase.java @@ -1,17 +1,6 @@ package io.github.norbipeti.thebuttonmcchat.commands; -import java.util.HashMap; - -import io.github.norbipeti.thebuttonmcchat.PluginMain; -import io.github.norbipeti.thebuttonmcchat.commands.appendtext.ShrugCommand; -import io.github.norbipeti.thebuttonmcchat.commands.appendtext.TableflipCommand; -import io.github.norbipeti.thebuttonmcchat.commands.appendtext.UnflipCommand; -import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommand; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; public abstract class TBMCCommandBase { diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/HelpCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/HelpCommand.java index 65de68f..192651d 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/HelpCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/HelpCommand.java @@ -1,5 +1,8 @@ package io.github.norbipeti.thebuttonmcchat.commands.ucmds; +import java.util.ArrayList; + +import io.github.norbipeti.thebuttonmcchat.commands.CommandCaller; import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase; import org.bukkit.command.CommandSender; @@ -17,9 +20,9 @@ public final class HelpCommand extends UCommandBase { if (args.length == 0) { sender.sendMessage(new String[] { "§6---- TBMC Help ----", - "Do /u help for more info", - "Alternatively, you can do /u help for more info about a command", - "Subcommands:", + "Do /u help for more info", + "Alternatively, you can do /u help [subcommands] for more info about a command", + "Topics:", "flairs: The flairs are the numbers near your name", "commands: See all the commands from this plugin", "login: If you or someone else has any problems with logins, lost inventory/location, etc." }); @@ -28,18 +31,22 @@ public final class HelpCommand extends UCommandBase { if (args[0].equalsIgnoreCase("flairs")) sender.sendMessage(new String[] { "§6---- About flairs ----", "" }); // TODO else if (args[0].equalsIgnoreCase("commands")) { - String[] text = new String[TBMCCommandBase.GetCommands().size() + 1]; + ArrayList text = new ArrayList(); int i = 0; - text[i++] = "§6---- Command list ----"; - for (TBMCCommandBase cmd : TBMCCommandBase.GetCommands().values()) - text[i++] = "/" + cmd.GetCommandName(); - sender.sendMessage(text); + text.set(i++, "§6---- Command list ----"); + for (TBMCCommandBase cmd : CommandCaller.GetCommands().values()) + if (!cmd.GetCommandPath().contains("/")) + text.set(i++, "/" + cmd.GetCommandPath()); + sender.sendMessage((String[]) text.toArray()); } else { - TBMCCommandBase cmd = TBMCCommandBase.GetCommands().get(args[0]); + String path = args[0]; + for (int i = 1; i < args.length; i++) + path += "/" + args[i]; + TBMCCommandBase cmd = CommandCaller.GetCommands().get(path); if (cmd == null) sender.sendMessage(new String[] { - "§cError: Command not found: " + args[0], - "Use either a command of this plugin or a subcommand (for example: /u accept --> /u help accept" }); + "§cError: Command not found: " + path.replace('/', ' '), + "Usage example: /u accept --> /u help u accept" }); else sender.sendMessage(cmd.GetHelpText(args[0])); } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/UCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/UCommand.java index 234bd1e..41782b1 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/UCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/UCommand.java @@ -4,12 +4,12 @@ import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase; import org.bukkit.command.CommandSender; -public final class UCommand extends UCommandBase { +public final class UCommand extends TBMCCommandBase { @Override public String[] GetHelpText(String alias) { return new String[] { "§6---- U commands ----", - "Subcommands: help, accept, ignore, admin" }; //TODO + "Subcommands: help, accept, ignore, admin" }; // TODO } @Override @@ -18,8 +18,8 @@ public final class UCommand extends UCommandBase { } @Override - public String GetUCommandPath() { - return "u"; // TODO: Same as at AdminCommand + public String GetCommandPath() { + return "u"; } @Override diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/UCommandBase.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/UCommandBase.java index 25d22e4..a415543 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/UCommandBase.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/UCommandBase.java @@ -1,9 +1,5 @@ package io.github.norbipeti.thebuttonmcchat.commands.ucmds; -import java.util.Arrays; - -import org.bukkit.command.CommandSender; - import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase; public abstract class UCommandBase extends TBMCCommandBase { @@ -12,8 +8,6 @@ public abstract class UCommandBase extends TBMCCommandBase { @Override public String GetCommandPath() { - if (GetUCommandPath().equals("u")) - return "u"; return "u/" + GetUCommandPath(); //TODO: This for others } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/AdminCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/AdminCommand.java index 2f6ca72..ab572c4 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/AdminCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/AdminCommand.java @@ -1,8 +1,10 @@ package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin; +import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommandBase; + import org.bukkit.command.CommandSender; -public final class AdminCommand extends AdminCommandBase { +public final class AdminCommand extends UCommandBase { @Override public String[] GetHelpText(String alias) { @@ -17,7 +19,7 @@ public final class AdminCommand extends AdminCommandBase { } @Override - public String GetAdminCommandName() { - return "admin"; //TODO: Call this by default (so /u admin invalidcmd should point here) + public String GetUCommandPath() { + return "admin"; } } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/AdminCommandBase.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/AdminCommandBase.java index 4c9c357..48cd973 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/AdminCommandBase.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/AdminCommandBase.java @@ -1,9 +1,5 @@ package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin; -import java.util.Arrays; - -import org.bukkit.command.CommandSender; - import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommandBase; public abstract class AdminCommandBase extends UCommandBase { @@ -12,9 +8,7 @@ public abstract class AdminCommandBase extends UCommandBase { @Override public String GetUCommandPath() { - if (GetAdminCommandName().equals("admin")) - return "admin"; - return "admin/" + GetAdminCommandName(); + return "admin/" + GetAdminCommandPath(); } @Override @@ -22,6 +16,6 @@ public abstract class AdminCommandBase extends UCommandBase { return false; // Allow admin commands in console } - public abstract String GetAdminCommandName(); + public abstract String GetAdminCommandPath(); } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ConfirmCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ConfirmCommand.java index aed4aa5..894e55c 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ConfirmCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ConfirmCommand.java @@ -28,7 +28,7 @@ public class ConfirmCommand extends AdminCommandBase { System.out.println("Error!\n" + e); if (sender != PluginMain.Console) sender.sendMessage("§cAn error occured. See console for details.§r"); - PluginMain.LastException = e; // 2015.08.09. + PluginMain.LastException = e; } } else sender.sendMessage("§cYou need to do /u admin reload first.§r"); @@ -36,7 +36,7 @@ public class ConfirmCommand extends AdminCommandBase { } @Override - public String GetAdminCommandName() { + public String GetAdminCommandPath() { return "confirm"; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/GetLastErrorCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/GetLastErrorCommand.java index e2fd032..0e9e3ff 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/GetLastErrorCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/GetLastErrorCommand.java @@ -14,7 +14,7 @@ public class GetLastErrorCommand extends AdminCommandBase { } @Override - public boolean OnAdminCommand(CommandSender sender, String alias, + public boolean OnCommand(CommandSender sender, String alias, String[] args) { if (PluginMain.LastException != null) { sender.sendMessage("Last error:"); @@ -26,7 +26,7 @@ public class GetLastErrorCommand extends AdminCommandBase { } @Override - public String GetAdminCommandName() { + public String GetAdminCommandPath() { return "getlasterror"; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/PlayerInfoCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/PlayerInfoCommand.java index 1d0fd12..2681835 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/PlayerInfoCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/PlayerInfoCommand.java @@ -15,7 +15,7 @@ public class PlayerInfoCommand extends AdminCommandBase { } @Override - public boolean OnAdminCommand(CommandSender sender, String alias, + public boolean OnCommand(CommandSender sender, String alias, String[] args) { if (args.length == 0) { return false; @@ -38,7 +38,7 @@ public class PlayerInfoCommand extends AdminCommandBase { } @Override - public String GetAdminCommandName() { + public String GetAdminCommandPath() { return "playerinfo"; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ReloadCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ReloadCommand.java index abe26c8..9230fcd 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ReloadCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ReloadCommand.java @@ -17,7 +17,7 @@ public final class ReloadCommand extends AdminCommandBase { public static CommandSender Reloader; @Override - public boolean OnAdminCommand(CommandSender sender, String alias, + public boolean OnCommand(CommandSender sender, String alias, String[] args) { Reloader = sender; sender.sendMessage("§bMake sure to save the current settings before you modify and reload them! Type /u admin confirm when done.§r"); @@ -25,7 +25,7 @@ public final class ReloadCommand extends AdminCommandBase { } @Override - public String GetAdminCommandName() { + public String GetAdminCommandPath() { return "reload"; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/SaveCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/SaveCommand.java index 2cda245..0b8e62c 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/SaveCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/SaveCommand.java @@ -13,7 +13,7 @@ public class SaveCommand extends AdminCommandBase { } @Override - public boolean OnAdminCommand(CommandSender sender, String alias, + public boolean OnCommand(CommandSender sender, String alias, String[] args) { PluginMain.SaveFiles(); // 2015.08.09. sender.sendMessage("§bSaved files. Now you can edit them and reload if you want.§r"); @@ -21,7 +21,7 @@ public class SaveCommand extends AdminCommandBase { } @Override - public String GetAdminCommandName() { + public String GetAdminCommandPath() { return "save"; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/SetFlairCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/SetFlairCommand.java index 387dcd6..9c407b0 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/SetFlairCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/SetFlairCommand.java @@ -20,7 +20,7 @@ public class SetFlairCommand extends AdminCommandBase { } @Override - public boolean OnAdminCommand(CommandSender sender, String alias, + public boolean OnCommand(CommandSender sender, String alias, String[] args) { if (args.length < 3) { return false; @@ -71,7 +71,7 @@ public class SetFlairCommand extends AdminCommandBase { } @Override - public String GetAdminCommandName() { + public String GetAdminCommandPath() { return "setflair"; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/UpdatePlugin.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/UpdatePlugin.java index 53d9b57..131e3c6 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/UpdatePlugin.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/UpdatePlugin.java @@ -19,7 +19,7 @@ public class UpdatePlugin extends AdminCommandBase { } @Override - public boolean OnAdminCommand(CommandSender sender, String alias, + public boolean OnCommand(CommandSender sender, String alias, String[] args) { sender.sendMessage("Updating Auto-Flair plugin..."); System.out.println("Forced updating of Auto-Flair plugin."); @@ -41,7 +41,7 @@ public class UpdatePlugin extends AdminCommandBase { } @Override - public String GetAdminCommandName() { + public String GetAdminCommandPath() { return "updateplugin"; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/AddCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/AddCommand.java index baf0a19..f8320d7 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/AddCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/AddCommand.java @@ -17,7 +17,7 @@ public class AddCommand extends AnnounceCommandBase { } @Override - public boolean OnAnnounceCommand(CommandSender sender, String alias, + public boolean OnCommand(CommandSender sender, String alias, String[] args) { if (args.length < 1) { return false; @@ -35,7 +35,7 @@ public class AddCommand extends AnnounceCommandBase { } @Override - public String GetAnnounceCommandName() { + public String GetAnnounceCommandPath() { return "add"; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/AnnounceCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/AnnounceCommand.java index f11a6ee..f55ef0e 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/AnnounceCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/AnnounceCommand.java @@ -1,8 +1,10 @@ package io.github.norbipeti.thebuttonmcchat.commands.ucmds.announce; +import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommandBase; + import org.bukkit.command.CommandSender; -public class AnnounceCommand extends AnnounceCommandBase { +public class AnnounceCommand extends UCommandBase { @Override public String[] GetHelpText(String alias) { @@ -11,13 +13,12 @@ public class AnnounceCommand extends AnnounceCommandBase { } @Override - public boolean OnAnnounceCommand(CommandSender sender, String alias, - String[] args) { + public boolean OnCommand(CommandSender sender, String alias, String[] args) { return false; } @Override - public String GetAnnounceCommandName() { + public String GetUCommandPath() { return "announce"; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/AnnounceCommandBase.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/AnnounceCommandBase.java index cb9645a..698d1ae 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/AnnounceCommandBase.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/AnnounceCommandBase.java @@ -1,9 +1,5 @@ package io.github.norbipeti.thebuttonmcchat.commands.ucmds.announce; -import java.util.Arrays; - -import org.bukkit.command.CommandSender; - import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommandBase; public abstract class AnnounceCommandBase extends UCommandBase { @@ -11,21 +7,10 @@ public abstract class AnnounceCommandBase extends UCommandBase { public abstract String[] GetHelpText(String alias); @Override - public boolean OnUCommand(CommandSender sender, String alias, String[] args) { - if (args.length == 0) - return false; - return OnAnnounceCommand(sender, alias, - Arrays.copyOfRange(args, 1, args.length)); //TODO: Only allow OPs and mods to use it - } - - public abstract boolean OnAnnounceCommand(CommandSender sender, - String alias, String[] args); - - @Override - public String GetUCommandName() { + public String GetUCommandPath() { return "announce"; } - public abstract String GetAnnounceCommandName(); + public abstract String GetAnnounceCommandPath(); } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/EditCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/EditCommand.java index 8d5929b..60094cb 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/EditCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/EditCommand.java @@ -15,7 +15,7 @@ public class EditCommand extends AnnounceCommandBase { } @Override - public boolean OnAnnounceCommand(CommandSender sender, String alias, + public boolean OnCommand(CommandSender sender, String alias, String[] args) { if (!(sender instanceof BlockCommandSender)) { sender.sendMessage("§cError: This command can only be used from a command block. You can use add and remove, though it's not recommended."); @@ -43,7 +43,7 @@ public class EditCommand extends AnnounceCommandBase { } @Override - public String GetAnnounceCommandName() { + public String GetAnnounceCommandPath() { return "edit"; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/ListCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/ListCommand.java index f4c0920..5e2dec7 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/ListCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/ListCommand.java @@ -13,7 +13,7 @@ public class ListCommand extends AnnounceCommandBase { } @Override - public boolean OnAnnounceCommand(CommandSender sender, String alias, + public boolean OnCommand(CommandSender sender, String alias, String[] args) { sender.sendMessage("§bList of announce messages:§r"); sender.sendMessage("§bFormat: [index] message§r"); @@ -26,7 +26,7 @@ public class ListCommand extends AnnounceCommandBase { } @Override - public String GetAnnounceCommandName() { + public String GetAnnounceCommandPath() { return "list"; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/RemoveCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/RemoveCommand.java index 3650dc5..0207c75 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/RemoveCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/RemoveCommand.java @@ -17,7 +17,7 @@ public class RemoveCommand extends AnnounceCommandBase { } @Override - public boolean OnAnnounceCommand(CommandSender sender, String alias, + public boolean OnCommand(CommandSender sender, String alias, String[] args) { if (args.length < 1) { sender.sendMessage("§cUsage: /u announce remove "); @@ -28,7 +28,7 @@ public class RemoveCommand extends AnnounceCommandBase { } @Override - public String GetAnnounceCommandName() { + public String GetAnnounceCommandPath() { return "remove"; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/SetTimeCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/SetTimeCommand.java index 89992d8..4fa356b 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/SetTimeCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/announce/SetTimeCommand.java @@ -14,7 +14,7 @@ public class SetTimeCommand extends AnnounceCommandBase { } @Override - public boolean OnAnnounceCommand(CommandSender sender, String alias, + public boolean OnCommand(CommandSender sender, String alias, String[] args) { if (args.length < 3) { return false; @@ -31,7 +31,7 @@ public class SetTimeCommand extends AnnounceCommandBase { } @Override - public String GetAnnounceCommandName() { + public String GetAnnounceCommandPath() { return "settime"; }