本文整理汇总了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);
}
示例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;
}
示例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;
}
}
}
示例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;
}
}
示例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();
}
示例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;
}