From 7b4e7355476d8097879aaf054f4b96d1db43c32b Mon Sep 17 00:00:00 2001 From: Indyuce Date: Thu, 12 Aug 2021 01:00:19 +0200 Subject: [PATCH] fixed denizen hook --- .../java/net/Indyuce/mmoitems/MMOItems.java | 6 ++---- .../mmoitems/comp/denizen/DenizenHook.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/main/java/net/Indyuce/mmoitems/comp/denizen/DenizenHook.java diff --git a/src/main/java/net/Indyuce/mmoitems/MMOItems.java b/src/main/java/net/Indyuce/mmoitems/MMOItems.java index 8c13427d..90ac1f11 100644 --- a/src/main/java/net/Indyuce/mmoitems/MMOItems.java +++ b/src/main/java/net/Indyuce/mmoitems/MMOItems.java @@ -1,6 +1,5 @@ package net.Indyuce.mmoitems; -import com.denizenscript.depenizen.bukkit.Depenizen; import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackCategory; import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackMessage; @@ -17,7 +16,7 @@ import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.api.util.message.FFPMMOItems; import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot; import net.Indyuce.mmoitems.comp.*; -import net.Indyuce.mmoitems.comp.denizen.DenizenBridge; +import net.Indyuce.mmoitems.comp.denizen.DenizenHook; import net.Indyuce.mmoitems.comp.eco.VaultSupport; import net.Indyuce.mmoitems.comp.enchants.AdvancedEnchantmentsHook; import net.Indyuce.mmoitems.comp.enchants.CrazyEnchantsStat; @@ -143,8 +142,7 @@ public class MMOItems extends LuminePlugin { enchantPlugins.add(new MythicEnchantsSupport()); if (Bukkit.getPluginManager().getPlugin("Depenizen") != null) { - Depenizen depenizen = (Depenizen) Bukkit.getPluginManager().getPlugin("Depenizen"); - depenizen.registerBridge(getName(), () -> new DenizenBridge()); + new DenizenHook(); getLogger().log(Level.INFO, "Hooked onto Denizen"); } } diff --git a/src/main/java/net/Indyuce/mmoitems/comp/denizen/DenizenHook.java b/src/main/java/net/Indyuce/mmoitems/comp/denizen/DenizenHook.java new file mode 100644 index 00000000..6a14a475 --- /dev/null +++ b/src/main/java/net/Indyuce/mmoitems/comp/denizen/DenizenHook.java @@ -0,0 +1,18 @@ +package net.Indyuce.mmoitems.comp.denizen; + +import com.denizenscript.depenizen.bukkit.Depenizen; +import net.Indyuce.mmoitems.MMOItems; +import org.bukkit.Bukkit; + +public class DenizenHook { + + /** + * Putting this here so that the Depenizen import does not + * appear in the main MMOItems class which would cause an issue + * for all servers without Denizen + */ + public DenizenHook() { + Depenizen depenizen = (Depenizen) Bukkit.getPluginManager().getPlugin("Depenizen"); + depenizen.registerBridge(MMOItems.plugin.getName(), () -> new DenizenBridge()); + } +}