diff --git a/gradle.properties b/gradle.properties index 3c8ded614..296fec522 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ group=com.lokamc.slice version=1.21.3-R0.1-SNAPSHOT mcVersion=1.21.3 -paperRef=c2294d7067959d264eb8ad275557f194a3e2656f +paperRef=da7138233f6392e791d790d1c3407414c855f9c2 updatingMinecraft=false org.gradle.caching=true diff --git a/patches/api/0012-Add-PlayerLoadStatsEvent.patch b/patches/api/0012-Add-PlayerLoadStatsEvent.patch index 27ac6d9fe..6f957b5f4 100644 --- a/patches/api/0012-Add-PlayerLoadStatsEvent.patch +++ b/patches/api/0012-Add-PlayerLoadStatsEvent.patch @@ -1,17 +1,18 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Cryptite Date: Sat, 16 Nov 2024 09:34:15 -0600 -Subject: [PATCH] Add PlayerLoadStatsEvent +Subject: [PATCH] Add PlayerLoadStatsEvent Fix patch diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadStatsEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadStatsEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..8c74868a7445b478a80aff160a7a588a885aa889 +index 0000000000000000000000000000000000000000..13c627b73520d862f864834732f0cad35532298b --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadStatsEvent.java -@@ -0,0 +1,53 @@ +@@ -0,0 +1,54 @@ +package com.destroystokyo.paper.event.player; + ++import com.google.gson.JsonObject; +import org.bukkit.Bukkit; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; @@ -26,7 +27,7 @@ index 0000000000000000000000000000000000000000..8c74868a7445b478a80aff160a7a588a +public class PlayerLoadStatsEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + private final UUID playerId; -+ private String json; ++ private JsonObject json; + + public PlayerLoadStatsEvent(@NotNull UUID playerId) { + super(!Bukkit.isPrimaryThread()); @@ -44,11 +45,11 @@ index 0000000000000000000000000000000000000000..8c74868a7445b478a80aff160a7a588a + } + + @Nullable -+ public String getStatistics() { ++ public JsonObject getStatistics() { + return json; + } + -+ public void setStatistics(@NotNull String json) { ++ public void setStatistics(@NotNull JsonObject json) { + this.json = json; + } + diff --git a/patches/server/0005-Add-World-Instance-flag.patch b/patches/server/0005-Add-World-Instance-flag.patch index c8ad49c1e..9416d29f0 100644 --- a/patches/server/0005-Add-World-Instance-flag.patch +++ b/patches/server/0005-Add-World-Instance-flag.patch @@ -17,10 +17,10 @@ index 585e2b43a0326f0b81597fa1234d3c67c76af550..e256e5ff5c167c6cff5b9e985cdc80d5 public LevelChunk getChunkIfLoaded(int x, int z) { return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 8f234b46c24a0ae08aa5f8190c5b27e1f62dfbab..149100c63bce390440f2d162cfd45ebf2ddc6976 100644 +index 57da11c0da7322e74810e7108e9c8000b0c36520..68e3dee346fe013f8e69900a0911583f851d2782 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -1329,6 +1329,18 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1330,6 +1330,18 @@ public class CraftWorld extends CraftRegionAccessor implements World { this.world.noSave = !value; } diff --git a/patches/server/0021-Add-PlayerLoadStatsEvent.patch b/patches/server/0021-Add-PlayerLoadStatsEvent.patch index 18393bbf0..8ac5a29c0 100644 --- a/patches/server/0021-Add-PlayerLoadStatsEvent.patch +++ b/patches/server/0021-Add-PlayerLoadStatsEvent.patch @@ -1,11 +1,11 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Cryptite Date: Sat, 16 Nov 2024 09:34:15 -0600 -Subject: [PATCH] Add PlayerLoadStatsEvent +Subject: [PATCH] Add PlayerLoadStatsEvent Fix patch diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index b775de1732238954e9bbbd072277254d2dc91b18..e590ce0e76985dd5c701ae933509221a2853266a 100644 +index 2c1781a45828ef8018e976a445984197f0df1445..46f060f33fcbc6a4568a7fcfba29e83a4d192578 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -1414,7 +1414,7 @@ public abstract class PlayerList { @@ -18,7 +18,7 @@ index b775de1732238954e9bbbd072277254d2dc91b18..e590ce0e76985dd5c701ae933509221a } diff --git a/src/main/java/net/minecraft/stats/ServerStatsCounter.java b/src/main/java/net/minecraft/stats/ServerStatsCounter.java -index da7e1a69ecb4e6b3be2d8544ac406aa519bd196e..3bac27ffaea7fe873aa73605256f83837322fe0a 100644 +index da7e1a69ecb4e6b3be2d8544ac406aa519bd196e..6947650f299f99402a4a8d9c8384eb9f71a8e3a6 100644 --- a/src/main/java/net/minecraft/stats/ServerStatsCounter.java +++ b/src/main/java/net/minecraft/stats/ServerStatsCounter.java @@ -45,10 +45,16 @@ public class ServerStatsCounter extends StatsCounter { @@ -33,10 +33,130 @@ index da7e1a69ecb4e6b3be2d8544ac406aa519bd196e..3bac27ffaea7fe873aa73605256f8383 + // Slice start - If event supplies stats, use it. Otherwise just load from disk as usual + com.destroystokyo.paper.event.player.PlayerLoadStatsEvent event = new com.destroystokyo.paper.event.player.PlayerLoadStatsEvent(uuid); + org.bukkit.Bukkit.getPluginManager().callEvent(event); -+ String providedJson = event.getStatistics(); ++ JsonObject providedJson = event.getStatistics(); + if (providedJson != null) { -+ this.parseLocal(server.getFixerUpper(), providedJson); ++ parseLocal(server.getFixerUpper(), providedJson); + } else if (file.isFile()) { // Slice end try { this.parseLocal(server.getFixerUpper(), FileUtils.readFileToString(file)); } catch (IOException ioexception) { +@@ -101,77 +107,59 @@ public class ServerStatsCounter extends StatsCounter { + try { + JsonReader jsonreader = new JsonReader(new StringReader(json)); + +- label48: +- { +- try { +- jsonreader.setLenient(false); +- JsonElement jsonelement = Streams.parse(jsonreader); +- +- if (!jsonelement.isJsonNull()) { +- CompoundTag nbttagcompound = ServerStatsCounter.fromJson(jsonelement.getAsJsonObject()); +- +- nbttagcompound = DataFixTypes.STATS.updateToCurrentVersion(dataFixer, nbttagcompound, NbtUtils.getDataVersion(nbttagcompound, 1343)); +- if (!nbttagcompound.contains("stats", 10)) { +- break label48; +- } +- +- CompoundTag nbttagcompound1 = nbttagcompound.getCompound("stats"); +- Iterator iterator = nbttagcompound1.getAllKeys().iterator(); +- +- while (true) { +- if (!iterator.hasNext()) { +- break label48; +- } +- +- String s1 = (String) iterator.next(); +- +- if (nbttagcompound1.contains(s1, 10)) { +- Util.ifElse(BuiltInRegistries.STAT_TYPE.getOptional(ResourceLocation.parse(s1)), (statisticwrapper) -> { +- CompoundTag nbttagcompound2 = nbttagcompound1.getCompound(s1); +- Iterator iterator1 = nbttagcompound2.getAllKeys().iterator(); +- +- while (iterator1.hasNext()) { +- String s2 = (String) iterator1.next(); +- +- 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, nbttagcompound2.get(s2), s2}); +- } +- } +- +- }, () -> { +- ServerStatsCounter.LOGGER.warn("Invalid statistic type in {}: Don't know what {} is", this.file, s1); +- }); +- } +- } +- } +- +- ServerStatsCounter.LOGGER.error("Unable to parse Stat data from {}", this.file); +- } catch (Throwable throwable) { +- try { +- jsonreader.close(); +- } catch (Throwable throwable1) { +- throwable.addSuppressed(throwable1); +- } ++ // Slice start ++ try { ++ jsonreader.setLenient(false); ++ JsonElement jsonelement = Streams.parse(jsonreader); + +- throw throwable; ++ if (!jsonelement.isJsonNull()) { ++ parseLocal(dataFixer, jsonelement.getAsJsonObject()); // Slice ++ } ++ } catch (Throwable throwable) { ++ try { ++ jsonreader.close(); ++ } catch (Throwable throwable1) { ++ throwable.addSuppressed(throwable1); + } + +- jsonreader.close(); +- return; ++ throw throwable; + } + + jsonreader.close(); + } catch (IOException | JsonParseException jsonparseexception) { + ServerStatsCounter.LOGGER.error("Unable to parse Stat data from {}", this.file, jsonparseexception); + } ++ } ++ ++ public void parseLocal(DataFixer dataFixer, JsonObject jsonObject) { ++ CompoundTag nbttagcompound = ServerStatsCounter.fromJson(jsonObject); ++ nbttagcompound = DataFixTypes.STATS.updateToCurrentVersion(dataFixer, nbttagcompound, NbtUtils.getDataVersion(nbttagcompound, 1343)); ++ if (!nbttagcompound.contains("stats", 10)) { ++ ServerStatsCounter.LOGGER.error("Unable to parse Stat data from {}", jsonObject); ++ return; ++ } + ++ CompoundTag nbttagcompound1 = nbttagcompound.getCompound("stats"); ++ ++ for (String s1 : nbttagcompound1.getAllKeys()) { ++ if (nbttagcompound1.contains(s1, 10)) { ++ Util.ifElse(BuiltInRegistries.STAT_TYPE.getOptional(ResourceLocation.parse(s1)), (statisticwrapper) -> { ++ CompoundTag nbttagcompound2 = nbttagcompound1.getCompound(s1); ++ for (String s2 : nbttagcompound2.getAllKeys()) { ++ 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, nbttagcompound2.get(s2), s2}); ++ } ++ } ++ ++ }, () -> ServerStatsCounter.LOGGER.warn("Invalid statistic type in {}: Don't know what {} is", this.file, s1)); ++ } ++ } + } ++ // Slice end + + private Optional> getStat(StatType type, String id) { + // CraftBukkit - decompile error start diff --git a/patches/server/0024-Add-PlayerData-Events.patch b/patches/server/0024-Add-PlayerData-Events.patch index f93b54d59..bd9e3221a 100644 --- a/patches/server/0024-Add-PlayerData-Events.patch +++ b/patches/server/0024-Add-PlayerData-Events.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add PlayerData Events diff --git a/src/main/java/net/minecraft/stats/ServerStatsCounter.java b/src/main/java/net/minecraft/stats/ServerStatsCounter.java -index 3bac27ffaea7fe873aa73605256f83837322fe0a..ba8416b010ca17cc5a4640dab2f9f5420227f3ca 100644 +index 6947650f299f99402a4a8d9c8384eb9f71a8e3a6..299fcc2ecb17f8d42ff3480ec9868127faa9b0fc 100644 --- a/src/main/java/net/minecraft/stats/ServerStatsCounter.java +++ b/src/main/java/net/minecraft/stats/ServerStatsCounter.java -@@ -210,7 +210,12 @@ public class ServerStatsCounter extends StatsCounter { +@@ -192,7 +192,12 @@ public class ServerStatsCounter extends StatsCounter { return nbttagcompound; } @@ -22,7 +22,7 @@ index 3bac27ffaea7fe873aa73605256f83837322fe0a..ba8416b010ca17cc5a4640dab2f9f542 Map, JsonObject> map = Maps.newHashMap(); ObjectIterator objectiterator = this.stats.object2IntEntrySet().iterator(); -@@ -236,7 +241,7 @@ public class ServerStatsCounter extends StatsCounter { +@@ -218,7 +223,7 @@ public class ServerStatsCounter extends StatsCounter { jsonobject1.add("stats", jsonobject); jsonobject1.addProperty("DataVersion", SharedConstants.getCurrentVersion().getDataVersion().getVersion());