SetPlayerIdleTimeoutCommand .java

net.minecraft.server.commands.SetPlayerIdleTimeoutCommand (class): members: register. strings: "commands.setidletimeout.success.disabled", "minutes".

net.minecraft.server.commandsclass31 linesserver1.1 KB

API Surface (1)

void register(final CommandDispatcher<CommandSourceStack> dispatcher)

String literals (4)

"setidletimeout"
"minutes"
"commands.setidletimeout.success"
"commands.setidletimeout.success.disabled"

Code Graph: Dependencies (3)

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

Full Source

SetPlayerIdleTimeoutCommand.java31 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.commands;
2
3
import com.mojang.brigadier.CommandDispatcher;
4
import com.mojang.brigadier.arguments.IntegerArgumentType;
5
import net.minecraft.commands.CommandSourceStack;
6
import net.minecraft.commands.Commands;
7
import net.minecraft.network.chat.Component;
8
9
public class SetPlayerIdleTimeoutCommand {
10
	public static void register(final CommandDispatcher<CommandSourceStack> dispatcher) {
11
		dispatcher.register(
12
			Commands.literal("setidletimeout")
13
				.requires(Commands.hasPermission(Commands.LEVEL_ADMINS))
14
				.then(
15
					Commands.argument("minutes", IntegerArgumentType.integer(0)).executes(c -> setIdleTimeout(c.getSource(), IntegerArgumentType.getInteger(c, "minutes")))
16
				)
17
		);
18
	}
19
20
	private static int setIdleTimeout(final CommandSourceStack source, final int time) {
21
		source.getServer().setPlayerIdleTimeout(time);
22
		if (time > 0) {
23
			source.sendSuccess(() -> Component.translatable("commands.setidletimeout.success", time), true);
24
		} else {
25
			source.sendSuccess(() -> Component.translatable("commands.setidletimeout.success.disabled"), true);
26
		}
27
28
		return time;
29
	}
30
}
31

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