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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
--- a/net/minecraft/server/ServerAdvancementManager.java
+++ b/net/minecraft/server/ServerAdvancementManager.java
@@ -1,8 +1,9 @@
+// mc-dev import
package net.minecraft.server;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Multimap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
@@ -10,8 +11,8 @@
import com.mojang.logging.LogUtils;
import com.mojang.serialization.JsonOps;
import java.util.Collection;
+import java.util.Iterator;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import net.minecraft.Util;
@@ -29,59 +30,70 @@
import org.slf4j.Logger;
public class ServerAdvancementManager extends SimpleJsonResourceReloadListener {
+
private static final Logger LOGGER = LogUtils.getLogger();
- private static final Gson GSON = new GsonBuilder().create();
- private Map<ResourceLocation, AdvancementHolder> advancements = Map.of();
+ public static final Gson GSON = (new GsonBuilder()).create();
+ public Map<ResourceLocation, AdvancementHolder> advancements = Map.of();
private AdvancementTree tree = new AdvancementTree();
private final LootDataManager lootData;
public ServerAdvancementManager(LootDataManager lootData) {
- super(GSON, "advancements");
+ super(ServerAdvancementManager.GSON, "advancements");
this.lootData = lootData;
}
- @Override
protected void apply(Map<ResourceLocation, JsonElement> object, ResourceManager resourceManager, ProfilerFiller profiler) {
Builder<ResourceLocation, AdvancementHolder> builder = ImmutableMap.builder();
- object.forEach((resourceLocation, jsonElement) -> {
+
+ object.forEach((minecraftkey, jsonelement) -> {
try {
- Advancement advancement = Util.getOrThrow(Advancement.CODEC.parse(JsonOps.INSTANCE, jsonElement), JsonParseException::new);
- this.validate(resourceLocation, advancement);
- builder.put(resourceLocation, new AdvancementHolder(resourceLocation, advancement));
- } catch (Exception var5x) {
- LOGGER.error("Parsing error loading custom advancement {}: {}", resourceLocation, var5x.getMessage());
+ Advancement advancement = (Advancement) Util.getOrThrow(Advancement.CODEC.parse(JsonOps.INSTANCE, jsonelement), JsonParseException::new);
+
+ this.validate(minecraftkey, advancement);
+ builder.put(minecraftkey, new AdvancementHolder(minecraftkey, advancement));
+ } catch (Exception exception) {
+ ServerAdvancementManager.LOGGER.error("Parsing error loading custom advancement {}: {}", minecraftkey, exception.getMessage());
}
+
});
this.advancements = builder.buildOrThrow();
- AdvancementTree advancementTree = new AdvancementTree();
- advancementTree.addAll(this.advancements.values());
+ AdvancementTree advancementtree = new AdvancementTree();
- for (AdvancementNode advancementNode : advancementTree.roots()) {
- if (advancementNode.holder().value().display().isPresent()) {
- TreeNodePosition.run(advancementNode);
+ advancementtree.addAll(this.advancements.values());
+ Iterator iterator = advancementtree.roots().iterator();
+
+ while (iterator.hasNext()) {
+ AdvancementNode advancementnode = (AdvancementNode) iterator.next();
+
+ if (advancementnode.holder().value().display().isPresent()) {
+ TreeNodePosition.run(advancementnode);
}
}
- this.tree = advancementTree;
+ this.tree = advancementtree;
}
- private void validate(ResourceLocation resourceLocation, Advancement advancement) {
- ProblemReporter.Collector collector = new ProblemReporter.Collector();
- advancement.validate(collector, this.lootData);
- Multimap<String, String> multimap = collector.get();
+ private void validate(ResourceLocation minecraftkey, Advancement advancement) {
+ ProblemReporter.a problemreporter_a = new ProblemReporter.a();
+
+ advancement.validate(problemreporter_a, this.lootData);
+ Multimap<String, String> multimap = problemreporter_a.get();
+
if (!multimap.isEmpty()) {
- String string = multimap.asMap()
- .entrySet()
- .stream()
- .map(entry -> " at " + entry.getKey() + ": " + String.join("; ", entry.getValue()))
- .collect(Collectors.joining("\n"));
- LOGGER.warn("Found validation problems in advancement {}: \n{}", resourceLocation, string);
+ String s = (String) multimap.asMap().entrySet().stream().map((entry) -> {
+ String s1 = (String) entry.getKey();
+
+ return " at " + s1 + ": " + String.join("; ", (Iterable) entry.getValue());
+ }).collect(Collectors.joining("\n"));
+
+ ServerAdvancementManager.LOGGER.warn("Found validation problems in advancement {}: \n{}", minecraftkey, s);
}
+
}
@Nullable
- public AdvancementHolder get(ResourceLocation resourceLocation) {
- return this.advancements.get(resourceLocation);
+ public AdvancementHolder get(ResourceLocation minecraftkey) {
+ return (AdvancementHolder) this.advancements.get(minecraftkey);
}
public AdvancementTree tree() {
|