Yatopia/patches/server/0056-Preload-ProtocolLib-EnumWrappers.patch

68 lines
3.5 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ishland <ishlandmc@yeah.net>
Date: Wed, 27 Jan 2021 20:16:47 +0800
Subject: [PATCH] Preload ProtocolLib EnumWrappers
Currently, ProtocolLib load EnumWrappers lazily and causing memory effects issues. This patch preloads EnumWrappers to prevent further NPE.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
Upstream (#461) * Updated Upstream and Sidestream(s) (Paper) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 8a29f5894 [Auto] Updated Upstream (Bukkit/CraftBukkit) 8756d232c Expose server protocol version (#5416) * Updated Upstream and Sidestream(s) (Tuinity/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Tuinity Changes: 32b4d52 Updated Upstream (Paper) ac5adca Make sure lit is set for pre 1.14 chunks Purpur Changes: 24d9e61 Piglin portal spawn modifier 5866f36 Fix #263 - NPE on TPSBar when player disconnects 7f7f024 Updated Upstream (Paper, Tuinity, & Airplane) * bump kotlin-stdlib * Updated Upstream and Sidestream(s) (Paper/Airplane/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 606cdac60 Update the view distance before scheduling chunk loads (#5269) Airplane Changes: 0789789 Updated Upstream (Tuinity) c1e4d71 Fluid cache patch Purpur Changes: 04f73c5 Fix error when using non living entity on monster egg 76c35fc Fix #287 - TPSBarTask NPE (again) * Updated Upstream and Sidestream(s) (Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Purpur Changes: 2e62618 Fix #280 - Ridables do not reset idle timer
2021-04-15 20:46:34 +02:00
index 01775d93c5cc6eda99c0a7190b5ce43be36d52cc..ada7639c31fe6952f689bc2e437db57abe1b1037 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
Upstream (#461) * Updated Upstream and Sidestream(s) (Paper) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 8a29f5894 [Auto] Updated Upstream (Bukkit/CraftBukkit) 8756d232c Expose server protocol version (#5416) * Updated Upstream and Sidestream(s) (Tuinity/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Tuinity Changes: 32b4d52 Updated Upstream (Paper) ac5adca Make sure lit is set for pre 1.14 chunks Purpur Changes: 24d9e61 Piglin portal spawn modifier 5866f36 Fix #263 - NPE on TPSBar when player disconnects 7f7f024 Updated Upstream (Paper, Tuinity, & Airplane) * bump kotlin-stdlib * Updated Upstream and Sidestream(s) (Paper/Airplane/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 606cdac60 Update the view distance before scheduling chunk loads (#5269) Airplane Changes: 0789789 Updated Upstream (Tuinity) c1e4d71 Fluid cache patch Purpur Changes: 04f73c5 Fix error when using non living entity on monster egg 76c35fc Fix #287 - TPSBarTask NPE (again) * Updated Upstream and Sidestream(s) (Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Purpur Changes: 2e62618 Fix #280 - Ridables do not reset idle timer
2021-04-15 20:46:34 +02:00
@@ -1078,6 +1078,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
// Paper end
PaperJvmChecker.checkJvm(); // Paper jvm version nag
+ if (org.yatopiamc.yatopia.server.YatopiaConfig.fixProtocolLib) org.yatopiamc.yatopia.server.util.YatopiaPreloadProtocolLib.run(); // Yatopia
com.tuinity.tuinity.config.TuinityConfig.createWorldSections = false; // Tuinity - don't let plugin created worlds fill our config
org.spigotmc.WatchdogThread.tick(); // Paper
org.spigotmc.WatchdogThread.hasStarted = true; // Paper
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index c2dc5265552ebd429111253c70481003a4be29dd..15e2fa125bc293b954cceb5b1fbcec7fade3e4db 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -271,4 +271,9 @@ public class YatopiaConfig {
logPlayerLoginLoc = getBoolean("settings.log-player-login-location", logPlayerLoginLoc);
}
+ public static boolean fixProtocolLib = true;
+ private static void protocolLib() {
+ fixProtocolLib = getBoolean("settings.fix-protocollib", fixProtocolLib);
+ }
+
}
diff --git a/src/main/java/org/yatopiamc/yatopia/server/util/YatopiaPreloadProtocolLib.java b/src/main/java/org/yatopiamc/yatopia/server/util/YatopiaPreloadProtocolLib.java
new file mode 100644
index 0000000000000000000000000000000000000000..85906aa00163a4626b16190e2e48385bc5eba801
--- /dev/null
+++ b/src/main/java/org/yatopiamc/yatopia/server/util/YatopiaPreloadProtocolLib.java
@@ -0,0 +1,28 @@
+package org.yatopiamc.yatopia.server.util;
+
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.SimplePluginManager;
+
+import java.lang.reflect.Method;
+
+public class YatopiaPreloadProtocolLib {
+
+ public synchronized static void run() {
+ try {
+ final SimplePluginManager pluginManager = (SimplePluginManager) Bukkit.getPluginManager();
+ final Plugin protocolLib = pluginManager.getPlugin("ProtocolLib");
+ if(protocolLib != null && protocolLib.isEnabled()) {
+ MinecraftServer.LOGGER.info("Yatopia: Attempting to fix ProtocolLib");
+ final Method initialize = Class.forName("com.comphenix.protocol.wrappers.EnumWrappers", true, protocolLib.getClass().getClassLoader()).getDeclaredMethod("initialize");
+ initialize.setAccessible(true);
+ initialize.invoke(null);
+ synchronized (YatopiaPreloadProtocolLib.class) {
+ }
+ }
+ } catch (Throwable t) {
+ MinecraftServer.LOGGER.warn("Unable to fix ProtocolLib", t);
+ }
+ }
+}