mirror of
https://github.com/SimplexDevelopment/SimplexCL.git
synced 2024-11-14 14:33:34 +00:00
Minor Changes
Changed CommandBase#subCommand to return a boolean so you can check to see if it ran, to ensure that you only run the subcommand and not the subcommand AND the main command.
This commit is contained in:
parent
92990227b9
commit
aa54dd5f10
@ -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
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user