From fcb43684006c0ac7380b6cec4eaa52085a08a49a Mon Sep 17 00:00:00 2001 From: RoiEX Date: Fri, 28 Apr 2017 19:06:40 +0200 Subject: [PATCH] Add Router | Up version --- .../roiex/plugins/cmdhelper/CMDHelper.java | 19 +++++++++---------- .../plugins/cmdhelper/CommandRouter.java | 3 ++- src/main/resources/plugin.yml | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/roiex/plugins/cmdhelper/CMDHelper.java b/src/main/java/com/roiex/plugins/cmdhelper/CMDHelper.java index 5c34e23..c0e48ac 100644 --- a/src/main/java/com/roiex/plugins/cmdhelper/CMDHelper.java +++ b/src/main/java/com/roiex/plugins/cmdhelper/CMDHelper.java @@ -17,16 +17,15 @@ public class CMDHelper extends JavaPlugin { @Override public void onEnable() { CommandArgument.registerDefaults(); - // PluginCommand testCommand = getCommand("testCommand"); - // testCommand.setExecutor(new CommandExecutor() { - // - // @Override - // public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - // sender.sendMessage("Hi"); - // return true; - // } - // }); - // registerCommandSyntax(testCommand, "[ ]|[ ]|[ ] []", new PermissionMask(" ", "permission-coolness")); +// PluginCommand testCommand = getCommand("testCommand"); +// testCommand.setExecutor(new CommandRouter().addRoute(" ", (s, c, a, args) -> { +// System.out.println("Setblock"); +// return true; +// }).addRoute(" ", (s, c, a, args) -> { +// System.out.println("Other Stuff"); +// return true; +// })); +// registerCommandSyntax(testCommand, "[ ]|[ ]|[ ] []", new PermissionMask(" ", "permission-coolness")); } public void registerCommandSyntax(PluginCommand command, String structure, PermissionMask... permissionMasks) { diff --git a/src/main/java/com/roiex/plugins/cmdhelper/CommandRouter.java b/src/main/java/com/roiex/plugins/cmdhelper/CommandRouter.java index 2819b88..e0c52ac 100644 --- a/src/main/java/com/roiex/plugins/cmdhelper/CommandRouter.java +++ b/src/main/java/com/roiex/plugins/cmdhelper/CommandRouter.java @@ -11,8 +11,9 @@ public class CommandRouter implements CommandExecutor { private Map routes = new HashMap<>(); - public void addRoute(String pattern, CommandConsumer consumer){ + public CommandRouter addRoute(String pattern, CommandConsumer consumer){ routes.put(pattern, consumer); + return this; } @Override diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 260f75a..e52464f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: CMDHelper main: com.roiex.plugins.cmdhelper.CMDHelper -version: 1.0 +version: 2.1.0 #commands: # testCommand: # description: Some Test Command