Skip to content

Commit

Permalink
fix nullpointers when plugin fails to load
Browse files Browse the repository at this point in the history
  • Loading branch information
DaJokni committed Feb 2, 2024
1 parent e2bae3c commit 60219c7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/net/crashcraft/crashclaim/CrashClaim.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit 60219c7

Please sign in to comment.