2021-01-27 16:53:05 +01:00
|
|
|
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
|
2021-04-27 18:40:55 +02:00
|
|
|
index 43de296558a54657efa6b34e34bdaaeccaef8ed1..13f9af375011fe6a7e96605105d147445d58d26f 100644
|
2021-01-27 16:53:05 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2021-04-21 23:26:49 +02:00
|
|
|
@@ -1088,6 +1088,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2021-01-27 16:53:05 +01:00
|
|
|
// 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
|
2021-05-11 05:16:50 +02:00
|
|
|
index b246e6450130964cf91d0be81fbddae6598d9d8c..fce7ce0efca340cf5820cdcbe010c9fdeae7cafc 100644
|
2021-01-27 16:53:05 +01:00
|
|
|
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
|
|
|
|
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
|
2021-05-11 05:16:50 +02:00
|
|
|
@@ -266,4 +266,9 @@ public class YatopiaConfig {
|
2021-01-27 16:53:05 +01:00
|
|
|
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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|