SaveOffCommand.java
net.minecraft.server.commands.SaveOffCommand
信息
- 全限定名:net.minecraft.server.commands.SaveOffCommand
- 类型:public class
- 包:net.minecraft.server.commands
- 源码路径:src/main/java/net/minecraft/server/commands/SaveOffCommand.java
- 起始行号:L9
- 职责:
TODO
字段/常量
ERROR_ALREADY_OFF- 类型:
SimpleCommandExceptionType - 修饰符:
private static final - 源码定位:
L10 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) @ L12
- 方法名:register
- 源码定位:L12
- 返回类型:void
- 修饰符:public static
参数:
- dispatcher: CommandDispatcher
说明:
TODO
代码
public class SaveOffCommand {
private static final SimpleCommandExceptionType ERROR_ALREADY_OFF = new SimpleCommandExceptionType(Component.translatable("commands.save.alreadyOff"));
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
dispatcher.register(Commands.literal("save-off").requires(Commands.hasPermission(Commands.LEVEL_OWNERS)).executes(c -> {
CommandSourceStack source = c.getSource();
boolean success = source.getServer().setAutoSave(false);
if (!success) {
throw ERROR_ALREADY_OFF.create();
} else {
source.sendSuccess(() -> Component.translatable("commands.save.disabled"), true);
return 1;
}
}));
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Commands.hasPermission(), Commands.literal()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Component.translatable()
- 引用位置: