Fix some plugin loading issue

This commit is contained in:
Marc Baloup 2022-12-14 17:58:05 +01:00
parent 49024bf3f8
commit 126d5df619
Signed by: marcbal
GPG Key ID: BBC0FE3ABC30B893
3 changed files with 12 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import fr.pandacube.lib.chat.Chat;
import fr.pandacube.lib.commands.BrigadierCommand; import fr.pandacube.lib.commands.BrigadierCommand;
import fr.pandacube.lib.commands.SuggestionsSupplier; import fr.pandacube.lib.commands.SuggestionsSupplier;
import fr.pandacube.lib.paper.permissions.PandalibPaperPermissions; 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.CraftServer;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftVector; import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftVector;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.VanillaCommandWrapper; import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.VanillaCommandWrapper;
@ -66,6 +67,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<BukkitBriga
private static final CommandDispatcher<BukkitBrigadierCommandSource> nmsDispatcher; private static final CommandDispatcher<BukkitBrigadierCommandSource> nmsDispatcher;
static { static {
PandalibPaperReflect.init();
vanillaCommandDispatcher = ReflectWrapper.wrapTyped(Bukkit.getServer(), CraftServer.class) vanillaCommandDispatcher = ReflectWrapper.wrapTyped(Bukkit.getServer(), CraftServer.class)
.getServer() .getServer()
.vanillaCommandDispatcher(); .vanillaCommandDispatcher();

View File

@ -71,11 +71,18 @@ import static fr.pandacube.lib.reflect.wrapper.WrapperRegistry.initWrapper;
*/ */
public class PandalibPaperReflect { public class PandalibPaperReflect {
private static boolean isInit = false;
/** /**
* Initializes the reflect tools in {@code pandalib-paper-reflect} module. * Initializes the reflect tools in {@code pandalib-paper-reflect} module.
*/ */
public static void init() { public static void init() {
NMSReflect.init(); NMSReflect.init();
synchronized (PandalibPaperReflect.class) {
if (isInit)
return;
isInit = true;
}
initWrapperClasses(); initWrapperClasses();
} }

View File

@ -7,11 +7,12 @@ public class PandaLibPaper {
private static Plugin plugin; private static Plugin plugin;
public static void init(Plugin plugin) { public static void onLoad(Plugin plugin) {
PandaLibPaper.plugin = plugin; PandaLibPaper.plugin = plugin;
}
public static void onEnable() {
PerformanceAnalysisManager.getInstance(); // initialize PerformanceAnalysisManager.getInstance(); // initialize
} }