mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-20 15:39:31 +00:00
Switched from BossType to Entities system
This commit is contained in:
@@ -4,6 +4,9 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
import com.willfp.eco.core.EcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.core.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import com.willfp.eco.core.config.interfaces.Config;
|
import com.willfp.eco.core.config.interfaces.Config;
|
||||||
|
import com.willfp.eco.core.entities.CustomEntity;
|
||||||
|
import com.willfp.eco.core.entities.Entities;
|
||||||
|
import com.willfp.eco.core.entities.TestableEntity;
|
||||||
import com.willfp.eco.core.integrations.placeholder.PlaceholderEntry;
|
import com.willfp.eco.core.integrations.placeholder.PlaceholderEntry;
|
||||||
import com.willfp.eco.core.items.Items;
|
import com.willfp.eco.core.items.Items;
|
||||||
import com.willfp.eco.core.items.builder.ItemBuilder;
|
import com.willfp.eco.core.items.builder.ItemBuilder;
|
||||||
@@ -16,8 +19,7 @@ import com.willfp.eco.util.NumberUtils;
|
|||||||
import com.willfp.eco.util.StringUtils;
|
import com.willfp.eco.util.StringUtils;
|
||||||
import com.willfp.ecobosses.bosses.effects.Effect;
|
import com.willfp.ecobosses.bosses.effects.Effect;
|
||||||
import com.willfp.ecobosses.bosses.effects.Effects;
|
import com.willfp.ecobosses.bosses.effects.Effects;
|
||||||
import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils;
|
import com.willfp.ecobosses.bosses.util.BossUtils;
|
||||||
import com.willfp.ecobosses.bosses.util.bosstype.BossType;
|
|
||||||
import com.willfp.ecobosses.bosses.util.obj.ArgumentedEffectName;
|
import com.willfp.ecobosses.bosses.util.obj.ArgumentedEffectName;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.BossbarProperties;
|
import com.willfp.ecobosses.bosses.util.obj.BossbarProperties;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.EquipmentPiece;
|
import com.willfp.ecobosses.bosses.util.obj.EquipmentPiece;
|
||||||
@@ -62,7 +64,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
* The name of the boss.
|
* The name of the boss.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private final String name;
|
private final String id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The config of the set.
|
* The config of the set.
|
||||||
@@ -79,7 +81,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
/**
|
/**
|
||||||
* The base entity spawner.
|
* The base entity spawner.
|
||||||
*/
|
*/
|
||||||
private final BossType bossType;
|
private final TestableEntity bossType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the boss bar is enabled.
|
* If the boss bar is enabled.
|
||||||
@@ -317,16 +319,16 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
/**
|
/**
|
||||||
* Create a new Boss.
|
* Create a new Boss.
|
||||||
*
|
*
|
||||||
* @param name The name of the set.
|
* @param id The name of the set.
|
||||||
* @param config The set's config.
|
* @param config The set's config.
|
||||||
* @param plugin Instance of EcoBosses.
|
* @param plugin Instance of EcoBosses.
|
||||||
*/
|
*/
|
||||||
public EcoBoss(@NotNull final String name,
|
public EcoBoss(@NotNull final String id,
|
||||||
@NotNull final Config config,
|
@NotNull final Config config,
|
||||||
@NotNull final EcoPlugin plugin) {
|
@NotNull final EcoPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.name = name;
|
this.id = id;
|
||||||
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.baby = this.getConfig().getBool("baby");
|
||||||
@@ -334,7 +336,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
this.displayName = this.getConfig().getFormattedString("name");
|
this.displayName = this.getConfig().getFormattedString("name");
|
||||||
|
|
||||||
// Boss Type
|
// Boss Type
|
||||||
this.bossType = BossEntityUtils.getBossType(this.getConfig().getString("base-mob"));
|
this.bossType = Entities.lookup("base-mob");
|
||||||
|
|
||||||
// Boss Bar
|
// Boss Bar
|
||||||
this.bossbarEnabled = this.getConfig().getBool("bossbar.enabled");
|
this.bossbarEnabled = this.getConfig().getBool("bossbar.enabled");
|
||||||
@@ -419,7 +421,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
|
|
||||||
// Rewards
|
// Rewards
|
||||||
this.drops = new ArrayList<>();
|
this.drops = new ArrayList<>();
|
||||||
drops.addAll(this.getConfig().getStrings("rewards.drops", false));
|
drops.addAll(this.getConfig().getStrings("rewards.drops"));
|
||||||
|
|
||||||
this.experienceOptions = new ExperienceOptions(
|
this.experienceOptions = new ExperienceOptions(
|
||||||
this.getConfig().getInt("rewards.xp.minimum"),
|
this.getConfig().getInt("rewards.xp.minimum"),
|
||||||
@@ -516,7 +518,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
this.topDamagerCommands = new HashMap<>();
|
this.topDamagerCommands = new HashMap<>();
|
||||||
for (int i = 1; i <= 3; i++) {
|
for (int i = 1; i <= 3; i++) {
|
||||||
this.topDamagerCommands.put(i, new ArrayList<>());
|
this.topDamagerCommands.put(i, new ArrayList<>());
|
||||||
for (String string : this.getConfig().getStrings("rewards.top-damager-commands." + i, false)) {
|
for (String string : this.getConfig().getStrings("rewards.top-damager-commands." + i)) {
|
||||||
double chance = 100;
|
double chance = 100;
|
||||||
if (string.contains("::")) {
|
if (string.contains("::")) {
|
||||||
String[] split = string.split("::");
|
String[] split = string.split("::");
|
||||||
@@ -532,7 +534,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
// Nearby Rewards
|
// Nearby Rewards
|
||||||
this.nearbyRadius = this.getConfig().getDouble("rewards.nearby-player-commands.radius");
|
this.nearbyRadius = this.getConfig().getDouble("rewards.nearby-player-commands.radius");
|
||||||
this.nearbyPlayersCommands = new HashMap<>();
|
this.nearbyPlayersCommands = new HashMap<>();
|
||||||
for (String string : this.getConfig().getStrings("rewards.nearby-player-commands.commands", false)) {
|
for (String string : this.getConfig().getStrings("rewards.nearby-player-commands.commands")) {
|
||||||
double chance = 100;
|
double chance = 100;
|
||||||
if (string.contains("::")) {
|
if (string.contains("::")) {
|
||||||
String[] split = string.split("::");
|
String[] split = string.split("::");
|
||||||
@@ -547,18 +549,13 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
for (String string : this.getConfig().getStrings("effects")) {
|
for (String string : this.getConfig().getStrings("effects")) {
|
||||||
String effectName = string.split(":")[0];
|
String effectName = string.split(":")[0];
|
||||||
List<String> args = new ArrayList<>(Arrays.asList(string.replace(effectName + ":", "").split(":")));
|
List<String> args = new ArrayList<>(Arrays.asList(string.replace(effectName + ":", "").split(":")));
|
||||||
if (args.contains("mythicmobs")) {
|
|
||||||
String newArg = "mythicmobs:" + args.get(args.indexOf("mythicmobs")+1);
|
|
||||||
args.set(args.indexOf("mythicmobs"), newArg);
|
|
||||||
args.remove(args.get(args.indexOf(newArg)+1));
|
|
||||||
}
|
|
||||||
this.effectNames.add(new ArgumentedEffectName(effectName, args));
|
this.effectNames.add(new ArgumentedEffectName(effectName, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ArgumentedEffectName effectName : new ArrayList<>(this.effectNames)) {
|
for (ArgumentedEffectName effectName : new ArrayList<>(this.effectNames)) {
|
||||||
if (Effects.getEffect(effectName.name(), effectName.args()) == null) {
|
if (Effects.getEffect(effectName.name(), effectName.args()) == null) {
|
||||||
this.effectNames.remove(effectName);
|
this.effectNames.remove(effectName);
|
||||||
Bukkit.getLogger().warning("Invalid effect " + effectName.name() + " specified in " + this.name);
|
Bukkit.getLogger().warning("Invalid effect " + effectName.name() + " specified in " + this.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,12 +580,12 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
new PlaceholderEntry(
|
new PlaceholderEntry(
|
||||||
"timeuntilspawn_"+this.name,
|
"timeuntilspawn_" + this.id,
|
||||||
(player) -> new BigDecimal(this.timeUntilSpawn / 20).setScale(1, RoundingMode.HALF_UP).toString(),
|
(player) -> new BigDecimal(this.timeUntilSpawn / 20).setScale(1, RoundingMode.HALF_UP).toString(),
|
||||||
false
|
false
|
||||||
).register();
|
).register();
|
||||||
|
|
||||||
for (String req : config.getStrings("spawn-requirements", false)) {
|
for (String req : config.getStrings("spawn-requirements")) {
|
||||||
List<String> split = Arrays.asList(req.split(":"));
|
List<String> split = Arrays.asList(req.split(":"));
|
||||||
if (split.size() < 2) {
|
if (split.size() < 2) {
|
||||||
continue;
|
continue;
|
||||||
@@ -608,7 +605,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
ItemBuilder builder = new ItemStackBuilder(material)
|
ItemBuilder builder = new ItemStackBuilder(material)
|
||||||
.setDisplayName(this.getConfig().getString("spawn-egg.name"))
|
.setDisplayName(this.getConfig().getString("spawn-egg.name"))
|
||||||
.addLoreLines(this.getConfig().getStrings("spawn-egg.lore"))
|
.addLoreLines(this.getConfig().getStrings("spawn-egg.lore"))
|
||||||
.writeMetaKey(this.getPlugin().getNamespacedKeyFactory().create("spawn_egg"), PersistentDataType.STRING, this.getName());
|
.writeMetaKey(this.getPlugin().getNamespacedKeyFactory().create("spawn_egg"), PersistentDataType.STRING, this.getId());
|
||||||
|
|
||||||
if (this.getConfig().getBool("spawn-egg.glow")) {
|
if (this.getConfig().getBool("spawn-egg.glow")) {
|
||||||
builder.addEnchantment(Enchantment.DURABILITY, 1)
|
builder.addEnchantment(Enchantment.DURABILITY, 1)
|
||||||
@@ -620,9 +617,9 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
if (this.getConfig().getBool("spawn-egg.craftable")) {
|
if (this.getConfig().getBool("spawn-egg.craftable")) {
|
||||||
Recipes.createAndRegisterRecipe(
|
Recipes.createAndRegisterRecipe(
|
||||||
this.getPlugin(),
|
this.getPlugin(),
|
||||||
"spawn_egg_" + this.getName(),
|
"spawn_egg_" + this.getId(),
|
||||||
this.getSpawnEgg(),
|
this.getSpawnEgg(),
|
||||||
this.getConfig().getStrings("spawn-egg.recipe", false)
|
this.getConfig().getStrings("spawn-egg.recipe")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -631,6 +628,17 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
|
|
||||||
if (this.getConfig().getBool("enabled")) {
|
if (this.getConfig().getBool("enabled")) {
|
||||||
EcoBosses.addBoss(this);
|
EcoBosses.addBoss(this);
|
||||||
|
|
||||||
|
new CustomEntity(
|
||||||
|
this.getPlugin().getNamespacedKeyFactory().create(this.id),
|
||||||
|
test -> {
|
||||||
|
if (!(test instanceof LivingEntity living)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Objects.equals(this, BossUtils.getBoss(living));
|
||||||
|
},
|
||||||
|
this::spawn
|
||||||
|
).register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -676,7 +684,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
|
|
||||||
ItemStack itemStack = Items.lookup(dropName).getItem();
|
ItemStack itemStack = Items.lookup(dropName).getItem();
|
||||||
if (itemStack.getType() == Material.AIR) {
|
if (itemStack.getType() == Material.AIR) {
|
||||||
Bukkit.getLogger().warning(this.getName() + " has an invalid drop configured! (" + dropName + ")");
|
Bukkit.getLogger().warning(this.getId() + " has an invalid drop configured! (" + dropName + ")");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,16 +715,17 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
*
|
*
|
||||||
* @param location The location.
|
* @param location The location.
|
||||||
*/
|
*/
|
||||||
public void spawn(@NotNull final Location location) {
|
public LivingEntity spawn(@NotNull final Location location) {
|
||||||
location.getChunk().load();
|
location.getChunk().load();
|
||||||
|
|
||||||
LivingEntity entity = bossType.spawnBossEntity(location);
|
LivingEntity entity = (LivingEntity) bossType.spawn(location);
|
||||||
this.livingBosses.put(entity, new LivingEcoBoss(
|
this.livingBosses.put(entity, new LivingEcoBoss(
|
||||||
this.getPlugin(),
|
this.getPlugin(),
|
||||||
entity,
|
entity,
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -757,18 +766,18 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getName().equals(boss.getName());
|
return this.getId().equals(boss.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(this.getName());
|
return Objects.hash(this.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "EcoBoss{"
|
return "EcoBoss{"
|
||||||
+ this.getName()
|
+ this.getId()
|
||||||
+ "}";
|
+ "}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ public class EcoBosses {
|
|||||||
* @param set The {@link EcoBoss} to add.
|
* @param set The {@link EcoBoss} to add.
|
||||||
*/
|
*/
|
||||||
public static void addBoss(@NotNull final EcoBoss set) {
|
public static void addBoss(@NotNull final EcoBoss set) {
|
||||||
BY_NAME.remove(set.getName());
|
BY_NAME.remove(set.getId());
|
||||||
BY_NAME.put(set.getName(), set);
|
BY_NAME.put(set.getId(), set);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,6 +99,6 @@ public class EcoBosses {
|
|||||||
* @param set The {@link EcoBoss} to remove.
|
* @param set The {@link EcoBoss} to remove.
|
||||||
*/
|
*/
|
||||||
public static void removeBoss(@NotNull final EcoBoss set) {
|
public static void removeBoss(@NotNull final EcoBoss set) {
|
||||||
BY_NAME.remove(set.getName());
|
BY_NAME.remove(set.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class LivingEcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onSpawn() {
|
private void onSpawn() {
|
||||||
entity.getPersistentDataContainer().set(this.getPlugin().getNamespacedKeyFactory().create("boss"), PersistentDataType.STRING, boss.getName());
|
entity.getPersistentDataContainer().set(this.getPlugin().getNamespacedKeyFactory().create("boss"), PersistentDataType.STRING, boss.getId());
|
||||||
entity.setPersistent(true);
|
entity.setPersistent(true);
|
||||||
entity.setRemoveWhenFarAway(false);
|
entity.setRemoveWhenFarAway(false);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.willfp.ecobosses.bosses.effects.effects;
|
package com.willfp.ecobosses.bosses.effects.effects;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.entities.Entities;
|
||||||
|
import com.willfp.eco.core.entities.TestableEntity;
|
||||||
import com.willfp.eco.util.NumberUtils;
|
import com.willfp.eco.util.NumberUtils;
|
||||||
import com.willfp.ecobosses.bosses.EcoBoss;
|
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||||
import com.willfp.ecobosses.bosses.effects.Effect;
|
import com.willfp.ecobosses.bosses.effects.Effect;
|
||||||
import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils;
|
|
||||||
import com.willfp.ecobosses.bosses.util.bosstype.BossType;
|
|
||||||
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -17,7 +17,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class EffectSummon extends Effect {
|
public class EffectSummon extends Effect {
|
||||||
private final BossType type;
|
private final TestableEntity type;
|
||||||
private final double chance;
|
private final double chance;
|
||||||
|
|
||||||
public EffectSummon(@NotNull final List<String> args) {
|
public EffectSummon(@NotNull final List<String> args) {
|
||||||
@@ -27,7 +27,7 @@ public class EffectSummon extends Effect {
|
|||||||
showConfigError("Incorrect amount of arguments!");
|
showConfigError("Incorrect amount of arguments!");
|
||||||
}
|
}
|
||||||
|
|
||||||
type = BossEntityUtils.getBossType(args.get(0));
|
type = Entities.lookup(args.get(0));
|
||||||
chance = Double.parseDouble(args.get(1));
|
chance = Double.parseDouble(args.get(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public class EffectSummon extends Effect {
|
|||||||
loc.add(0, 1, 0);
|
loc.add(0, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity summonedEntity = type.spawnBossEntity(loc);
|
Entity summonedEntity = type.spawn(loc);
|
||||||
if (summonedEntity instanceof Mob) {
|
if (summonedEntity instanceof Mob) {
|
||||||
((Mob) summonedEntity).setTarget(player);
|
((Mob) summonedEntity).setTarget(player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
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.Creeper;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Zombie;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class BossEntityUtils {
|
|
||||||
/**
|
|
||||||
* Get boss type.
|
|
||||||
*
|
|
||||||
* @param id The name.
|
|
||||||
* @return The boss type.
|
|
||||||
*/
|
|
||||||
public static BossType getBossType(@NotNull String id) {
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
MythicMob mob = MythicMobs.inst().getMobManager().getMythicMob(id.replace("mythicmobs:", "")
|
|
||||||
.replace("_" + level, ""));
|
|
||||||
|
|
||||||
if (mob != null) {
|
|
||||||
return new MythicMobsBossType(mob, level);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id.equalsIgnoreCase("charged_creeper")) {
|
|
||||||
return new ChargedCreeperBossType();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Class<? extends LivingEntity> type = (Class<? extends LivingEntity>) EntityType.valueOf(id.toUpperCase()).getEntityClass();
|
|
||||||
assert type != null;
|
|
||||||
return new VanillaBossType(type);
|
|
||||||
} catch (IllegalArgumentException ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return new VanillaBossType(Zombie.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.willfp.ecobosses.bosses.util.bosstype;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public abstract class BossType {
|
|
||||||
/**
|
|
||||||
* Spawn boss entity.
|
|
||||||
*
|
|
||||||
* @param location The location.
|
|
||||||
* @return The entity.
|
|
||||||
*/
|
|
||||||
public abstract LivingEntity spawnBossEntity(@NotNull Location location);
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.willfp.ecobosses.bosses.util.bosstype;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Creeper;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
class ChargedCreeperBossType extends VanillaBossType {
|
|
||||||
/**
|
|
||||||
* Create new Charged Creeper boss type.
|
|
||||||
*/
|
|
||||||
ChargedCreeperBossType() {
|
|
||||||
super(Creeper.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spawn a charged creeper.
|
|
||||||
*
|
|
||||||
* @param location The location.
|
|
||||||
* @return The entity.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public LivingEntity spawnBossEntity(@NotNull final Location location) {
|
|
||||||
Creeper creeper = Objects.requireNonNull(location.getWorld()).spawn(location, Creeper.class);
|
|
||||||
creeper.setPowered(true);
|
|
||||||
return creeper;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.willfp.ecobosses.bosses.util.bosstype;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Creeper;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
class VanillaBossType extends BossType {
|
|
||||||
/**
|
|
||||||
* The entity type.
|
|
||||||
*/
|
|
||||||
private final Class<? extends LivingEntity> entityClass;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create new vanilla boss type.
|
|
||||||
*
|
|
||||||
* @param entityClass The entity class.
|
|
||||||
*/
|
|
||||||
VanillaBossType(@NotNull final Class<? extends LivingEntity> entityClass) {
|
|
||||||
this.entityClass = entityClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LivingEntity spawnBossEntity(@NotNull final Location location) {
|
|
||||||
LivingEntity result = Objects.requireNonNull(location.getWorld()).spawn(location, entityClass);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -56,7 +56,7 @@ public class CommandGive extends Subcommand {
|
|||||||
BOSS_NAMES.clear();
|
BOSS_NAMES.clear();
|
||||||
BOSS_NAMES.addAll(EcoBosses.values().stream()
|
BOSS_NAMES.addAll(EcoBosses.values().stream()
|
||||||
.filter(boss -> boss.getSpawnEgg() != null)
|
.filter(boss -> boss.getSpawnEgg() != null)
|
||||||
.map(EcoBoss::getName)
|
.map(EcoBoss::getId)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ public class CommandGive extends Subcommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String message = this.getPlugin().getLangYml().getMessage("give-success");
|
String message = this.getPlugin().getLangYml().getMessage("give-success");
|
||||||
message = message.replace("%boss%", boss.getName()).replace("%recipient%", reciever.getName());
|
message = message.replace("%boss%", boss.getId()).replace("%recipient%", reciever.getName());
|
||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
|
|
||||||
ItemStack itemStack = boss.getSpawnEgg();
|
ItemStack itemStack = boss.getSpawnEgg();
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class CommandSpawn extends Subcommand {
|
|||||||
@ConfigUpdater
|
@ConfigUpdater
|
||||||
public static void reload() {
|
public static void reload() {
|
||||||
BOSS_NAMES.clear();
|
BOSS_NAMES.clear();
|
||||||
BOSS_NAMES.addAll(EcoBosses.values().stream().map(EcoBoss::getName).collect(Collectors.toList()));
|
BOSS_NAMES.addAll(EcoBosses.values().stream().map(EcoBoss::getId).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user