diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index d27e575..5623169 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -33,6 +33,7 @@ import static de.steamwar.command.SWCommandUtils.getAnnotation; public abstract class SWCommand { + private boolean enabled = true; private final Set commandSet = new HashSet<>(); private final Set commandHelpSet = new HashSet<>(); @@ -44,6 +45,7 @@ public abstract class SWCommand { SWCommandUtils.commandMap.register("steamwar", new Command(command, "", "/" + command, Arrays.asList(aliases)) { @Override public boolean execute(CommandSender sender, String alias, String[] args) { + if (!enabled) return false; for (SubCommand subCommand : commandSet) { if (subCommand.invoke(sender, args)) { return false; @@ -59,6 +61,7 @@ public abstract class SWCommand { @Override public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { + if (!enabled) return Collections.emptyList(); List strings = new ArrayList<>(); for (SubCommand subCommand : commandSet) { List tabCompletes = subCommand.tabComplete(sender, args); @@ -132,6 +135,14 @@ public abstract class SWCommand { consumer.accept(anno, parameters); } + protected boolean isEnabled() { + return enabled; + } + + protected void setEnabled(boolean enabled) { + this.enabled = enabled; + } + @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) protected @interface Register {