/** * Please move to the CommandIssuer version * @deprecated */ public static Player findPlayerSmart(CommandSender requester, String search) { CommandManager manager = CommandManager.getCurrentCommandManager(); if (manager != null) { return findPlayerSmart(manager.getCommandIssuer(requester), search); } throw new IllegalStateException("You may not use the ACFBukkitUtil#findPlayerSmart(CommandSender) async to the command execution."); }
/** @deprecated Unstable API */ @Deprecated @UnstableAPI public CommandHelp generateCommandHelp() { verifyUnstableAPI("help"); CommandOperationContext context = getCurrentCommandOperationContext(); if (context == null) { throw new IllegalStateException("This method can only be called as part of a command execution."); } String commandLabel = context.getCommandLabel(); return generateCommandHelp(context.getCommandIssuer(), this.obtainRootCommand(commandLabel)); }
@Override protected boolean handleUncaughtException(BaseCommand scope, RegisteredCommand registeredCommand, CommandIssuer sender, List<String> args, Throwable t) { if (t instanceof CommandException && t.getCause() != null && t.getMessage().startsWith("Unhandled exception")) { t = t.getCause(); } return super.handleUncaughtException(scope, registeredCommand, sender, args, t); } }
public void sendMessage(IT issuerArg, MessageType type, MessageKeyProvider key, String... replacements) { sendMessage(getCommandIssuer(issuerArg), type, key, replacements); }
public Locale setIssuerLocale(IT issuer, Locale locale) { I commandIssuer = getCommandIssuer(issuer); Locale old = issuersLocale.put(commandIssuer.getUniqueId(), locale); if (!Objects.equals(old, locale)) { this.notifyLocaleChange(commandIssuer, old, locale); } return old; }
public void help(Object issuer, String[] args) { help(manager.getCommandIssuer(issuer), args); } public void help(CommandIssuer issuer, String[] args) {
/** @deprecated Unstable API */ @Deprecated @UnstableAPI public CommandHelp generateCommandHelp(@NotNull String command) { verifyUnstableAPI("help"); CommandOperationContext context = getCurrentCommandOperationContext(); if (context == null) { throw new IllegalStateException("This method can only be called as part of a command execution."); } return generateCommandHelp(context.getCommandIssuer(), command); }
CommandHelp commandHelp = manager.generateCommandHelp(); if (showHelp.search) { commandHelp.setSearch(showHelp.searchArgs == null ? args : showHelp.searchArgs); if (!this.manager.handleUncaughtException(scope, this, sender, args, e)) { sender.sendMessage(MessageType.ERROR, MessageKeys.ERROR_PERFORMING_COMMAND); this.manager.log(LogLevel.ERROR, "Exception in command: " + command + " " + ACFUtil.join(args), e); this.manager.log(LogLevel.ERROR, "Exception in handleException for command: " + command + " " + ACFUtil.join(args), e); this.manager.log(LogLevel.ERROR, "Exception triggered by exception handler:", e2);
Map<String, Object> passedArgs = new LinkedHashMap<>(); int remainingRequired = requiredResolvers; CommandOperationContext opContext = CommandManager.getCurrentCommandOperationContext(); for (int i = 0; i < parameters.length && i < argLimit; i++) { boolean isLast = i == parameters.length - 1; CEC context = (CEC) this.manager.createCommandContext(this, parameter, sender, args, i, passedArgs); boolean requiresInput = parameter.requiresInput(); if (requiresInput && remainingRequired > 0) { CommandCompletions commandCompletions = this.manager.getCommandCompletions(); for (String s : parameter.getValues()) {
private void validateConditions(String conditions, CommandOperationContext context) throws InvalidCommandArgument { if (conditions == null) { return; } conditions = this.manager.getCommandReplacements().replace(conditions); CommandIssuer issuer = context.getCommandIssuer(); for (String cond : ACFPatterns.PIPE.split(conditions)) { String[] split = ACFPatterns.COLON.split(cond, 2); String id = split[0].toLowerCase(); Condition<I> condition = this.conditions.get(id); if (condition == null) { RegisteredCommand cmd = context.getRegisteredCommand(); this.manager.log(LogLevel.ERROR, "Could not find command condition " + id + " for " + cmd.method.getName()); continue; } String config = split.length == 2 ? split[1] : null; //noinspection unchecked CC conditionContext = (CC) this.manager.createConditionContext(issuer, config); //noinspection unchecked condition.validateCondition(conditionContext); } }
/** * Gets the current command manager. * * @return The current command manager. */ public CommandManager getCurrentCommandManager() { return CommandManager.getCurrentCommandManager(); }
subCommand = manager.getCommandReplacements().replace(subCommand.toLowerCase()); final String[] subCommandParts = ACFPatterns.SPACE.split(subCommand); final String[] aliasNames = manager.getAnnotations().getAnnotationValues(method, CommandAlias.class, Annotations.REPLACEMENTS | Annotations.LOWERCASE); RegisteredCommand cmd = manager.createRegisteredCommand(this, cmdName, method, prefSubCommand);
@Override public void accept(CommandResult commandResult) { SpongeCommandOperationContext context = (SpongeCommandOperationContext) CommandManager.getCurrentCommandOperationContext(); context.setResult(commandResult); } }
List<String> getCompletionValues(RegisteredCommand command, CommandIssuer sender, String completion, String[] args, boolean isAsync) { completion = manager.getCommandReplacements().replace(completion); CommandCompletionContext context = manager.createCompletionContext(command, sender, input, config, args);
/** * This is ran before any command operation has been performed. * * @param issuer * The user who executed the command. * @param commandLabel * The label the user used to execute the command. This is not the command name, but their input. * When there is multiple aliases, this is which alias was used * @param args * The arguments passed to the command when executing it. * @param isAsync * Whether the command is executed off of the main thread. * * @return The context which is being registered to the {@link CommandManager}'s {@link * CommandManager#commandOperationContext thread local stack}. */ private CommandOperationContext preCommandOperation(CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) { Stack<CommandOperationContext> contexts = CommandManager.commandOperationContext.get(); CommandOperationContext context = this.manager.createCommandOperationContext(this, issuer, commandLabel, args, isAsync); contexts.push(context); lastCommandOperationContext = context; execSubcommand = null; execLabel = commandLabel; origArgs = args; return context; }
public void doHelp(Object issuer, String... args) { doHelp(manager.getCommandIssuer(issuer), args); } public void doHelp(CommandIssuer issuer, String... args) {
return; conditions = this.manager.getCommandReplacements().replace(conditions); I issuer = execContext.getIssuer(); for (String cond : ACFPatterns.PIPE.split(conditions)) { this.manager.log(LogLevel.ERROR, "Could not find command condition " + id + " for " + cmd.method.getName() + "::" +execContext.getParam().getName()); continue; CC conditionContext = (CC) this.manager.createConditionContext(issuer, config);
public boolean isAsync() { return CommandManager.getCurrentCommandOperationContext().isAsync(); } }
/** * Please move to the CommandIssuer version * @deprecated */ public static ProxiedPlayer findPlayerSmart(CommandSender requester, String search) { CommandManager manager = CommandManager.getCurrentCommandManager(); if (manager != null) { return findPlayerSmart(manager.getCommandIssuer(requester), search); } throw new IllegalStateException("You may not use the ACFBungeeUtil#findPlayerSmart(CommandSender) async to the command execution."); }
public boolean hasPermission(Object issuer) { return hasPermission(manager.getCommandIssuer(issuer)); }