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
|
--- 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;
|