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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
--- a/net/minecraft/server/commands/GameRuleCommand.java
+++ b/net/minecraft/server/commands/GameRuleCommand.java
@@ -4,39 +4,48 @@
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.commands.CommandSourceStack;
-import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.GameRules;
public class GameRuleCommand {
+
+ public GameRuleCommand() {}
+
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
- final LiteralArgumentBuilder<CommandSourceStack> literalArgumentBuilder = Commands.literal("gamerule").requires(source -> source.hasPermission(2));
- GameRules.visitGameRuleTypes(
- new GameRules.GameRuleTypeVisitor() {
- @Override
- public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) {
- literalArgumentBuilder.then(
- Commands.literal(key.getId())
- .executes(context -> GameRuleCommand.queryRule(context.getSource(), key))
- .then(type.createArgument("value").executes(context -> GameRuleCommand.setRule(context, key)))
- );
- }
+ final LiteralArgumentBuilder<CommandSourceStack> literalargumentbuilder = (LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("gamerule").requires((commandlistenerwrapper) -> {
+ return commandlistenerwrapper.hasPermission(2);
+ });
+
+ GameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor() {
+ @Override
+ public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) {
+ literalargumentbuilder.then(((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal(key.getId()).executes((commandcontext) -> {
+ return GameRuleCommand.queryRule((CommandSourceStack) commandcontext.getSource(), key);
+ })).then(type.createArgument("value").executes((commandcontext) -> {
+ return GameRuleCommand.setRule(commandcontext, key);
+ })));
}
- );
- dispatcher.register(literalArgumentBuilder);
+ });
+ dispatcher.register(literalargumentbuilder);
}
static <T extends GameRules.Value<T>> int setRule(CommandContext<CommandSourceStack> source, GameRules.Key<T> gameRule) {
- CommandSourceStack commandSourceStack = source.getSource();
- T rule = commandSourceStack.getServer().getGameRules().getRule(gameRule);
- rule.setFromArgument(source, "value");
- commandSourceStack.sendSuccess(() -> Component.translatable("commands.gamerule.set", gameRule.getId(), rule.toString()), true);
- return rule.getCommandResult();
+ CommandSourceStack commandlistenerwrapper = (CommandSourceStack) source.getSource();
+ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gameRule); // CraftBukkit
+
+ t0.setFromArgument(source, "value");
+ commandlistenerwrapper.sendSuccess(() -> {
+ return Component.translatable("commands.gamerule.set", gameRule.getId(), t0.toString());
+ }, true);
+ return t0.getCommandResult();
}
static <T extends GameRules.Value<T>> int queryRule(CommandSourceStack source, GameRules.Key<T> gameRule) {
- T rule = source.getServer().getGameRules().getRule(gameRule);
- source.sendSuccess(() -> Component.translatable("commands.gamerule.query", gameRule.getId(), rule.toString()), false);
- return rule.getCommandResult();
+ T t0 = source.getLevel().getGameRules().getRule(gameRule); // CraftBukkit
+
+ source.sendSuccess(() -> {
+ return Component.translatable("commands.gamerule.query", gameRule.getId(), t0.toString());
+ }, false);
+ return t0.getCommandResult();
}
}
|