当前位置: 首页>>代码示例>>Java>>正文


Java CommandArgs.setState方法代码示例

本文整理汇总了Java中org.spongepowered.api.command.args.CommandArgs.setState方法的典型用法代码示例。如果您正苦于以下问题:Java CommandArgs.setState方法的具体用法?Java CommandArgs.setState怎么用?Java CommandArgs.setState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.command.args.CommandArgs的用法示例。


在下文中一共展示了CommandArgs.setState方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseValue

import org.spongepowered.api.command.args.CommandArgs; //导入方法依赖的package包/类
@Nullable
@Override
protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
    UUID id;

    final SourcePaginations paginations = getPaginationState(source, false);
    if (paginations == null) {
        throw args.createError(t("Source %s has no paginations!", source.getName()));
    }

    Object state = args.getState();
    try {
        id = UUID.fromString(args.next());
    } catch (IllegalArgumentException ex) {
        if (paginations.getLastUuid() != null) {
            args.setState(state);
            return paginations.get(paginations.getLastUuid());
        }
        throw args.createError(t("Input was not a valid UUID!"));
    }
    final ActivePagination pagination = paginations.get(id);
    if (pagination == null) {
        throw args.createError(t("No pagination registered for id %s", id.toString()));
    }
    return paginations.get(id);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:27,代码来源:LanternPaginationService.java

示例2: complete

import org.spongepowered.api.command.args.CommandArgs; //导入方法依赖的package包/类
@Nonnull
@Override
public List<String> complete(
        @Nonnull CommandSource src, CommandArgs args, CommandContext context) {
    Object state = args.getState();
    final Optional<String> nextArg = args.nextIfPresent();
    args.setState(state);
    List<String> choices = nextArg.map(Selector::complete).orElseGet(ImmutableList::of);

    if (choices.isEmpty()) {
        choices = super.complete(src, args, context);
    }

    if (choices.size() == 1) {
        currentSurvivalGame = choices.get(0);
    } else {
        currentSurvivalGame = null;
    }

    return choices;
}
 
开发者ID:m0pt0pmatt,项目名称:SurvivalGames,代码行数:22,代码来源:SurvivalGameCommandElement.java

示例3: parse

import org.spongepowered.api.command.args.CommandArgs; //导入方法依赖的package包/类
@Override
public void parse(CommandSource source, CommandArgs args, CommandContext context) throws ArgumentParseException {
    if (!args.hasNext()) {
        return;
    }
    Object startState = args.getState();
    try {
        this.element.parse(source, args, context);
    } catch (ArgumentParseException ex) {
        if (args.hasNext()) { // If there are more args, suppress. Otherwise, throw the error
            args.setState(startState);
        } else {
            throw ex;
        }
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:17,代码来源:WeakOptionalWrapper.java

示例4: parse

import org.spongepowered.api.command.args.CommandArgs; //导入方法依赖的package包/类
public void parse(CommandSource source, CommandArgs args, CommandContext context) throws ArgumentParseException {
    ArgumentParseException lastException = null;
    for (CommandElement element : this.elements) {
        Object startState = args.getState();
        try {
            element.parse(source, args, context);
            return;
        } catch (ArgumentParseException ex) {
            lastException = ex;
            args.setState(startState);
        }
    }
    if (lastException != null) {
        throw lastException;
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:17,代码来源:FirstParsingWrapper.java

示例5: complete

import org.spongepowered.api.command.args.CommandArgs; //导入方法依赖的package包/类
@Override
public List<String> complete(CommandSource src, CommandArgs args, CommandContext context, Completer original) {
    Object state = args.getState();
    final List<String> completions = original.complete(src, args, context);
    // Why are there empty entries in the list?
    if (!completions.isEmpty() && completions.size() != 1 && !completions.get(0).isEmpty()) {
        return completions;
    }
    args.setState(state);
    if (!args.nextIfPresent().isPresent()) {
        return Collections.emptyList();
    }
    if (args.nextIfPresent().isPresent()) {
        if (args.nextIfPresent().isPresent()) {
            // Store the current state
            state = args.getState();
            if (args.nextIfPresent().isPresent()) {
                // We finished the vector3d, reset before the last arg
                args.setState(state);
                Lantern.getLogger().warn("Attempted to complete to many args, vector3d has only 3 components.");
            } else {
                // The z is being completed
                return this.completeZ(src, context);
            }
        } else {
            // The y is being completed
            return this.completeY(src, context);
        }
    } else {
        // The x is being completed
        return this.completeX(src, context);
    }
    return Collections.emptyList();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:35,代码来源:GenericArguments2.java

示例6: parseValue

import org.spongepowered.api.command.args.CommandArgs; //导入方法依赖的package包/类
@Nullable
public Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
    ArgumentParseException lastException = null;
    for (UCommandElement element : this.elements) {
        Object startState = args.getState();
        try {
            Object rtrn = element.parseValue(source, args);
            return rtrn;
        } catch (ArgumentParseException ex) {
            lastException = ex;
            args.setState(startState);
        }
    }
    throw lastException;
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:16,代码来源:FirstParsingWrapper.java


注:本文中的org.spongepowered.api.command.args.CommandArgs.setState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。