diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/commands/DifficultyCommand.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/server/commands/DifficultyCommand.java.patch | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/commands/DifficultyCommand.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/commands/DifficultyCommand.java.patch new file mode 100644 index 0000000000..2378c01fbe --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/server/commands/DifficultyCommand.java.patch @@ -0,0 +1,68 @@ +--- a/net/minecraft/server/commands/DifficultyCommand.java ++++ b/net/minecraft/server/commands/DifficultyCommand.java +@@ -5,7 +5,6 @@ + import com.mojang.brigadier.exceptions.CommandSyntaxException; + import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; + import net.minecraft.commands.CommandSourceStack; +-import net.minecraft.commands.Commands; + import net.minecraft.network.chat.Component; + import net.minecraft.server.MinecraftServer; + import net.minecraft.world.Difficulty; +@@ -18,39 +17,40 @@ + + public DifficultyCommand() {} + +- public static void register(CommandDispatcher<CommandSourceStack> commanddispatcher) { +- LiteralArgumentBuilder<CommandSourceStack> literalargumentbuilder = Commands.literal("difficulty"); +- Difficulty[] adifficulty = Difficulty.values(); +- int i = adifficulty.length; ++ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) { ++ LiteralArgumentBuilder<CommandSourceStack> literalargumentbuilder = net.minecraft.commands.Commands.literal("difficulty"); ++ Difficulty[] aenumdifficulty = Difficulty.values(); ++ int i = aenumdifficulty.length; + + for (int j = 0; j < i; ++j) { +- Difficulty difficulty = adifficulty[j]; ++ Difficulty enumdifficulty = aenumdifficulty[j]; + +- literalargumentbuilder.then(Commands.literal(difficulty.getKey()).executes((commandcontext) -> { +- return setDifficulty((CommandSourceStack) commandcontext.getSource(), difficulty); ++ literalargumentbuilder.then(net.minecraft.commands.Commands.literal(enumdifficulty.getKey()).executes((commandcontext) -> { ++ return setDifficulty((CommandSourceStack) commandcontext.getSource(), enumdifficulty); + })); + } + +- commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) literalargumentbuilder.requires((commandsourcestack) -> { +- return commandsourcestack.hasPermission(2); ++ dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) literalargumentbuilder.requires((commandlistenerwrapper) -> { ++ return commandlistenerwrapper.hasPermission(2); + })).executes((commandcontext) -> { +- Difficulty difficulty1 = ((CommandSourceStack) commandcontext.getSource()).getLevel().getDifficulty(); ++ Difficulty enumdifficulty1 = ((CommandSourceStack) commandcontext.getSource()).getLevel().getDifficulty(); + + ((CommandSourceStack) commandcontext.getSource()).sendSuccess(() -> { +- return Component.translatable("commands.difficulty.query", difficulty1.getDisplayName()); ++ return Component.translatable("commands.difficulty.query", enumdifficulty1.getDisplayName()); + }, false); +- return difficulty1.getId(); ++ return enumdifficulty1.getId(); + })); + } + +- public static int setDifficulty(CommandSourceStack commandsourcestack, Difficulty difficulty) throws CommandSyntaxException { +- MinecraftServer minecraftserver = commandsourcestack.getServer(); ++ public static int setDifficulty(CommandSourceStack source, Difficulty difficulty) throws CommandSyntaxException { ++ MinecraftServer minecraftserver = source.getServer(); ++ net.minecraft.server.level.ServerLevel worldServer = source.getLevel(); // CraftBukkit + +- if (minecraftserver.getWorldData().getDifficulty() == difficulty) { ++ if (worldServer.getDifficulty() == difficulty) { // CraftBukkit + throw DifficultyCommand.ERROR_ALREADY_DIFFICULT.create(difficulty.getKey()); + } else { +- minecraftserver.setDifficulty(difficulty, true); +- commandsourcestack.sendSuccess(() -> { ++ worldServer.serverLevelData.setDifficulty(difficulty); // CraftBukkit ++ source.sendSuccess(() -> { + return Component.translatable("commands.difficulty.success", difficulty.getDisplayName()); + }, true); + return 0; |