9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-20 23:49:22 +00:00

Improved mythicmobs pr

This commit is contained in:
Auxilor
2021-09-20 16:46:07 +01:00
parent 201ec4161b
commit 77985e5a23
2 changed files with 17 additions and 24 deletions

View File

@@ -51,8 +51,7 @@ public class EcoBossesPlugin extends EcoPlugin {
@Override @Override
protected List<IntegrationLoader> loadIntegrationLoaders() { protected List<IntegrationLoader> loadIntegrationLoaders() {
return Arrays.asList( return Arrays.asList(
new IntegrationLoader("LevelledMobs", () -> this.getEventManager().registerListener(new LevelledMobsListener())), new IntegrationLoader("LevelledMobs", () -> this.getEventManager().registerListener(new LevelledMobsListener()))
new IntegrationLoader("MythicMobs", () -> BossEntityUtils.mythicMobs = true)
); );
} }

View File

@@ -7,6 +7,7 @@ import lombok.Setter;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Zombie;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Arrays; import java.util.Arrays;
@@ -14,11 +15,6 @@ import java.util.Arrays;
@UtilityClass @UtilityClass
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class BossEntityUtils { public class BossEntityUtils {
@Getter
@Setter
public static boolean mythicMobs = false;
/** /**
* Get boss type. * Get boss type.
* *
@@ -27,32 +23,30 @@ public class BossEntityUtils {
*/ */
public static BossType getBossType(@NotNull String id) { public static BossType getBossType(@NotNull String id) {
if (id.startsWith("mythicmobs_")) { if (id.startsWith("mythicmobs:")) {
if (mythicMobs) {
int level; int level;
try { try {
level = Integer.parseInt(Arrays.stream(id.split("_")).toList().get(id.split("_").length-1)); level = Integer.parseInt(Arrays.stream(id.split("_")).toList().get(id.split("_").length - 1));
} catch (NumberFormatException exception) { } catch (NumberFormatException exception) {
level = 1; level = 1;
} }
MythicMob mob = MythicMobs.inst().getMobManager().getMythicMob(id.replace("mythicmobs_", "").replace("_"+level, "")); MythicMob mob = MythicMobs.inst().getMobManager().getMythicMob(id.replace("mythicmobs:", "")
.replace("_" + level, ""));
if (mob != null) { if (mob != null) {
return new MythicMobsBossType(mob, level); return new MythicMobsBossType(mob, level);
} }
else id = "zombie";
} else id = "zombie";
} }
try { try {
Class<? extends LivingEntity> type = (Class<? extends LivingEntity>) EntityType.valueOf(id.toUpperCase()).getEntityClass(); Class<? extends LivingEntity> type = (Class<? extends LivingEntity>) EntityType.valueOf(id.toUpperCase()).getEntityClass();
assert type != null; assert type != null;
return new VanillaBossType(type); return new VanillaBossType(type);
} catch (IllegalArgumentException ignored) {} } catch (IllegalArgumentException ignored) {
}
return null; return new VanillaBossType(Zombie.class);
} }
} }