-
Notifications
You must be signed in to change notification settings - Fork 0
/
AHServerCommands.java
57 lines (48 loc) · 2.03 KB
/
AHServerCommands.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package org.auioc.mcmod.arnicalib.server.command;
import static net.minecraft.commands.Commands.literal;
import java.util.List;
import org.auioc.mcmod.arnicalib.ArnicaLib;
import org.auioc.mcmod.arnicalib.common.command.impl.VersionCommand;
import org.auioc.mcmod.arnicalib.server.command.impl.RtpCommand;
import org.auioc.mcmod.arnicalib.utils.game.EnvironmentUtils;
import org.auioc.mcmod.arnicalib.utils.game.command.DynamicCommandHandler;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.tree.CommandNode;
import net.minecraft.commands.CommandSourceStack;
public final class AHServerCommands {
public static final CommandNode<CommandSourceStack> NODE = literal(ArnicaLib.MOD_ID).build();
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
VersionCommand.addVersionNode(NODE, ArnicaLib.class);
NODE.addChild(RtpCommand.NODE);
if (EnvironmentUtils.IS_DEV) addTestNode(NODE);
getAHNode(dispatcher).addChild(NODE);
}
public static CommandNode<CommandSourceStack> getAHNode(CommandDispatcher<CommandSourceStack> dispatcher) {
CommandNode<CommandSourceStack> node = dispatcher.findNode(List.of("ah"));
if (node == null) {
node = dispatcher.register(literal("ah"));
}
return node;
}
/**
* @since 4.1.0
* @deprecated Use {@link #getAHNode} instead
*/
@Deprecated(since = "5.1.3", forRemoval = true)
public static CommandNode<CommandSourceStack> getRootNode(CommandDispatcher<CommandSourceStack> dispatcher) {
return getAHNode(dispatcher);
}
private static void addTestNode(CommandNode<CommandSourceStack> node) {
node.addChild(
literal("test")
.executes(
(ctx) -> DynamicCommandHandler.run(
"org.auioc.mcmod.arnicalib.server.command.TestCommandHandler",
"run",
ctx
)
)
.build()
);
}
}