User Tools

Site Tools


zh_cn:tutorial:command_argument_types

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
zh_cn:tutorial:command_argument_types [2023/04/20 11:06] solidblockzh_cn:tutorial:command_argument_types [2023/04/20 11:11] – fix type solidblock
Line 42: Line 42:
 <code java [enable_line_numbers="true"]>String uuidString = reader.getString().substring(argBeginning, reader.getCursor());</code> <code java [enable_line_numbers="true"]>String uuidString = reader.getString().substring(argBeginning, reader.getCursor());</code>
  
-最终,我们检我们的参数是否正确,并解析我们的参数,如果解析失败则抛出异常。+最终,我们检我们的参数是否正确,并解析我们的参数,如果解析失败则抛出异常。
  
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
Line 73: Line 73:
 import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
 import net.minecraft.text.Text; import net.minecraft.text.Text;
-import net.minecraft.util.SystemUtil; 
  
 import java.util.ArrayList; import java.util.ArrayList;
Line 89: Line 88:
     public static <S> UUID getUuid(String name, CommandContext<S> context) {     public static <S> UUID getUuid(String name, CommandContext<S> context) {
         // 注意你应该假设 CommandContext 中包含的 CommandSource 是一个泛型类型。         // 注意你应该假设 CommandContext 中包含的 CommandSource 是一个泛型类型。
-        // 如果你需要访问 ServerCommandSource,确保你在强转之前验证了源。+        // 如果你需要访问 ServerCommandSource,确保你在强转之前验证了命令源。
         return context.getArgument(name, UUID.class);         return context.getArgument(name, UUID.class);
     }     }
  
-    private static final Collection<String> EXAMPLES = SystemUtil.consume(new ArrayList<>(), list -> { +    private static final Collection<String> EXAMPLES = List.of
-        list.add("765e5d33-c991-454f-8775-b6a7a394c097"); // i509VCB: 用户名 The_1_gamers +        "765e5d33-c991-454f-8775-b6a7a394c097"// i509VCB: 用户名 The_1_gamers 
-        list.add("069a79f4-44e9-4726-a5be-fca90e38aaf5"); // Notch +        "069a79f4-44e9-4726-a5be-fca90e38aaf5"// Notch 
-        list.add("61699b2e-d327-4a01-9f1e-0ea8c3f06bc6"); // Dinnerbone +        "61699b2e-d327-4a01-9f1e-0ea8c3f06bc6"  // Dinnerbone 
-    });+    );
  
     @Override     @Override
zh_cn/tutorial/command_argument_types.txt · Last modified: 2024/04/15 07:24 by solidblock