From 77985e5a230e22c23f2310811faa304f2fe6e160 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 20 Sep 2021 16:46:07 +0100 Subject: [PATCH] Improved mythicmobs pr --- .../com/willfp/ecobosses/EcoBossesPlugin.java | 3 +- .../bosses/util/bosstype/BossEntityUtils.java | 38 ++++++++----------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java index ff15fe1..7f1d29d 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java @@ -51,8 +51,7 @@ public class EcoBossesPlugin extends EcoPlugin { @Override protected List loadIntegrationLoaders() { return Arrays.asList( - new IntegrationLoader("LevelledMobs", () -> this.getEventManager().registerListener(new LevelledMobsListener())), - new IntegrationLoader("MythicMobs", () -> BossEntityUtils.mythicMobs = true) + new IntegrationLoader("LevelledMobs", () -> this.getEventManager().registerListener(new LevelledMobsListener())) ); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java index 5a2b062..9bdc61d 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java @@ -7,6 +7,7 @@ import lombok.Setter; import lombok.experimental.UtilityClass; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Zombie; import org.jetbrains.annotations.NotNull; import java.util.Arrays; @@ -14,11 +15,6 @@ import java.util.Arrays; @UtilityClass @SuppressWarnings("unchecked") public class BossEntityUtils { - - @Getter - @Setter - public static boolean mythicMobs = false; - /** * Get boss type. * @@ -27,32 +23,30 @@ public class BossEntityUtils { */ public static BossType getBossType(@NotNull String id) { - if (id.startsWith("mythicmobs_")) { - if (mythicMobs) { - int level; + if (id.startsWith("mythicmobs:")) { + int level; - try { - level = Integer.parseInt(Arrays.stream(id.split("_")).toList().get(id.split("_").length-1)); - } catch (NumberFormatException exception) { - level = 1; - } + try { + level = Integer.parseInt(Arrays.stream(id.split("_")).toList().get(id.split("_").length - 1)); + } catch (NumberFormatException exception) { + level = 1; + } - MythicMob mob = MythicMobs.inst().getMobManager().getMythicMob(id.replace("mythicmobs_", "").replace("_"+level, "")); - - if (mob != null) { - return new MythicMobsBossType(mob, level); - } - else id = "zombie"; - } else id = "zombie"; + MythicMob mob = MythicMobs.inst().getMobManager().getMythicMob(id.replace("mythicmobs:", "") + .replace("_" + level, "")); + if (mob != null) { + return new MythicMobsBossType(mob, level); + } } try { Class type = (Class) EntityType.valueOf(id.toUpperCase()).getEntityClass(); assert type != null; return new VanillaBossType(type); - } catch (IllegalArgumentException ignored) {} + } catch (IllegalArgumentException ignored) { + } - return null; + return new VanillaBossType(Zombie.class); } }