9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-21 16:09:24 +00:00

Added MythicMobs mobs support. Usage: 'base-mob: mythicmobs_<MythicMobName>_<level>'

This commit is contained in:
_OfTeN_
2021-09-19 22:49:49 +03:00
parent 31ccdf2589
commit a2c8b73dbc
6 changed files with 96 additions and 11 deletions

View File

@@ -39,6 +39,7 @@ allprojects {
maven { url 'https://maven.sk89q.com/repo/' }
maven { url 'https://github.com/factions-site/repo/raw/public/' }
maven { url 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
maven { url 'https://mvn.lumine.io/repository/maven-public/' }
}
jar {
@@ -85,7 +86,15 @@ shadowJar {
}
jar {
archiveFileName = findProperty("plugin-name") + " v" + findProperty("version") + " " + "unshaded" + ".jar"
archiveFileName = findProperty("plugin-name") + " v" + findProperty("version") + ".jar"
}
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
group = 'com.willfp'

View File

@@ -6,4 +6,5 @@ dependencies {
compileOnly 'commons-io:commons-io:2.8.0'
compileOnly 'com.destroystokyo.paper:paper-api:1.16.3-R0.1-SNAPSHOT'
compileOnly 'com.github.lokka30:LevelledMobs:3.1.4'
compileOnly 'io.lumine.xikage:MythicMobs:4.9.1'
}

View File

@@ -3,12 +3,9 @@ package com.willfp.ecobosses;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.command.impl.PluginCommand;
import com.willfp.eco.core.integrations.IntegrationLoader;
import com.willfp.ecobosses.bosses.listeners.AttackListeners;
import com.willfp.ecobosses.bosses.listeners.AutoSpawnTimer;
import com.willfp.ecobosses.bosses.listeners.DeathListeners;
import com.willfp.ecobosses.bosses.listeners.PassiveListeners;
import com.willfp.ecobosses.bosses.listeners.SpawnListeners;
import com.willfp.ecobosses.bosses.listeners.*;
import com.willfp.ecobosses.bosses.util.BossUtils;
import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils;
import com.willfp.ecobosses.commands.CommandEcobosses;
import com.willfp.ecobosses.integrations.levelledmobs.LevelledMobsListener;
import com.willfp.ecobosses.util.DiscoverRecipeListener;
@@ -46,7 +43,7 @@ public class EcoBossesPlugin extends EcoPlugin {
@Override
protected List<PluginCommand> loadPluginCommands() {
return Arrays.asList(
return List.of(
new CommandEcobosses(this)
);
}
@@ -54,7 +51,8 @@ public class EcoBossesPlugin extends EcoPlugin {
@Override
protected List<IntegrationLoader> loadIntegrationLoaders() {
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

@@ -13,11 +13,13 @@ import com.willfp.ecobosses.bosses.tick.tickers.NamePlaceholderTicker;
import com.willfp.ecobosses.bosses.tick.tickers.TargetTicker;
import com.willfp.ecobosses.bosses.util.obj.EquipmentPiece;
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.Block;
import org.bukkit.boss.BarFlag;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;

View File

@@ -1,26 +1,55 @@
package com.willfp.ecobosses.bosses.util.bosstype;
import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.UtilityClass;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
@UtilityClass
@SuppressWarnings("unchecked")
public class BossEntityUtils {
@Getter
@Setter
public static boolean mythicMobs = false;
/**
* Get boss type.
*
* @param id The name.
* @return The boss type.
*/
public static BossType getBossType(@NotNull final String id) {
public static BossType getBossType(@NotNull String id) {
if (mythicMobs && id.startsWith("mythicmobs_")) {
int level;
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";
}
try {
Class<? extends LivingEntity> type = (Class<? extends LivingEntity>) EntityType.valueOf(id.toUpperCase()).getEntityClass();
assert type != null;
return new VanillaBossType(type);
} catch (IllegalArgumentException ignored) {
}
} catch (IllegalArgumentException ignored) {}
return null;
}

View File

@@ -0,0 +1,46 @@
package com.willfp.ecobosses.bosses.util.bosstype;
import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.adapters.AbstractLocation;
import io.lumine.xikage.mythicmobs.adapters.AbstractWorld;
import io.lumine.xikage.mythicmobs.api.exceptions.InvalidMobTypeException;
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
public class MythicMobsBossType extends BossType {
/**
* The entity type.
*/
private final MythicMob boss;
/**
* Level of MythicMobs mob
*/
private final int level;
/**
* Create new vanilla boss type.
*
* @param boss The MythicMob.
*/
public MythicMobsBossType(MythicMob boss, int level) {
this.boss = boss;
this.level = level;
}
@Override
public LivingEntity spawnBossEntity(@NotNull Location location) {
try {
return (LivingEntity) MythicMobs.inst().getAPIHelper().spawnMythicMob(boss, location, level);
} catch (InvalidMobTypeException e) {
e.printStackTrace();
}
return null;
}
}