ColorArgument.java
net.minecraft.commands.arguments.ColorArgument
信息
- 全限定名:net.minecraft.commands.arguments.ColorArgument
- 类型:public class
- 包:net.minecraft.commands.arguments
- 源码路径:src/main/java/net/minecraft/commands/arguments/ColorArgument.java
- 起始行号:L18
- 实现:ArgumentType
- 职责:
TODO
字段/常量
-
EXAMPLES- 类型:
Collection<String> - 修饰符:
private static final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
ERROR_INVALID_VALUE- 类型:
DynamicCommandExceptionType - 修饰符:
public static final - 源码定位:
L20 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private ColorArgument() @ L24
- 构造器名:ColorArgument
- 源码定位:L24
- 修饰符:private
参数:
- 无
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static ColorArgument color() @ L27
- 方法名:color
- 源码定位:L27
- 返回类型:ColorArgument
- 修饰符:public static
参数:
- 无
说明:
TODO
public static ChatFormatting getColor(CommandContext<CommandSourceStack> context, String name) @ L31
- 方法名:getColor
- 源码定位:L31
- 返回类型:ChatFormatting
- 修饰符:public static
参数:
- context: CommandContext
- name: String
说明:
TODO
public ChatFormatting parse(StringReader reader) @ L35
- 方法名:parse
- 源码定位:L35
- 返回类型:ChatFormatting
- 修饰符:public
参数:
- reader: StringReader
说明:
TODO
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> contextBuilder, SuggestionsBuilder builder) @ L45
- 方法名:listSuggestions
- 源码定位:L45
- 返回类型:
CompletableFuture - 修饰符:public
参数:
- contextBuilder: CommandContext
- builder: SuggestionsBuilder
说明:
TODO
public Collection<String> getExamples() @ L50
- 方法名:getExamples
- 源码定位:L50
- 返回类型:Collection
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public class ColorArgument implements ArgumentType<ChatFormatting> {
private static final Collection<String> EXAMPLES = Arrays.asList("red", "green");
public static final DynamicCommandExceptionType ERROR_INVALID_VALUE = new DynamicCommandExceptionType(
value -> Component.translatableEscape("argument.color.invalid", value)
);
private ColorArgument() {
}
public static ColorArgument color() {
return new ColorArgument();
}
public static ChatFormatting getColor(CommandContext<CommandSourceStack> context, String name) {
return context.getArgument(name, ChatFormatting.class);
}
public ChatFormatting parse(StringReader reader) throws CommandSyntaxException {
String id = reader.readUnquotedString();
ChatFormatting result = ChatFormatting.getByName(id);
if (result != null && !result.isFormat()) {
return result;
} else {
throw ERROR_INVALID_VALUE.createWithContext(reader, id);
}
}
@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> contextBuilder, SuggestionsBuilder builder) {
return SharedSuggestionProvider.suggest(ChatFormatting.getNames(true, false), builder);
}
@Override
public Collection<String> getExamples() {
return EXAMPLES;
}
}引用的其他类
-
- 引用位置:
实现/方法调用/返回值 - 关联成员:
ChatFormatting.getByName(), ChatFormatting.getNames()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SharedSuggestionProvider.suggest()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Component.translatableEscape()
- 引用位置: