DebugConfigCommand.java
net.minecraft.server.commands.DebugConfigCommand
信息
- 全限定名:net.minecraft.server.commands.DebugConfigCommand
- 类型:public class
- 包:net.minecraft.server.commands
- 源码路径:src/main/java/net/minecraft/server/commands/DebugConfigCommand.java
- 起始行号:L25
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context) @ L26
- 方法名:register
- 源码定位:L26
- 返回类型:void
- 修饰符:public static
参数:
- dispatcher: CommandDispatcher
- context: CommandBuildContext
说明:
TODO
private static Iterable<String> getUuidsInConfig(MinecraftServer server) @ L62
- 方法名:getUuidsInConfig
- 源码定位:L62
- 返回类型:Iterable
- 修饰符:private static
参数:
- server: MinecraftServer
说明:
TODO
private static int config(CommandSourceStack source, ServerPlayer target) @ L74
- 方法名:config
- 源码定位:L74
- 返回类型:int
- 修饰符:private static
参数:
- source: CommandSourceStack
- target: ServerPlayer
说明:
TODO
private static ServerConfigurationPacketListenerImpl findConfigPlayer(MinecraftServer server, UUID target) @ L81
- 方法名:findConfigPlayer
- 源码定位:L81
- 返回类型:ServerConfigurationPacketListenerImpl
- 修饰符:private static
参数:
- server: MinecraftServer
- target: UUID
说明:
TODO
private static int unconfig(CommandSourceStack source, UUID target) @ L93
- 方法名:unconfig
- 源码定位:L93
- 返回类型:int
- 修饰符:private static
参数:
- source: CommandSourceStack
- target: UUID
说明:
TODO
private static int showDialog(CommandSourceStack source, UUID target, Holder<Dialog> dialog) @ L104
- 方法名:showDialog
- 源码定位:L104
- 返回类型:int
- 修饰符:private static
参数:
- source: CommandSourceStack
- target: UUID
- dialog: Holder
说明:
TODO
代码
public class DebugConfigCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context) {
dispatcher.register(
Commands.literal("debugconfig")
.requires(Commands.hasPermission(Commands.LEVEL_ADMINS))
.then(
Commands.literal("config")
.then(Commands.argument("target", EntityArgument.player()).executes(c -> config(c.getSource(), EntityArgument.getPlayer(c, "target"))))
)
.then(
Commands.literal("unconfig")
.then(
Commands.argument("target", UuidArgument.uuid())
.suggests((c, p) -> SharedSuggestionProvider.suggest(getUuidsInConfig(c.getSource().getServer()), p))
.executes(c -> unconfig(c.getSource(), UuidArgument.getUuid(c, "target")))
)
)
.then(
Commands.literal("dialog")
.then(
Commands.argument("target", UuidArgument.uuid())
.suggests((c, p) -> SharedSuggestionProvider.suggest(getUuidsInConfig(c.getSource().getServer()), p))
.then(
Commands.argument("dialog", ResourceOrIdArgument.dialog(context))
.executes(
c -> showDialog(
(CommandSourceStack)c.getSource(),
UuidArgument.getUuid(c, "target"),
ResourceOrIdArgument.getDialog(c, "dialog")
)
)
)
)
)
);
}
private static Iterable<String> getUuidsInConfig(MinecraftServer server) {
Set<String> result = new HashSet<>();
for (Connection connection : server.getConnection().getConnections()) {
if (connection.getPacketListener() instanceof ServerConfigurationPacketListenerImpl configListener) {
result.add(configListener.getOwner().id().toString());
}
}
return result;
}
private static int config(CommandSourceStack source, ServerPlayer target) {
GameProfile gameProfile = target.getGameProfile();
target.connection.switchToConfig();
source.sendSuccess(() -> Component.literal("Switched player " + gameProfile.name() + "(" + gameProfile.id() + ") to config mode"), false);
return 1;
}
private static @Nullable ServerConfigurationPacketListenerImpl findConfigPlayer(MinecraftServer server, UUID target) {
for (Connection connection : server.getConnection().getConnections()) {
if (connection.getPacketListener() instanceof ServerConfigurationPacketListenerImpl configListener && configListener.getOwner().id().equals(target)
)
{
return configListener;
}
}
return null;
}
private static int unconfig(CommandSourceStack source, UUID target) {
ServerConfigurationPacketListenerImpl listener = findConfigPlayer(source.getServer(), target);
if (listener != null) {
listener.returnToWorld();
return 1;
} else {
source.sendFailure(Component.literal("Can't find player to unconfig"));
return 0;
}
}
private static int showDialog(CommandSourceStack source, UUID target, Holder<Dialog> dialog) {
ServerConfigurationPacketListenerImpl listener = findConfigPlayer(source.getServer(), target);
if (listener != null) {
listener.send(new ClientboundShowDialogPacket(dialog));
return 1;
} else {
source.sendFailure(Component.literal("Can't find player to talk to"));
return 0;
}
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Commands.argument(), Commands.hasPermission(), Commands.literal()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SharedSuggestionProvider.suggest()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
EntityArgument.getPlayer(), EntityArgument.player()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ResourceOrIdArgument.dialog(), ResourceOrIdArgument.getDialog()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
UuidArgument.getUuid(), UuidArgument.uuid()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Component.literal()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
ClientboundShowDialogPacket()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
ServerConfigurationPacketListenerImpl
- 引用位置:
返回值
- 引用位置: