ObjectiveCriteriaArgument.java
net.minecraft.commands.arguments.ObjectiveCriteriaArgument
信息
- 全限定名:net.minecraft.commands.arguments.ObjectiveCriteriaArgument
- 类型:public class
- 包:net.minecraft.commands.arguments
- 源码路径:src/main/java/net/minecraft/commands/arguments/ObjectiveCriteriaArgument.java
- 起始行号:L23
- 实现:ArgumentType
- 职责:
TODO
字段/常量
-
EXAMPLES- 类型:
Collection<String> - 修饰符:
private static final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
ERROR_INVALID_VALUE- 类型:
DynamicCommandExceptionType - 修饰符:
public static final - 源码定位:
L25 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private ObjectiveCriteriaArgument() @ L29
- 构造器名:ObjectiveCriteriaArgument
- 源码定位:L29
- 修饰符:private
参数:
- 无
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static ObjectiveCriteriaArgument criteria() @ L32
- 方法名:criteria
- 源码定位:L32
- 返回类型:ObjectiveCriteriaArgument
- 修饰符:public static
参数:
- 无
说明:
TODO
public static ObjectiveCriteria getCriteria(CommandContext<CommandSourceStack> context, String name) @ L36
- 方法名:getCriteria
- 源码定位:L36
- 返回类型:ObjectiveCriteria
- 修饰符:public static
参数:
- context: CommandContext
- name: String
说明:
TODO
public ObjectiveCriteria parse(StringReader reader) @ L40
- 方法名:parse
- 源码定位:L40
- 返回类型:ObjectiveCriteria
- 修饰符:public
参数:
- reader: StringReader
说明:
TODO
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) @ L54
- 方法名:listSuggestions
- 源码定位:L54
- 返回类型:
CompletableFuture - 修饰符:public
参数:
- context: CommandContext
- builder: SuggestionsBuilder
说明:
TODO
public <T> String getName(StatType<T> type, Object value) @ L68
- 方法名:getName
- 源码定位:L68
- 返回类型:
String - 修饰符:public
参数:
- type: StatType
- value: Object
说明:
TODO
public Collection<String> getExamples() @ L72
- 方法名:getExamples
- 源码定位:L72
- 返回类型:Collection
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public class ObjectiveCriteriaArgument implements ArgumentType<ObjectiveCriteria> {
private static final Collection<String> EXAMPLES = Arrays.asList("foo", "foo.bar.baz", "minecraft:foo");
public static final DynamicCommandExceptionType ERROR_INVALID_VALUE = new DynamicCommandExceptionType(
value -> Component.translatableEscape("argument.criteria.invalid", value)
);
private ObjectiveCriteriaArgument() {
}
public static ObjectiveCriteriaArgument criteria() {
return new ObjectiveCriteriaArgument();
}
public static ObjectiveCriteria getCriteria(CommandContext<CommandSourceStack> context, String name) {
return context.getArgument(name, ObjectiveCriteria.class);
}
public ObjectiveCriteria parse(StringReader reader) throws CommandSyntaxException {
int start = reader.getCursor();
while (reader.canRead() && reader.peek() != ' ') {
reader.skip();
}
String id = reader.getString().substring(start, reader.getCursor());
return ObjectiveCriteria.byName(id).orElseThrow(() -> {
reader.setCursor(start);
return ERROR_INVALID_VALUE.createWithContext(reader, id);
});
}
@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
List<String> ids = Lists.newArrayList(ObjectiveCriteria.getCustomCriteriaNames());
for (StatType<?> type : BuiltInRegistries.STAT_TYPE) {
for (Object value : type.getRegistry()) {
String name = this.getName(type, value);
ids.add(name);
}
}
return SharedSuggestionProvider.suggest(ids, builder);
}
public <T> String getName(StatType<T> type, Object value) {
return Stat.buildName(type, (T)value);
}
@Override
public Collection<String> getExamples() {
return EXAMPLES;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SharedSuggestionProvider.suggest()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Component.translatableEscape()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Stat.buildName()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
实现/方法调用/返回值 - 关联成员:
ObjectiveCriteria.byName(), ObjectiveCriteria.getCustomCriteriaNames()
- 引用位置: