diff --git a/src/main/java/io/github/simplex/cl/CommandBase.java b/src/main/java/io/github/simplex/cl/CommandBase.java index 57448d9..7c66dfd 100644 --- a/src/main/java/io/github/simplex/cl/CommandBase.java +++ b/src/main/java/io/github/simplex/cl/CommandBase.java @@ -116,14 +116,14 @@ public abstract class CommandBase extends Permissible implements ICommand { * @param command The SubCommand to run. * This is a functional interface to provide easy implementation of the command's details. */ - public void subCommand(@NotNull String name, @NotNull CommandSender sender, @NotNull String permission, String @NotNull [] args, @NotNull SubCommand command) { + public boolean subCommand(@NotNull String name, @NotNull CommandSender sender, @NotNull String permission, String @NotNull [] args, @NotNull SubCommand command) { if (!sender.hasPermission(permission)) { sender.sendMessage(msg(getPermissionMessage())); - return; + return true; } if (args.length == 0) { - return; + return false; } String[] tieredCmd = name.split(" "); @@ -131,13 +131,13 @@ public abstract class CommandBase extends Permissible implements ICommand { if (args.length == 1 && tieredCmd.length == 1) { if (args[0].equalsIgnoreCase(name)) { command.execute(); - return; + return true; } } if (args.length == 2 && tieredCmd.length == 2) { if (args[0].equalsIgnoreCase(tieredCmd[0]) && args[1].equalsIgnoreCase(tieredCmd[1])) { command.execute(); - return; + return true; } } if (args.length == 3 && tieredCmd.length == 3) { @@ -145,7 +145,7 @@ public abstract class CommandBase extends Permissible implements ICommand { && args[1].equalsIgnoreCase(tieredCmd[1]) && args[2].equalsIgnoreCase(tieredCmd[2])) { command.execute(); - return; + return true; } } if (args.length == 4 && tieredCmd.length == 4) { @@ -154,8 +154,10 @@ public abstract class CommandBase extends Permissible implements ICommand { && args[2].equalsIgnoreCase(tieredCmd[2]) && args[3].equalsIgnoreCase(tieredCmd[3])) { command.execute(); + return true; } } + return false; } @Nullable diff --git a/src/main/java/io/github/simplex/cl/impl/ExampleCommand.java b/src/main/java/io/github/simplex/cl/impl/ExampleCommand.java index 6297aaf..2f3915f 100644 --- a/src/main/java/io/github/simplex/cl/impl/ExampleCommand.java +++ b/src/main/java/io/github/simplex/cl/impl/ExampleCommand.java @@ -16,13 +16,13 @@ public final class ExampleCommand extends CommandBase { @Override public void execute(CommandSender sender, String[] args, boolean allowConsole) { - subCommand("info", sender, getPermission() + ".info", args, () -> { - sender.sendMessage(msg("SimplexCL was created by SimplexDevelopment!", BasicColors.GOLD)); - }); + if (subCommand("info", sender, getPermission() + ".info", args, () -> sender.sendMessage(msg("SimplexCL was created by SimplexDevelopment!", BasicColors.GOLD)))) { + return; + } - subCommand("info more", sender, getPermission() + ".info.more", args, () -> { - sender.sendMessage(msg("https://github.com/SimplexDevelopment", AdvancedColors.FUCHSIA)); - }); + if (subCommand("info more", sender, getPermission() + ".info.more", args, () -> sender.sendMessage(msg("https://github.com/SimplexDevelopment", AdvancedColors.FUCHSIA)))) { + return; + } sender.sendMessage(msg("This is an example command.", BasicColors.BLUE)); }