diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java index a84a89c..b6be417 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java @@ -20,6 +20,7 @@ import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils; import com.willfp.ecobosses.bosses.util.bosstype.BossType; import com.willfp.ecobosses.bosses.util.obj.ArgumentedEffectName; import com.willfp.ecobosses.bosses.util.obj.BossbarProperties; +import com.willfp.ecobosses.bosses.util.obj.EquipmentPiece; import com.willfp.ecobosses.bosses.util.obj.ExperienceOptions; import com.willfp.ecobosses.bosses.util.obj.ImmunityOptions; import com.willfp.ecobosses.bosses.util.obj.OptionedSound; @@ -39,6 +40,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.persistence.PersistentDataType; @@ -293,7 +295,7 @@ public class EcoBoss extends PluginDependent { private final ItemStack spawnEgg; /** - * All the requirements needed in order to use the enchantment. + * All the requirements needed in order to spawn the boss. */ private final Map> requirements = new HashMap<>(); @@ -302,6 +304,12 @@ public class EcoBoss extends PluginDependent { */ private final Map cachedRequirements = new HashMap<>(); + /** + * The equipment for the boss. + */ + @Getter + private final Map equipment = new HashMap<>(); + /** * Create a new Boss. * @@ -337,6 +345,60 @@ public class EcoBoss extends PluginDependent { this.movementSpeedMultiplier = this.getConfig().getInt("movement-speed"); this.timeToLive = this.getConfig().getInt("time-to-live", -1); + // Equipment + ItemStack helmet = Items.lookup(this.getConfig().getString("gear.helmet.item")).getItem(); + ItemStack chestplate = Items.lookup(this.getConfig().getString("gear.chestplate.item")).getItem(); + ItemStack leggings = Items.lookup(this.getConfig().getString("gear.leggings.item")).getItem(); + ItemStack boots = Items.lookup(this.getConfig().getString("gear.boots.item")).getItem(); + ItemStack hand = Items.lookup(this.getConfig().getString("gear.hand.item")).getItem(); + + if (helmet.getType() != Material.AIR) { + this.equipment.put( + EquipmentSlot.HEAD, + new EquipmentPiece( + helmet, + this.getConfig().getDouble("gear.helmet.chance") + ) + ); + } + if (chestplate.getType() != Material.AIR) { + this.equipment.put( + EquipmentSlot.CHEST, + new EquipmentPiece( + chestplate, + this.getConfig().getDouble("gear.chestplate.chance") + ) + ); + } + if (leggings.getType() != Material.AIR) { + this.equipment.put( + EquipmentSlot.LEGS, + new EquipmentPiece( + leggings, + this.getConfig().getDouble("gear.leggings.chance") + ) + ); + } + if (boots.getType() != Material.AIR) { + this.equipment.put( + EquipmentSlot.FEET, + new EquipmentPiece( + boots, + this.getConfig().getDouble("gear.boots.chance") + ) + ); + } + if (hand.getType() != Material.AIR) { + this.equipment.put( + EquipmentSlot.HAND, + new EquipmentPiece( + hand, + this.getConfig().getDouble("gear.hand.chance") + ) + ); + } + + // Spawn Totem this.spawnTotemEnabled = this.getConfig().getBool("spawn-totem.enabled"); this.spawnTotem = new SpawnTotem( diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java index d481371..4a9e41c 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java @@ -11,6 +11,7 @@ import com.willfp.ecobosses.bosses.tick.tickers.BossBarTicker; import com.willfp.ecobosses.bosses.tick.tickers.DeathTimeTicker; 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 lombok.Getter; import org.bukkit.Bukkit; @@ -20,6 +21,8 @@ import org.bukkit.attribute.AttributeModifier; import org.bukkit.boss.BarFlag; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.persistence.PersistentDataType; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -109,6 +112,35 @@ public class LivingEcoBoss extends PluginDependent { entity.setCustomName(boss.getDisplayName()); entity.setCustomNameVisible(true); + EntityEquipment equipment = entity.getEquipment(); + if (equipment != null) { + EquipmentPiece head = boss.getEquipment().get(EquipmentSlot.HEAD); + EquipmentPiece chest = boss.getEquipment().get(EquipmentSlot.CHEST); + EquipmentPiece legs = boss.getEquipment().get(EquipmentSlot.LEGS); + EquipmentPiece boots = boss.getEquipment().get(EquipmentSlot.FEET); + EquipmentPiece hand = boss.getEquipment().get(EquipmentSlot.HAND); + if (head != null) { + equipment.setHelmet(head.itemStack(), true); + equipment.setHelmetDropChance((float) head.chance()); + } + if (chest != null) { + equipment.setChestplate(chest.itemStack(), true); + equipment.setChestplateDropChance((float) chest.chance()); + } + if (legs != null) { + equipment.setLeggings(legs.itemStack(), true); + equipment.setLeggingsDropChance((float) legs.chance()); + } + if (boots != null) { + equipment.setBoots(boots.itemStack(), true); + equipment.setBootsDropChance((float) boots.chance()); + } + if (hand != null) { + equipment.setItemInMainHand(hand.itemStack(), true); + equipment.setItemInMainHandDropChance((float) hand.chance()); + } + } + AttributeInstance movementSpeed = entity.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED); assert movementSpeed != null; movementSpeed.addModifier(new AttributeModifier(entity.getUniqueId(), "ecobosses-movement-multiplier", boss.getMovementSpeedMultiplier() - 1, AttributeModifier.Operation.MULTIPLY_SCALAR_1)); diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/EquipmentPiece.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/EquipmentPiece.java new file mode 100644 index 0000000..798876b --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/EquipmentPiece.java @@ -0,0 +1,8 @@ +package com.willfp.ecobosses.bosses.util.obj; + +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public record EquipmentPiece(@NotNull ItemStack itemStack, + double chance) { +} diff --git a/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml b/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml index 6c40a06..ee39081 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml @@ -91,6 +91,23 @@ effects: - "give-potion-effect:wither:4:200:10" - "give-potion-effect:hunger:10:600:10" +gear: + helmet: + item: "" + chance: 100 + chestplate: + item: "" + chance: 100 + leggings: + item: "" + chance: 100 + boots: + item: "" + chance: 100 + hand: + item: "" + chance: 100 + defence: immunities: explosion: false diff --git a/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml b/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml index 49a14ad..9db16f3 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml @@ -94,6 +94,23 @@ effects: - "give-potion-effect:blindness:1:40:20" - "teleport:7:15" +gear: + helmet: + item: "" + chance: 100 + chestplate: + item: "" + chance: 100 + leggings: + item: "" + chance: 100 + boots: + item: "" + chance: 100 + hand: + item: "" + chance: 100 + defence: immunities: explosion: true diff --git a/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml b/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml index 8eee847..99bd570 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml @@ -95,6 +95,23 @@ effects: - "give-potion-effect:slow:5:100:20" - "give-potion-effect:levitation:3:50:10" +gear: + helmet: + item: "" + chance: 100 + chestplate: + item: "" + chance: 100 + leggings: + item: "" + chance: 100 + boots: + item: "" + chance: 100 + hand: + item: "" + chance: 100 + defence: immunities: explosion: true diff --git a/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml b/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml index ae4c3d4..e711c38 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml @@ -95,6 +95,23 @@ effects: - "give-potion-effect:hunger:5:400:10" - "give-potion-effect:slow_digging:3:40:10" +gear: + helmet: + item: "" + chance: 100 + chestplate: + item: "" + chance: 100 + leggings: + item: "" + chance: 100 + boots: + item: "" + chance: 100 + hand: + item: "" + chance: 100 + defence: immunities: explosion: false