mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-19 23:19:17 +00:00
Added option to set boss gear (armor / weapon)
This commit is contained in:
@@ -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<EcoPlugin> {
|
||||
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<Requirement, List<String>> requirements = new HashMap<>();
|
||||
|
||||
@@ -302,6 +304,12 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
||||
*/
|
||||
private final Map<UUID, Boolean> cachedRequirements = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The equipment for the boss.
|
||||
*/
|
||||
@Getter
|
||||
private final Map<EquipmentSlot, EquipmentPiece> equipment = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Create a new Boss.
|
||||
*
|
||||
@@ -337,6 +345,60 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
||||
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(
|
||||
|
||||
@@ -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<EcoPlugin> {
|
||||
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));
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user