From ea80af1b99cfb4dbe7ac0564ffaf2298ed07ec0d Mon Sep 17 00:00:00 2001 From: Eli Date: Thu, 14 Apr 2022 13:22:12 +0200 Subject: [PATCH] fix future errors for out-of-date MM hook --- src/main/java/me/justeli/coins/Coins.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/justeli/coins/Coins.java b/src/main/java/me/justeli/coins/Coins.java index c3a867c..f7f5ec8 100644 --- a/src/main/java/me/justeli/coins/Coins.java +++ b/src/main/java/me/justeli/coins/Coins.java @@ -92,15 +92,18 @@ public void onEnable () if (getServer().getPluginManager().isPluginEnabled("MythicMobs")) { Optional mm = Optional.ofNullable(getServer().getPluginManager().getPlugin("MythicMobs")); - if (mm.isPresent() && mm.get().getDescription().getVersion().startsWith("4.")) + try { - this.mmHook = new MythicMobsHook4(this); + if (mm.isPresent() && mm.get().getDescription().getVersion().startsWith("4.")) + { + this.mmHook = new MythicMobsHook4(this); + } + else if (mm.isPresent()) + { + this.mmHook = new MythicMobsHook5(this); + } } - else if (mm.isPresent() && mm.get().getDescription().getVersion().startsWith("5.")) - { - this.mmHook = new MythicMobsHook5(this); - } - else + catch (Exception | NoClassDefFoundError exception) { console(Level.WARNING, "Detected MythicMobs, but the version of MythicMobs you are using is not supported."); }