From 126d5df619ebda6b26b617a0c3bf613ffd2203db Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Wed, 14 Dec 2022 17:58:05 +0100 Subject: [PATCH] Fix some plugin loading issue --- .../lib/paper/commands/PaperBrigadierCommand.java | 2 ++ .../pandacube/lib/paper/reflect/PandalibPaperReflect.java | 7 +++++++ .../main/java/fr/pandacube/lib/paper/PandaLibPaper.java | 5 +++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pandalib-paper-commands/src/main/java/fr/pandacube/lib/paper/commands/PaperBrigadierCommand.java b/pandalib-paper-commands/src/main/java/fr/pandacube/lib/paper/commands/PaperBrigadierCommand.java index 0d9e582..d27664a 100644 --- a/pandalib-paper-commands/src/main/java/fr/pandacube/lib/paper/commands/PaperBrigadierCommand.java +++ b/pandalib-paper-commands/src/main/java/fr/pandacube/lib/paper/commands/PaperBrigadierCommand.java @@ -13,6 +13,7 @@ import fr.pandacube.lib.chat.Chat; import fr.pandacube.lib.commands.BrigadierCommand; import fr.pandacube.lib.commands.SuggestionsSupplier; import fr.pandacube.lib.paper.permissions.PandalibPaperPermissions; +import fr.pandacube.lib.paper.reflect.PandalibPaperReflect; import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftServer; import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftVector; import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.VanillaCommandWrapper; @@ -66,6 +67,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand nmsDispatcher; static { + PandalibPaperReflect.init(); vanillaCommandDispatcher = ReflectWrapper.wrapTyped(Bukkit.getServer(), CraftServer.class) .getServer() .vanillaCommandDispatcher(); diff --git a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java index f0be8bb..9252be7 100644 --- a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java +++ b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java @@ -71,11 +71,18 @@ import static fr.pandacube.lib.reflect.wrapper.WrapperRegistry.initWrapper; */ public class PandalibPaperReflect { + private static boolean isInit = false; + /** * Initializes the reflect tools in {@code pandalib-paper-reflect} module. */ public static void init() { NMSReflect.init(); + synchronized (PandalibPaperReflect.class) { + if (isInit) + return; + isInit = true; + } initWrapperClasses(); } diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/PandaLibPaper.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/PandaLibPaper.java index 159c3c2..a91158c 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/PandaLibPaper.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/PandaLibPaper.java @@ -7,11 +7,12 @@ public class PandaLibPaper { private static Plugin plugin; - public static void init(Plugin plugin) { + public static void onLoad(Plugin plugin) { PandaLibPaper.plugin = plugin; + } + public static void onEnable() { PerformanceAnalysisManager.getInstance(); // initialize - }