From 60219c756a369fe532d2bed47bdb0213607a8844 Mon Sep 17 00:00:00 2001 From: DaJokni <56400974+DaJokni@users.noreply.github.com> Date: Sat, 3 Feb 2024 01:21:27 +0200 Subject: [PATCH] fix nullpointers when plugin fails to load --- .../net/crashcraft/crashclaim/CrashClaim.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/crashcraft/crashclaim/CrashClaim.java b/src/main/java/net/crashcraft/crashclaim/CrashClaim.java index 29762e9..160b8c6 100644 --- a/src/main/java/net/crashcraft/crashclaim/CrashClaim.java +++ b/src/main/java/net/crashcraft/crashclaim/CrashClaim.java @@ -81,6 +81,13 @@ public void onLoad() { @Override public void onEnable() { + + String bukkitVersion = Bukkit.getBukkitVersion(); + if (!bukkitVersion.matches("1\\.20\\.\\d+.*")) { + getLogger().severe("Incompatible server version: " + bukkitVersion); + getServer().getPluginManager().disablePlugin(this); + } + Bukkit.getPluginManager().registerEvents(pluginSupport, this); taskChainFactory = BukkitTaskChainFactory.create(this); @@ -130,13 +137,6 @@ public void onEnable() { Bukkit.getServicesManager().register(PaymentProvider.class, payment.getProvider(), plugin, ServicePriority.Normal); - String bukkitVersion = Bukkit.getBukkitVersion(); - if (!bukkitVersion.matches("1\\.20\\.\\d+.*")) { - getLogger().severe("Incompatible server version: " + bukkitVersion); - getServer().getPluginManager().disablePlugin(this); - } - - if (GlobalConfig.useStatistics) { getLogger().info("Enabling Statistics"); Metrics metrics = new Metrics(this, 12015); @@ -157,7 +157,7 @@ public void onDisable() { //Unregister all user facing things HandlerList.unregisterAll(this); - commandManager.getCommandManager().unregisterCommands(); + if (commandManager != null) commandManager.getCommandManager().unregisterCommands(); for (Player player : Bukkit.getOnlinePlayers()){ if (player.getOpenInventory().getTopInventory().getHolder() instanceof GUI){ player.closeInventory();