diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/commands/GameRuleCommand.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/server/commands/GameRuleCommand.java.patch | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/commands/GameRuleCommand.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/commands/GameRuleCommand.java.patch new file mode 100644 index 0000000000..c19f6d9203 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/server/commands/GameRuleCommand.java.patch @@ -0,0 +1,71 @@ +--- a/net/minecraft/server/commands/GameRuleCommand.java ++++ b/net/minecraft/server/commands/GameRuleCommand.java +@@ -4,7 +4,6 @@ + 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; + +@@ -12,41 +11,40 @@ + + public GameRuleCommand() {} + +- public static void register(CommandDispatcher<CommandSourceStack> commanddispatcher) { +- final LiteralArgumentBuilder<CommandSourceStack> literalargumentbuilder = (LiteralArgumentBuilder) Commands.literal("gamerule").requires((commandsourcestack) -> { +- return commandsourcestack.hasPermission(2); ++ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) { ++ final LiteralArgumentBuilder<CommandSourceStack> literalargumentbuilder = (LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("gamerule").requires((commandlistenerwrapper) -> { ++ return commandlistenerwrapper.hasPermission(2); + }); + + GameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor() { + @Override +- @Override +- public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> gamerules_key, GameRules.Type<T> gamerules_type) { +- literalargumentbuilder.then(((LiteralArgumentBuilder) Commands.literal(gamerules_key.getId()).executes((commandcontext) -> { +- return GameRuleCommand.queryRule((CommandSourceStack) commandcontext.getSource(), gamerules_key); +- })).then(gamerules_type.createArgument("value").executes((commandcontext) -> { +- return GameRuleCommand.setRule(commandcontext, gamerules_key); ++ 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); + }))); + } + }); +- commanddispatcher.register(literalargumentbuilder); ++ dispatcher.register(literalargumentbuilder); + } + +- static <T extends GameRules.Value<T>> int setRule(CommandContext<CommandSourceStack> commandcontext, GameRules.Key<T> gamerules_key) { +- CommandSourceStack commandsourcestack = (CommandSourceStack) commandcontext.getSource(); +- T t0 = commandsourcestack.getServer().getGameRules().getRule(gamerules_key); ++ static <T extends GameRules.Value<T>> int setRule(CommandContext<CommandSourceStack> source, GameRules.Key<T> gameRule) { ++ CommandSourceStack commandlistenerwrapper = (CommandSourceStack) source.getSource(); ++ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gameRule); // CraftBukkit + +- t0.setFromArgument(commandcontext, "value"); +- commandsourcestack.sendSuccess(() -> { +- return Component.translatable("commands.gamerule.set", gamerules_key.getId(), t0.toString()); ++ 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 commandsourcestack, GameRules.Key<T> gamerules_key) { +- T t0 = commandsourcestack.getServer().getGameRules().getRule(gamerules_key); ++ static <T extends GameRules.Value<T>> int queryRule(CommandSourceStack source, GameRules.Key<T> gameRule) { ++ T t0 = source.getLevel().getGameRules().getRule(gameRule); // CraftBukkit + +- commandsourcestack.sendSuccess(() -> { +- return Component.translatable("commands.gamerule.query", gamerules_key.getId(), t0.toString()); ++ source.sendSuccess(() -> { ++ return Component.translatable("commands.gamerule.query", gameRule.getId(), t0.toString()); + }, false); + return t0.getCommandResult(); + } |