UnpublishCommand .java

net.minecraft.server.commands.UnpublishCommand (class): members: ERROR_NOT_PUBLISHED, register. strings: "commands.unpublish.notPublished", "unpublish".

net.minecraft.server.commandsclass26 linesserver1.1 KB

API Surface (1)

void register(final CommandDispatcher<CommandSourceStack> dispatcher)

Fields & Constants (1)

ERROR_NOT_PUBLISHED

String literals (3)

"commands.unpublish.notPublished"
"unpublish"
"commands.unpublish.success"

Code Graph: Dependencies (3)

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

Full Source

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

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