TellRawCommand.java

net.minecraft.server.commands.TellRawCommand

信息

  • 全限定名:net.minecraft.server.commands.TellRawCommand
  • 类型:public class
  • 包:net.minecraft.server.commands
  • 源码路径:src/main/java/net/minecraft/server/commands/TellRawCommand.java
  • 起始行号:L11
  • 职责:

    TODO

字段/常量

内部类/嵌套类型

构造器

方法

下面的方法块按源码顺序生成。

public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context) @ L12

  • 方法名:register
  • 源码定位:L12
  • 返回类型:void
  • 修饰符:public static

参数:

  • dispatcher: CommandDispatcher
  • context: CommandBuildContext

说明:

TODO

代码

public class TellRawCommand {
    public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context) {
        dispatcher.register(
            Commands.literal("tellraw")
                .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS))
                .then(
                    Commands.argument("targets", EntityArgument.players())
                        .then(Commands.argument("message", ComponentArgument.textComponent(context)).executes(c -> {
                            int result = 0;
 
                            for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
                                player.sendSystemMessage(ComponentArgument.getResolvedComponent(c, "message", player));
                                result++;
                            }
 
                            return result;
                        }))
                )
        );
    }
}

引用的其他类

  • CommandBuildContext

    • 引用位置: 参数
  • CommandSourceStack

    • 引用位置: 参数
  • Commands

    • 引用位置: 方法调用
    • 关联成员: Commands.argument(), Commands.hasPermission(), Commands.literal()
  • ComponentArgument

    • 引用位置: 方法调用
    • 关联成员: ComponentArgument.getResolvedComponent(), ComponentArgument.textComponent()
  • EntityArgument

    • 引用位置: 方法调用
    • 关联成员: EntityArgument.getPlayers(), EntityArgument.players()