9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-20 15:39:31 +00:00

Merge pull request #7

MythicMobs support
This commit is contained in:
Will FP
2021-09-20 16:43:40 +01:00
committed by GitHub
12 changed files with 117 additions and 11 deletions

View File

@@ -39,6 +39,7 @@ allprojects {
maven { url 'https://maven.sk89q.com/repo/' } maven { url 'https://maven.sk89q.com/repo/' }
maven { url 'https://github.com/factions-site/repo/raw/public/' } maven { url 'https://github.com/factions-site/repo/raw/public/' }
maven { url 'https://repo.extendedclip.com/content/repositories/placeholderapi/' } maven { url 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
maven { url 'https://mvn.lumine.io/repository/maven-public/' }
} }
jar { jar {
@@ -85,7 +86,15 @@ shadowJar {
} }
jar { 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' group = 'com.willfp'

View File

@@ -6,4 +6,5 @@ dependencies {
compileOnly 'commons-io:commons-io:2.8.0' compileOnly 'commons-io:commons-io:2.8.0'
compileOnly 'com.destroystokyo.paper:paper-api:1.16.3-R0.1-SNAPSHOT' compileOnly 'com.destroystokyo.paper:paper-api:1.16.3-R0.1-SNAPSHOT'
compileOnly 'com.github.lokka30:LevelledMobs:3.1.4' 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.EcoPlugin;
import com.willfp.eco.core.command.impl.PluginCommand; import com.willfp.eco.core.command.impl.PluginCommand;
import com.willfp.eco.core.integrations.IntegrationLoader; import com.willfp.eco.core.integrations.IntegrationLoader;
import com.willfp.ecobosses.bosses.listeners.AttackListeners; import com.willfp.ecobosses.bosses.listeners.*;
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.util.BossUtils; 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.commands.CommandEcobosses;
import com.willfp.ecobosses.integrations.levelledmobs.LevelledMobsListener; import com.willfp.ecobosses.integrations.levelledmobs.LevelledMobsListener;
import com.willfp.ecobosses.util.DiscoverRecipeListener; import com.willfp.ecobosses.util.DiscoverRecipeListener;
@@ -46,7 +43,7 @@ public class EcoBossesPlugin extends EcoPlugin {
@Override @Override
protected List<PluginCommand> loadPluginCommands() { protected List<PluginCommand> loadPluginCommands() {
return Arrays.asList( return List.of(
new CommandEcobosses(this) new CommandEcobosses(this)
); );
} }
@@ -54,7 +51,8 @@ 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

@@ -124,6 +124,11 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
@Getter @Getter
private final int attackDamage; private final int attackDamage;
/**
* Age state.
*/
@Getter
private final boolean baby;
/** /**
* The follow range. * The follow range.
@@ -325,6 +330,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
this.name = name; this.name = name;
this.livingBosses = new HashMap<>(); this.livingBosses = new HashMap<>();
this.isGlowing = this.getConfig().getBool("glowing"); this.isGlowing = this.getConfig().getBool("glowing");
this.baby = this.getConfig().getBool("baby");
this.displayName = this.getConfig().getString("name"); this.displayName = this.getConfig().getString("name");

View File

@@ -13,12 +13,15 @@ import com.willfp.ecobosses.bosses.tick.tickers.NamePlaceholderTicker;
import com.willfp.ecobosses.bosses.tick.tickers.TargetTicker; import com.willfp.ecobosses.bosses.tick.tickers.TargetTicker;
import com.willfp.ecobosses.bosses.util.obj.EquipmentPiece; import com.willfp.ecobosses.bosses.util.obj.EquipmentPiece;
import com.willfp.ecobosses.bosses.util.obj.OptionedSound; import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance; import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier; import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.Block;
import org.bukkit.boss.BarFlag; import org.bukkit.boss.BarFlag;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
@@ -105,6 +108,11 @@ public class LivingEcoBoss extends PluginDependent<EcoPlugin> {
if (boss.isGlowing()) entity.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, Integer.MAX_VALUE, 1, false, false, false)); if (boss.isGlowing()) entity.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, Integer.MAX_VALUE, 1, false, false, false));
if (entity instanceof Ageable ageable) {
if (boss.isBaby()) ageable.setBaby();
else ageable.setAdult();
}
if (boss.getTimeToLive() > 0) { if (boss.getTimeToLive() > 0) {
entity.setMetadata("death-time", this.getPlugin().getMetadataValueFactory().create(System.currentTimeMillis() + (boss.getTimeToLive() * 1000L))); entity.setMetadata("death-time", this.getPlugin().getMetadataValueFactory().create(System.currentTimeMillis() + (boss.getTimeToLive() * 1000L)));
} }

View File

@@ -1,26 +1,57 @@
package com.willfp.ecobosses.bosses.util.bosstype; 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 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.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
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.
* *
* @param id The name. * @param id The name.
* @return The boss type. * @return The boss type.
*/ */
public static BossType getBossType(@NotNull final String id) { public static BossType getBossType(@NotNull String id) {
if (id.startsWith("mythicmobs_")) {
if (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";
} 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 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;
}
}

View File

@@ -2,6 +2,7 @@ enabled: true
name: "&fAlpha Wolf &7| &c%health%♥ &7| &e%time%" # Display name name: "&fAlpha Wolf &7| &c%health%♥ &7| &e%time%" # Display name
base-mob: wolf base-mob: wolf
baby: false # If set to true: will make the boss mob baby (if possible)
bossbar: bossbar:
enabled: true enabled: true

View File

@@ -2,6 +2,7 @@ enabled: true
name: "&9Dark Guardian &7| &c%health%♥ &7| &e%time%" # Display name name: "&9Dark Guardian &7| &c%health%♥ &7| &e%time%" # Display name
base-mob: ravager base-mob: ravager
baby: false # If set to true: will make the boss mob baby (if possible)
bossbar: bossbar:
enabled: true enabled: true

View File

@@ -2,6 +2,7 @@ enabled: true
name: "&8Steel Golem &7| &c%health%♥ &7| &e%time%" # Display name name: "&8Steel Golem &7| &c%health%♥ &7| &e%time%" # Display name
base-mob: iron_golem base-mob: iron_golem
baby: false # If set to true: will make the boss mob baby (if possible)
bossbar: bossbar:
enabled: true enabled: true

View File

@@ -2,6 +2,7 @@ enabled: true
name: "&4Tarantula &7| &c%health%♥ &7| &e%time%" # Display name name: "&4Tarantula &7| &c%health%♥ &7| &e%time%" # Display name
base-mob: cave_spider base-mob: cave_spider
baby: false # If set to true: will make the boss mob baby (if possible)
bossbar: bossbar:
enabled: true enabled: true

View File

@@ -5,6 +5,9 @@ api-version: 1.16
authors: [Auxilor] authors: [Auxilor]
website: willfp.com website: willfp.com
load: STARTUP load: STARTUP
softdepend:
- MythicMobs
- LevelledMobs
depend: depend:
- eco - eco