SaveOffCommand .java

net.minecraft.server.commands.SaveOffCommand (class, 25 lines): members: ERROR_ALREADY_OFF, register. strings: "commands.save.alreadyOff", "save-off".

net.minecraft.server.commandsclass25 linesserver963 B

API Surface (1)

void register(final CommandDispatcher<CommandSourceStack> dispatcher)

Fields & Constants (1)

ERROR_ALREADY_OFF

String literals (3)

"commands.save.alreadyOff"
"save-off"
"commands.save.disabled"

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

SaveOffCommand.java25 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.commands;
2
3
import com.mojang.brigadier.CommandDispatcher;
4
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
5
import net.minecraft.commands.CommandSourceStack;
6
import net.minecraft.commands.Commands;
7
import net.minecraft.network.chat.Component;
8
9
public class SaveOffCommand {
10
	private static final SimpleCommandExceptionType ERROR_ALREADY_OFF = new SimpleCommandExceptionType(Component.translatable("commands.save.alreadyOff"));
11
12
	public static void register(final CommandDispatcher<CommandSourceStack> dispatcher) {
13
		dispatcher.register(Commands.literal("save-off").requires(Commands.hasPermission(Commands.LEVEL_OWNERS)).executes(c -> {
14
			CommandSourceStack source = c.getSource();
15
			boolean success = source.getServer().setAutoSave(false);
16
			if (!success) {
17
				throw ERROR_ALREADY_OFF.create();
18
			}
19
20
			source.sendSuccess(() -> Component.translatable("commands.save.disabled"), true);
21
			return 1;
22
		}));
23
	}
24
}
25

Decompiled Minecraft 26.3 source of SaveOffCommand (net/minecraft/server/commands/SaveOffCommand.java) with Mojang official mappings, stored verbatim on the site.