From d63e0ead6fecd813eabcda5aa6423e2c4e97323f Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 27 Apr 2021 12:35:20 +0100 Subject: [PATCH] Fixed NPE from ItemConversions when plugin hasn't finished loading --- .../enchantments/util/ItemConversions.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/ItemConversions.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/ItemConversions.java index 78d779fa..a1f4917d 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/ItemConversions.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/ItemConversions.java @@ -48,6 +48,10 @@ public class ItemConversions extends PluginDependent implements Listener { */ @EventHandler public void loreConverter(@NotNull final PlayerItemHeldEvent event) { + if (this.getPlugin().getDisplayModule() == null) { // If plugin hasn't finished loading. + return; + } + if (!((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().isUsingLoreGetter()) { return; } @@ -66,6 +70,10 @@ public class ItemConversions extends PluginDependent implements Listener { */ @EventHandler public void aggressiveLoreConverter(@NotNull final InventoryOpenEvent event) { + if (this.getPlugin().getDisplayModule() == null) { // If plugin hasn't finished loading. + return; + } + if (!((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().isUsingAggressiveLoreGetter()) { return; } @@ -163,6 +171,10 @@ public class ItemConversions extends PluginDependent implements Listener { */ @EventHandler public void hideFixer(@NotNull final PlayerItemHeldEvent event) { + if (this.getPlugin().getDisplayModule() == null) { // If plugin hasn't finished loading. + return; + } + if (!((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().isUsingExperimentalHideFixer()) { return; } @@ -181,6 +193,10 @@ public class ItemConversions extends PluginDependent implements Listener { */ @EventHandler public void aggressiveHideFixer(@NotNull final InventoryOpenEvent event) { + if (this.getPlugin().getDisplayModule() == null) { // If plugin hasn't finished loading. + return; + } + if (!((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().isUsingAggressiveExperimentalHideFixer()) { return; }