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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
--- a/net/minecraft/server/commands/ReloadCommand.java
+++ b/net/minecraft/server/commands/ReloadCommand.java
@@ -2,11 +2,11 @@
import com.google.common.collect.Lists;
import com.mojang.brigadier.CommandDispatcher;
-import com.mojang.brigadier.context.CommandContext;
+import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.logging.LogUtils;
import java.util.Collection;
+import java.util.Iterator;
import net.minecraft.commands.CommandSourceStack;
-import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.packs.repository.PackRepository;
@@ -14,11 +14,14 @@
import org.slf4j.Logger;
public class ReloadCommand {
+
private static final Logger LOGGER = LogUtils.getLogger();
+ public ReloadCommand() {}
+
public static void reloadPacks(Collection<String> selectedIds, CommandSourceStack source) {
- source.getServer().reloadResources(selectedIds).exceptionally(throwable -> {
- LOGGER.warn("Failed to execute reload", throwable);
+ source.getServer().reloadResources(selectedIds).exceptionally((throwable) -> {
+ ReloadCommand.LOGGER.warn("Failed to execute reload", throwable);
source.sendFailure(Component.translatable("commands.reload.failure"));
return null;
});
@@ -26,28 +29,46 @@
private static Collection<String> discoverNewPacks(PackRepository packRepository, WorldData worldData, Collection<String> selectedIds) {
packRepository.reload();
- Collection<String> list = Lists.newArrayList(selectedIds);
- Collection<String> disabled = worldData.getDataConfiguration().dataPacks().getDisabled();
+ Collection<String> collection1 = Lists.newArrayList(selectedIds);
+ Collection<String> collection2 = worldData.getDataConfiguration().dataPacks().getDisabled();
+ Iterator iterator = packRepository.getAvailableIds().iterator();
- for (String string : packRepository.getAvailableIds()) {
- if (!disabled.contains(string) && !list.contains(string)) {
- list.add(string);
+ while (iterator.hasNext()) {
+ String s = (String) iterator.next();
+
+ if (!collection2.contains(s) && !collection1.contains(s)) {
+ collection1.add(s);
}
}
- return list;
+ return collection1;
}
+ // CraftBukkit start
+ public static void reload(MinecraftServer minecraftserver) {
+ PackRepository resourcepackrepository = minecraftserver.getPackRepository();
+ WorldData savedata = minecraftserver.getWorldData();
+ Collection<String> collection = resourcepackrepository.getSelectedIds();
+ Collection<String> collection1 = discoverNewPacks(resourcepackrepository, savedata, collection);
+ minecraftserver.reloadResources(collection1);
+ }
+ // CraftBukkit end
+
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
- dispatcher.register(Commands.literal("reload").requires(source -> source.hasPermission(2)).executes(context -> {
- CommandSourceStack commandSourceStack = context.getSource();
- MinecraftServer server = commandSourceStack.getServer();
- PackRepository packRepository = server.getPackRepository();
- WorldData worldData = server.getWorldData();
- Collection<String> selectedIds = packRepository.getSelectedIds();
- Collection<String> collection = discoverNewPacks(packRepository, worldData, selectedIds);
- commandSourceStack.sendSuccess(() -> Component.translatable("commands.reload.success"), true);
- reloadPacks(collection, commandSourceStack);
+ dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("reload").requires((commandlistenerwrapper) -> {
+ return commandlistenerwrapper.hasPermission(2);
+ })).executes((commandcontext) -> {
+ CommandSourceStack commandlistenerwrapper = (CommandSourceStack) commandcontext.getSource();
+ MinecraftServer minecraftserver = commandlistenerwrapper.getServer();
+ PackRepository resourcepackrepository = minecraftserver.getPackRepository();
+ WorldData savedata = minecraftserver.getWorldData();
+ Collection<String> collection = resourcepackrepository.getSelectedIds();
+ Collection<String> collection1 = discoverNewPacks(resourcepackrepository, savedata, collection);
+
+ commandlistenerwrapper.sendSuccess(() -> {
+ return Component.translatable("commands.reload.success");
+ }, true);
+ reloadPacks(collection1, commandlistenerwrapper);
return 0;
}));
}
|