diff --git a/core/src/main/java/co/aikar/commands/BaseCommand.java b/core/src/main/java/co/aikar/commands/BaseCommand.java index c051dfc4..ea0ff33e 100644 --- a/core/src/main/java/co/aikar/commands/BaseCommand.java +++ b/core/src/main/java/co/aikar/commands/BaseCommand.java @@ -324,7 +324,9 @@ public abstract class BaseCommand { } - if (subCommands.get(UNKNOWN) != null) { + if (subCommands.get(DEFAULT) != null && args.length == 0) { + executeSubcommand(commandContext, DEFAULT, issuer, args); + } else if (subCommands.get(UNKNOWN) != null) { if (!executeSubcommand(commandContext, UNKNOWN, issuer, args)) { help(issuer, args); } diff --git a/docs/acf-core/co/aikar/commands/BaseCommand.html b/docs/acf-core/co/aikar/commands/BaseCommand.html index 844b9eac..ff499af8 100644 --- a/docs/acf-core/co/aikar/commands/BaseCommand.html +++ b/docs/acf-core/co/aikar/commands/BaseCommand.html @@ -421,7 +421,7 @@ extends
  • getCurrentCommandIssuer

    -
    public CommandIssuer getCurrentCommandIssuer()
    +
    public CommandIssuer getCurrentCommandIssuer()
  • @@ -430,7 +430,7 @@ extends
  • getCurrentCommandManager

    -
    public CommandManager getCurrentCommandManager()
    +
    public CommandManager getCurrentCommandManager()
  • @@ -439,7 +439,7 @@ extends
  • canExecute

    -
    public boolean canExecute(CommandIssuer issuer,
    +
    public boolean canExecute(CommandIssuer issuer,
                               RegisteredCommand<?> cmd)
  • @@ -449,7 +449,7 @@ extends
  • tabComplete

    -
    public List<StringtabComplete(CommandIssuer issuer,
    +
    public List<StringtabComplete(CommandIssuer issuer,
                                     String commandLabel,
                                     String[] args)
                              throws IllegalArgumentException
    @@ -466,7 +466,7 @@ extends

    getCommandHelp

    @Deprecated
    -public CommandHelp getCommandHelp()
    +public CommandHelp getCommandHelp()
    Deprecated. Unstable API
  • @@ -477,7 +477,7 @@ public 

    showCommandHelp

    @Deprecated
    -public void showCommandHelp()
    +public void showCommandHelp()
    Deprecated. Unstable API
    @@ -487,7 +487,7 @@ public void 
  • help

    -
    public void help(Object issuer,
    +
    public void help(Object issuer,
                      String[] args)
  • @@ -497,7 +497,7 @@ public void 
  • help

    -
    public void help(CommandIssuer issuer,
    +
    public void help(CommandIssuer issuer,
                      String[] args)
  • @@ -507,7 +507,7 @@ public void 
  • doHelp

    -
    public void doHelp(Object issuer,
    +
    public void doHelp(Object issuer,
                        String... args)
  • @@ -517,7 +517,7 @@ public void 
  • doHelp

    -
    public void doHelp(CommandIssuer issuer,
    +
    public void doHelp(CommandIssuer issuer,
                        String... args)
  • @@ -527,7 +527,7 @@ public void 
  • showSyntax

    -
    public void showSyntax(CommandIssuer issuer,
    +
    public void showSyntax(CommandIssuer issuer,
                            RegisteredCommand<?> cmd)
  • @@ -537,7 +537,7 @@ public void 
  • hasPermission

    -
    public boolean hasPermission(Object issuer)
    +
    public boolean hasPermission(Object issuer)
  • @@ -546,7 +546,7 @@ public void 
  • hasPermission

    -
    public boolean hasPermission(CommandIssuer issuer)
    +
    public boolean hasPermission(CommandIssuer issuer)
  • @@ -555,7 +555,7 @@ public void 
  • getName

    -
    public String getName()
    +
    public String getName()
  • @@ -564,7 +564,7 @@ public void 
  • getExceptionHandler

    -
    public ExceptionHandler getExceptionHandler()
    +
    public ExceptionHandler getExceptionHandler()
  • @@ -573,7 +573,7 @@ public void 
  • setExceptionHandler

    -
    public BaseCommand setExceptionHandler(ExceptionHandler exceptionHandler)
    +
    public BaseCommand setExceptionHandler(ExceptionHandler exceptionHandler)
  • diff --git a/docs/acf-core/src-html/co/aikar/commands/BaseCommand.html b/docs/acf-core/src-html/co/aikar/commands/BaseCommand.html index 6eb1fef4..a64ab518 100644 --- a/docs/acf-core/src-html/co/aikar/commands/BaseCommand.html +++ b/docs/acf-core/src-html/co/aikar/commands/BaseCommand.html @@ -332,285 +332,286 @@ 324 } 325 326 -327 if (subCommands.get(UNKNOWN) != null) { -328 if (!executeSubcommand(commandContext, UNKNOWN, issuer, args)) { -329 help(issuer, args); -330 -331 } -332 } else if (subCommands.get(DEFAULT) != null) { -333 executeSubcommand(commandContext, DEFAULT, issuer, args); -334 } -335 -336 } finally { -337 postCommandOperation(); -338 } -339 } -340 -341 private void postCommandOperation() { -342 CommandManager.commandOperationContext.get().pop(); -343 execSubcommand = null; -344 execLabel = null; -345 origArgs = new String[]{}; -346 } -347 -348 private CommandOperationContext preCommandOperation(CommandIssuer issuer, String commandLabel, String[] args) { -349 Stack<CommandOperationContext> contexts = CommandManager.commandOperationContext.get(); -350 CommandOperationContext context = this.manager.createCommandOperationContext(this, issuer, commandLabel, args); -351 contexts.push(context); -352 lastCommandOperationContext = context; -353 execSubcommand = null; -354 execLabel = commandLabel; -355 origArgs = args; -356 return context; -357 } -358 -359 public CommandIssuer getCurrentCommandIssuer() { -360 return CommandManager.getCurrentCommandIssuer(); -361 } -362 public CommandManager getCurrentCommandManager() { -363 return CommandManager.getCurrentCommandManager(); -364 } -365 -366 private CommandSearch findSubCommand(String[] args) { -367 return findSubCommand(args, false); -368 } -369 private CommandSearch findSubCommand(String[] args, boolean completion) { -370 for (int i = args.length; i >= 0; i--) { -371 String checkSub = ApacheCommonsLangUtil.join(args, " ", 0, i).toLowerCase(); -372 Set<RegisteredCommand> cmds = subCommands.get(checkSub); -373 -374 final int extraArgs = args.length - i; -375 if (!cmds.isEmpty()) { -376 RegisteredCommand cmd = null; -377 if (cmds.size() == 1) { -378 cmd = Iterables.getOnlyElement(cmds); -379 } else { -380 Optional<RegisteredCommand> optCmd = cmds.stream().filter(c -> { -381 int required = c.requiredResolvers; -382 int optional = c.optionalResolvers; -383 return extraArgs <= required + optional && (completion || extraArgs >= required); -384 }).sorted((c1, c2) -> { -385 int a = c1.requiredResolvers + c1.optionalResolvers; -386 int b = c2.requiredResolvers + c2.optionalResolvers; -387 -388 if (a == b) { -389 return 0; -390 } -391 return a < b ? 1 : -1; -392 }).findFirst(); -393 if (optCmd.isPresent()) { -394 cmd = optCmd.get(); -395 } -396 } -397 if (cmd != null) { -398 return new CommandSearch(cmd, i, checkSub); -399 } -400 } -401 } -402 return null; -403 } -404 -405 private void executeCommand(CommandOperationContext commandOperationContext, -406 CommandIssuer issuer, String[] args, RegisteredCommand cmd) { -407 if (cmd.hasPermission(issuer)) { -408 commandOperationContext.setRegisteredCommand(cmd); -409 if (checkPrecommand(commandOperationContext, cmd, issuer, args)) { -410 return; -411 } -412 List<String> sargs = Lists.newArrayList(args); -413 cmd.invoke(issuer, sargs); -414 } else { -415 issuer.sendMessage(MessageType.ERROR, MessageKeys.PERMISSION_DENIED); -416 } -417 } -418 -419 public boolean canExecute(CommandIssuer issuer, RegisteredCommand<?> cmd) { -420 return true; -421 } -422 -423 public List<String> tabComplete(CommandIssuer issuer, String commandLabel, String[] args) -424 throws IllegalArgumentException { -425 -426 commandLabel = commandLabel.toLowerCase(); -427 try { -428 CommandOperationContext commandOperationContext = preCommandOperation(issuer, commandLabel, args); -429 -430 final CommandSearch search = findSubCommand(args, true); -431 -432 String argString = ApacheCommonsLangUtil.join(args, " ").toLowerCase(); -433 -434 final List<String> cmds = new ArrayList<>(); -435 -436 if (search != null) { -437 cmds.addAll(completeCommand(commandOperationContext, issuer, search.cmd, Arrays.copyOfRange(args, search.argIndex, args.length), commandLabel)); -438 } else if (subCommands.get(UNKNOWN).size() == 1) { -439 cmds.addAll(completeCommand(commandOperationContext, issuer, Iterables.getOnlyElement(subCommands.get(UNKNOWN)), args, commandLabel)); -440 } -441 -442 for (Map.Entry<String, RegisteredCommand> entry : subCommands.entries()) { -443 final String key = entry.getKey(); -444 if (key.startsWith(argString) && !UNKNOWN.equals(key) && !DEFAULT.equals(key)) { -445 final RegisteredCommand value = entry.getValue(); -446 if (!value.hasPermission(issuer)) { -447 continue; -448 } -449 String prefCommand = value.prefSubCommand; -450 -451 final String[] psplit = ACFPatterns.SPACE.split(prefCommand); -452 cmds.add(psplit[args.length - 1]); -453 } -454 } -455 -456 return filterTabComplete(args[args.length - 1], cmds); -457 } finally { -458 postCommandOperation(); -459 } -460 } -461 -462 private List<String> completeCommand(CommandOperationContext commandOperationContext, CommandIssuer issuer, RegisteredCommand cmd, String[] args, String commandLabel) { -463 if (!cmd.hasPermission(issuer) || args.length > cmd.requiredResolvers + cmd.optionalResolvers || args.length == 0 -464 || cmd.complete == null) { -465 return ImmutableList.of(); -466 } -467 -468 String[] completions = ACFPatterns.SPACE.split(cmd.complete); -469 -470 List<String> cmds = manager.getCommandCompletions().of(commandOperationContext, cmd, issuer, completions, args); -471 return filterTabComplete(args[args.length-1], cmds); -472 } -473 -474 private static List<String> filterTabComplete(String arg, List<String> cmds) { -475 return cmds.stream() -476 .distinct() -477 .filter(cmd -> cmd != null && (arg.isEmpty() || ApacheCommonsLangUtil.startsWithIgnoreCase(cmd, arg))) -478 .collect(Collectors.toList()); -479 } -480 +327 if (subCommands.get(DEFAULT) != null && args.length == 0) { +328 executeSubcommand(commandContext, DEFAULT, issuer, args); +329 } else if (subCommands.get(UNKNOWN) != null) { +330 if (!executeSubcommand(commandContext, UNKNOWN, issuer, args)) { +331 help(issuer, args); +332 } +333 } else if (subCommands.get(DEFAULT) != null) { +334 executeSubcommand(commandContext, DEFAULT, issuer, args); +335 } +336 +337 } finally { +338 postCommandOperation(); +339 } +340 } +341 +342 private void postCommandOperation() { +343 CommandManager.commandOperationContext.get().pop(); +344 execSubcommand = null; +345 execLabel = null; +346 origArgs = new String[]{}; +347 } +348 +349 private CommandOperationContext preCommandOperation(CommandIssuer issuer, String commandLabel, String[] args) { +350 Stack<CommandOperationContext> contexts = CommandManager.commandOperationContext.get(); +351 CommandOperationContext context = this.manager.createCommandOperationContext(this, issuer, commandLabel, args); +352 contexts.push(context); +353 lastCommandOperationContext = context; +354 execSubcommand = null; +355 execLabel = commandLabel; +356 origArgs = args; +357 return context; +358 } +359 +360 public CommandIssuer getCurrentCommandIssuer() { +361 return CommandManager.getCurrentCommandIssuer(); +362 } +363 public CommandManager getCurrentCommandManager() { +364 return CommandManager.getCurrentCommandManager(); +365 } +366 +367 private CommandSearch findSubCommand(String[] args) { +368 return findSubCommand(args, false); +369 } +370 private CommandSearch findSubCommand(String[] args, boolean completion) { +371 for (int i = args.length; i >= 0; i--) { +372 String checkSub = ApacheCommonsLangUtil.join(args, " ", 0, i).toLowerCase(); +373 Set<RegisteredCommand> cmds = subCommands.get(checkSub); +374 +375 final int extraArgs = args.length - i; +376 if (!cmds.isEmpty()) { +377 RegisteredCommand cmd = null; +378 if (cmds.size() == 1) { +379 cmd = Iterables.getOnlyElement(cmds); +380 } else { +381 Optional<RegisteredCommand> optCmd = cmds.stream().filter(c -> { +382 int required = c.requiredResolvers; +383 int optional = c.optionalResolvers; +384 return extraArgs <= required + optional && (completion || extraArgs >= required); +385 }).sorted((c1, c2) -> { +386 int a = c1.requiredResolvers + c1.optionalResolvers; +387 int b = c2.requiredResolvers + c2.optionalResolvers; +388 +389 if (a == b) { +390 return 0; +391 } +392 return a < b ? 1 : -1; +393 }).findFirst(); +394 if (optCmd.isPresent()) { +395 cmd = optCmd.get(); +396 } +397 } +398 if (cmd != null) { +399 return new CommandSearch(cmd, i, checkSub); +400 } +401 } +402 } +403 return null; +404 } +405 +406 private void executeCommand(CommandOperationContext commandOperationContext, +407 CommandIssuer issuer, String[] args, RegisteredCommand cmd) { +408 if (cmd.hasPermission(issuer)) { +409 commandOperationContext.setRegisteredCommand(cmd); +410 if (checkPrecommand(commandOperationContext, cmd, issuer, args)) { +411 return; +412 } +413 List<String> sargs = Lists.newArrayList(args); +414 cmd.invoke(issuer, sargs); +415 } else { +416 issuer.sendMessage(MessageType.ERROR, MessageKeys.PERMISSION_DENIED); +417 } +418 } +419 +420 public boolean canExecute(CommandIssuer issuer, RegisteredCommand<?> cmd) { +421 return true; +422 } +423 +424 public List<String> tabComplete(CommandIssuer issuer, String commandLabel, String[] args) +425 throws IllegalArgumentException { +426 +427 commandLabel = commandLabel.toLowerCase(); +428 try { +429 CommandOperationContext commandOperationContext = preCommandOperation(issuer, commandLabel, args); +430 +431 final CommandSearch search = findSubCommand(args, true); +432 +433 String argString = ApacheCommonsLangUtil.join(args, " ").toLowerCase(); +434 +435 final List<String> cmds = new ArrayList<>(); +436 +437 if (search != null) { +438 cmds.addAll(completeCommand(commandOperationContext, issuer, search.cmd, Arrays.copyOfRange(args, search.argIndex, args.length), commandLabel)); +439 } else if (subCommands.get(UNKNOWN).size() == 1) { +440 cmds.addAll(completeCommand(commandOperationContext, issuer, Iterables.getOnlyElement(subCommands.get(UNKNOWN)), args, commandLabel)); +441 } +442 +443 for (Map.Entry<String, RegisteredCommand> entry : subCommands.entries()) { +444 final String key = entry.getKey(); +445 if (key.startsWith(argString) && !UNKNOWN.equals(key) && !DEFAULT.equals(key)) { +446 final RegisteredCommand value = entry.getValue(); +447 if (!value.hasPermission(issuer)) { +448 continue; +449 } +450 String prefCommand = value.prefSubCommand; +451 +452 final String[] psplit = ACFPatterns.SPACE.split(prefCommand); +453 cmds.add(psplit[args.length - 1]); +454 } +455 } +456 +457 return filterTabComplete(args[args.length - 1], cmds); +458 } finally { +459 postCommandOperation(); +460 } +461 } +462 +463 private List<String> completeCommand(CommandOperationContext commandOperationContext, CommandIssuer issuer, RegisteredCommand cmd, String[] args, String commandLabel) { +464 if (!cmd.hasPermission(issuer) || args.length > cmd.requiredResolvers + cmd.optionalResolvers || args.length == 0 +465 || cmd.complete == null) { +466 return ImmutableList.of(); +467 } +468 +469 String[] completions = ACFPatterns.SPACE.split(cmd.complete); +470 +471 List<String> cmds = manager.getCommandCompletions().of(commandOperationContext, cmd, issuer, completions, args); +472 return filterTabComplete(args[args.length-1], cmds); +473 } +474 +475 private static List<String> filterTabComplete(String arg, List<String> cmds) { +476 return cmds.stream() +477 .distinct() +478 .filter(cmd -> cmd != null && (arg.isEmpty() || ApacheCommonsLangUtil.startsWithIgnoreCase(cmd, arg))) +479 .collect(Collectors.toList()); +480 } 481 -482 private boolean executeSubcommand(CommandOperationContext commandContext, String subcommand, CommandIssuer issuer, String... args) { -483 final Set<RegisteredCommand> defs = subCommands.get(subcommand); -484 RegisteredCommand def = null; -485 if (!defs.isEmpty()) { -486 if (defs.size() == 1) { -487 def = defs.iterator().next(); -488 } -489 if (def != null) { -490 executeCommand(commandContext, issuer, args, def); -491 return true; -492 } -493 } -494 return false; -495 } -496 -497 private boolean checkPrecommand(CommandOperationContext commandOperationContext, RegisteredCommand cmd, CommandIssuer issuer, String[] args) { -498 Method pre = this.preCommandHandler; -499 if (pre != null) { -500 try { -501 Class<?>[] types = pre.getParameterTypes(); -502 Object[] parameters = new Object[pre.getParameterCount()]; -503 for (int i = 0; i < parameters.length; i++) { -504 Class<?> type = types[i]; -505 Object issuerObject = issuer.getIssuer(); -506 if (manager.isCommandIssuer(type) && type.isAssignableFrom(issuerObject.getClass())) { -507 parameters[i] = issuerObject; -508 } else if (CommandIssuer.class.isAssignableFrom(type)) { -509 parameters[i] = issuer; -510 } else if (RegisteredCommand.class.isAssignableFrom(type)) { -511 parameters[i] = cmd; -512 } else if (String[].class.isAssignableFrom((type))) { -513 parameters[i] = args; -514 } else { -515 parameters[i] = null; -516 } -517 } -518 -519 return (boolean) pre.invoke(this, parameters); -520 } catch (IllegalAccessException | InvocationTargetException e) { -521 this.manager.log(LogLevel.ERROR, "Exception encountered while command pre-processing", e); -522 } -523 } -524 return false; -525 } -526 -527 /** @deprecated Unstable API */ @Deprecated @UnstableAPI -528 public CommandHelp getCommandHelp() { -529 return manager.generateCommandHelp(); -530 } -531 -532 /** @deprecated Unstable API */ @Deprecated @UnstableAPI -533 public void showCommandHelp() { -534 getCommandHelp().showHelp(); -535 } -536 -537 public void help(Object issuer, String[] args) { -538 help(manager.getCommandIssuer(issuer), args); -539 } -540 public void help(CommandIssuer issuer, String[] args) { -541 issuer.sendMessage(MessageType.ERROR, MessageKeys.UNKNOWN_COMMAND); -542 } -543 public void doHelp(Object issuer, String... args) { -544 doHelp(manager.getCommandIssuer(issuer), args); -545 } -546 public void doHelp(CommandIssuer issuer, String... args) { -547 help(issuer, args); -548 } -549 -550 public void showSyntax(CommandIssuer issuer, RegisteredCommand<?> cmd) { -551 issuer.sendMessage(MessageType.SYNTAX, MessageKeys.INVALID_SYNTAX, -552 "{command}", "/" + cmd.command, -553 "{syntax}", cmd.syntaxText -554 ); -555 } -556 -557 public boolean hasPermission(Object issuer) { -558 return hasPermission(manager.getCommandIssuer(issuer)); -559 } -560 -561 public boolean hasPermission(CommandIssuer issuer) { -562 return permission == null || permission.isEmpty() || (manager.hasPermission(issuer, permission) && (parentCommand == null || parentCommand.hasPermission(issuer))); -563 } -564 -565 public String getName() { -566 return commandName; -567 } -568 -569 public ExceptionHandler getExceptionHandler() { -570 return exceptionHandler; -571 } -572 -573 public BaseCommand setExceptionHandler(ExceptionHandler exceptionHandler) { -574 this.exceptionHandler = exceptionHandler; -575 return this; -576 } -577 -578 private static class CommandSearch { RegisteredCommand cmd; int argIndex; String checkSub; -579 -580 CommandSearch(RegisteredCommand cmd, int argIndex, String checkSub) { -581 this.cmd = cmd; -582 this.argIndex = argIndex; -583 this.checkSub = checkSub; -584 } -585 -586 String getCheckSub() { -587 return this.checkSub; -588 } -589 -590 @Override -591 public boolean equals(Object o) { -592 if (this == o) return true; -593 if (o == null || getClass() != o.getClass()) return false; -594 CommandSearch that = (CommandSearch) o; -595 return argIndex == that.argIndex && -596 Objects.equals(cmd, that.cmd) && -597 Objects.equals(checkSub, that.checkSub); -598 } -599 -600 @Override -601 public int hashCode() { -602 return Objects.hash(cmd, argIndex, checkSub); -603 } -604 } -605} +482 +483 private boolean executeSubcommand(CommandOperationContext commandContext, String subcommand, CommandIssuer issuer, String... args) { +484 final Set<RegisteredCommand> defs = subCommands.get(subcommand); +485 RegisteredCommand def = null; +486 if (!defs.isEmpty()) { +487 if (defs.size() == 1) { +488 def = defs.iterator().next(); +489 } +490 if (def != null) { +491 executeCommand(commandContext, issuer, args, def); +492 return true; +493 } +494 } +495 return false; +496 } +497 +498 private boolean checkPrecommand(CommandOperationContext commandOperationContext, RegisteredCommand cmd, CommandIssuer issuer, String[] args) { +499 Method pre = this.preCommandHandler; +500 if (pre != null) { +501 try { +502 Class<?>[] types = pre.getParameterTypes(); +503 Object[] parameters = new Object[pre.getParameterCount()]; +504 for (int i = 0; i < parameters.length; i++) { +505 Class<?> type = types[i]; +506 Object issuerObject = issuer.getIssuer(); +507 if (manager.isCommandIssuer(type) && type.isAssignableFrom(issuerObject.getClass())) { +508 parameters[i] = issuerObject; +509 } else if (CommandIssuer.class.isAssignableFrom(type)) { +510 parameters[i] = issuer; +511 } else if (RegisteredCommand.class.isAssignableFrom(type)) { +512 parameters[i] = cmd; +513 } else if (String[].class.isAssignableFrom((type))) { +514 parameters[i] = args; +515 } else { +516 parameters[i] = null; +517 } +518 } +519 +520 return (boolean) pre.invoke(this, parameters); +521 } catch (IllegalAccessException | InvocationTargetException e) { +522 this.manager.log(LogLevel.ERROR, "Exception encountered while command pre-processing", e); +523 } +524 } +525 return false; +526 } +527 +528 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +529 public CommandHelp getCommandHelp() { +530 return manager.generateCommandHelp(); +531 } +532 +533 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +534 public void showCommandHelp() { +535 getCommandHelp().showHelp(); +536 } +537 +538 public void help(Object issuer, String[] args) { +539 help(manager.getCommandIssuer(issuer), args); +540 } +541 public void help(CommandIssuer issuer, String[] args) { +542 issuer.sendMessage(MessageType.ERROR, MessageKeys.UNKNOWN_COMMAND); +543 } +544 public void doHelp(Object issuer, String... args) { +545 doHelp(manager.getCommandIssuer(issuer), args); +546 } +547 public void doHelp(CommandIssuer issuer, String... args) { +548 help(issuer, args); +549 } +550 +551 public void showSyntax(CommandIssuer issuer, RegisteredCommand<?> cmd) { +552 issuer.sendMessage(MessageType.SYNTAX, MessageKeys.INVALID_SYNTAX, +553 "{command}", "/" + cmd.command, +554 "{syntax}", cmd.syntaxText +555 ); +556 } +557 +558 public boolean hasPermission(Object issuer) { +559 return hasPermission(manager.getCommandIssuer(issuer)); +560 } +561 +562 public boolean hasPermission(CommandIssuer issuer) { +563 return permission == null || permission.isEmpty() || (manager.hasPermission(issuer, permission) && (parentCommand == null || parentCommand.hasPermission(issuer))); +564 } +565 +566 public String getName() { +567 return commandName; +568 } +569 +570 public ExceptionHandler getExceptionHandler() { +571 return exceptionHandler; +572 } +573 +574 public BaseCommand setExceptionHandler(ExceptionHandler exceptionHandler) { +575 this.exceptionHandler = exceptionHandler; +576 return this; +577 } +578 +579 private static class CommandSearch { RegisteredCommand cmd; int argIndex; String checkSub; +580 +581 CommandSearch(RegisteredCommand cmd, int argIndex, String checkSub) { +582 this.cmd = cmd; +583 this.argIndex = argIndex; +584 this.checkSub = checkSub; +585 } +586 +587 String getCheckSub() { +588 return this.checkSub; +589 } +590 +591 @Override +592 public boolean equals(Object o) { +593 if (this == o) return true; +594 if (o == null || getClass() != o.getClass()) return false; +595 CommandSearch that = (CommandSearch) o; +596 return argIndex == that.argIndex && +597 Objects.equals(cmd, that.cmd) && +598 Objects.equals(checkSub, that.checkSub); +599 } +600 +601 @Override +602 public int hashCode() { +603 return Objects.hash(cmd, argIndex, checkSub); +604 } +605 } +606}