aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/stats/ServerStatsCounter.java.patch
blob: ba76ef509ecfc6e1a67f45fb3bdce875b07d5b3a (plain)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
--- a/net/minecraft/stats/ServerStatsCounter.java
+++ b/net/minecraft/stats/ServerStatsCounter.java
@@ -1,3 +1,4 @@
+// mc-dev import
 package net.minecraft.stats;
 
 import com.google.common.collect.Maps;
@@ -44,12 +45,12 @@
     private final File file;
     private final Set<Stat<?>> dirty = Sets.newHashSet();
 
-    public ServerStatsCounter(MinecraftServer minecraftserver, File file) {
-        this.server = minecraftserver;
+    public ServerStatsCounter(MinecraftServer server, File file) {
+        this.server = server;
         this.file = file;
         if (file.isFile()) {
             try {
-                this.parseLocal(minecraftserver.getFixerUpper(), FileUtils.readFileToString(file));
+                this.parseLocal(server.getFixerUpper(), FileUtils.readFileToString(file));
             } catch (IOException ioexception) {
                 ServerStatsCounter.LOGGER.error("Couldn't read statistics file {}", file, ioexception);
             } catch (JsonParseException jsonparseexception) {
@@ -69,9 +70,8 @@
     }
 
     @Override
-    @Override
-    public void setValue(Player player, Stat<?> stat, int i) {
-        super.setValue(player, stat, i);
+    public void setValue(Player player, Stat<?> stat, int value) {
+        super.setValue(player, stat, value);
         this.dirty.add(stat);
     }
 
@@ -82,9 +82,9 @@
         return set;
     }
 
-    public void parseLocal(DataFixer datafixer, String s) {
+    public void parseLocal(DataFixer fixerUpper, String json) {
         try {
-            JsonReader jsonreader = new JsonReader(new StringReader(s));
+            JsonReader jsonreader = new JsonReader(new StringReader(json));
 
             label48:
             {
@@ -93,15 +93,15 @@
                     JsonElement jsonelement = Streams.parse(jsonreader);
 
                     if (!jsonelement.isJsonNull()) {
-                        CompoundTag compoundtag = fromJson(jsonelement.getAsJsonObject());
+                        CompoundTag nbttagcompound = fromJson(jsonelement.getAsJsonObject());
 
-                        compoundtag = DataFixTypes.STATS.updateToCurrentVersion(datafixer, compoundtag, NbtUtils.getDataVersion(compoundtag, 1343));
-                        if (!compoundtag.contains("stats", 10)) {
+                        nbttagcompound = DataFixTypes.STATS.updateToCurrentVersion(fixerUpper, nbttagcompound, NbtUtils.getDataVersion(nbttagcompound, 1343));
+                        if (!nbttagcompound.contains("stats", 10)) {
                             break label48;
                         }
 
-                        CompoundTag compoundtag1 = compoundtag.getCompound("stats");
-                        Iterator iterator = compoundtag1.getAllKeys().iterator();
+                        CompoundTag nbttagcompound1 = nbttagcompound.getCompound("stats");
+                        Iterator iterator = nbttagcompound1.getAllKeys().iterator();
 
                         while (true) {
                             if (!iterator.hasNext()) {
@@ -110,22 +110,22 @@
 
                             String s1 = (String) iterator.next();
 
-                            if (compoundtag1.contains(s1, 10)) {
-                                Util.ifElse(BuiltInRegistries.STAT_TYPE.getOptional(new ResourceLocation(s1)), (stattype) -> {
-                                    CompoundTag compoundtag2 = compoundtag1.getCompound(s1);
-                                    Iterator iterator1 = compoundtag2.getAllKeys().iterator();
+                            if (nbttagcompound1.contains(s1, 10)) {
+                                Util.ifElse(BuiltInRegistries.STAT_TYPE.getOptional(new ResourceLocation(s1)), (statisticwrapper) -> {
+                                    CompoundTag nbttagcompound2 = nbttagcompound1.getCompound(s1);
+                                    Iterator iterator1 = nbttagcompound2.getAllKeys().iterator();
 
                                     while (iterator1.hasNext()) {
                                         String s2 = (String) iterator1.next();
 
-                                        if (compoundtag2.contains(s2, 99)) {
-                                            Util.ifElse(this.getStat(stattype, s2), (stat) -> {
-                                                this.stats.put(stat, compoundtag2.getInt(s2));
+                                        if (nbttagcompound2.contains(s2, 99)) {
+                                            Util.ifElse(this.getStat(statisticwrapper, s2), (statistic) -> {
+                                                this.stats.put(statistic, nbttagcompound2.getInt(s2));
                                             }, () -> {
                                                 ServerStatsCounter.LOGGER.warn("Invalid statistic in {}: Don't know what {} is", this.file, s2);
                                             });
                                         } else {
-                                            ServerStatsCounter.LOGGER.warn("Invalid statistic value in {}: Don't know what {} is for key {}", new Object[]{this.file, compoundtag2.get(s2), s2});
+                                            ServerStatsCounter.LOGGER.warn("Invalid statistic value in {}: Don't know what {} is for key {}", new Object[]{this.file, nbttagcompound2.get(s2), s2});
                                         }
                                     }
 
@@ -158,36 +158,35 @@
 
     }
 
-    private <T> Optional<Stat<T>> getStat(StatType<T> stattype, String s) {
-        Optional optional = Optional.ofNullable(ResourceLocation.tryParse(s));
-        Registry registry = stattype.getRegistry();
+    private <T> Optional<Stat<T>> getStat(StatType<T> type, String location) {
+        // CraftBukkit - decompile error start
+        Optional<ResourceLocation> optional = Optional.ofNullable(ResourceLocation.tryParse(location));
+        Registry<T> iregistry = type.getRegistry();
 
-        Objects.requireNonNull(registry);
-        optional = optional.flatMap(registry::getOptional);
-        Objects.requireNonNull(stattype);
-        return optional.map(stattype::get);
+        return optional.flatMap(iregistry::getOptional).map(type::get);
+        // CraftBukkit - decompile error end
     }
 
-    private static CompoundTag fromJson(JsonObject jsonobject) {
-        CompoundTag compoundtag = new CompoundTag();
-        Iterator iterator = jsonobject.entrySet().iterator();
+    private static CompoundTag fromJson(JsonObject json) {
+        CompoundTag nbttagcompound = new CompoundTag();
+        Iterator iterator = json.entrySet().iterator();
 
         while (iterator.hasNext()) {
             Entry<String, JsonElement> entry = (Entry) iterator.next();
             JsonElement jsonelement = (JsonElement) entry.getValue();
 
             if (jsonelement.isJsonObject()) {
-                compoundtag.put((String) entry.getKey(), fromJson(jsonelement.getAsJsonObject()));
+                nbttagcompound.put((String) entry.getKey(), fromJson(jsonelement.getAsJsonObject()));
             } else if (jsonelement.isJsonPrimitive()) {
                 JsonPrimitive jsonprimitive = jsonelement.getAsJsonPrimitive();
 
                 if (jsonprimitive.isNumber()) {
-                    compoundtag.putInt((String) entry.getKey(), jsonprimitive.getAsInt());
+                    nbttagcompound.putInt((String) entry.getKey(), jsonprimitive.getAsInt());
                 }
             }
         }
 
-        return compoundtag;
+        return nbttagcompound;
     }
 
     protected String toJson() {
@@ -196,11 +195,11 @@
 
         while (objectiterator.hasNext()) {
             it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<Stat<?>> it_unimi_dsi_fastutil_objects_object2intmap_entry = (it.unimi.dsi.fastutil.objects.Object2IntMap.Entry) objectiterator.next();
-            Stat<?> stat = (Stat) it_unimi_dsi_fastutil_objects_object2intmap_entry.getKey();
+            Stat<?> statistic = (Stat) it_unimi_dsi_fastutil_objects_object2intmap_entry.getKey();
 
-            ((JsonObject) map.computeIfAbsent(stat.getType(), (stattype) -> {
+            ((JsonObject) map.computeIfAbsent(statistic.getType(), (statisticwrapper) -> {
                 return new JsonObject();
-            })).addProperty(getKey(stat).toString(), it_unimi_dsi_fastutil_objects_object2intmap_entry.getIntValue());
+            })).addProperty(getKey(statistic).toString(), it_unimi_dsi_fastutil_objects_object2intmap_entry.getIntValue());
         }
 
         JsonObject jsonobject = new JsonObject();
@@ -227,16 +226,16 @@
         this.dirty.addAll(this.stats.keySet());
     }
 
-    public void sendStats(ServerPlayer serverplayer) {
+    public void sendStats(ServerPlayer player) {
         Object2IntMap<Stat<?>> object2intmap = new Object2IntOpenHashMap();
         Iterator iterator = this.getDirty().iterator();
 
         while (iterator.hasNext()) {
-            Stat<?> stat = (Stat) iterator.next();
+            Stat<?> statistic = (Stat) iterator.next();
 
-            object2intmap.put(stat, this.getValue(stat));
+            object2intmap.put(statistic, this.getValue(statistic));
         }
 
-        serverplayer.connection.send(new ClientboundAwardStatsPacket(object2intmap));
+        player.connection.send(new ClientboundAwardStatsPacket(object2intmap));
     }
 }