Add Wolf armor equipper

This commit is contained in:
fullwall 2024-08-08 10:19:19 +08:00
parent c8f6e4f4ec
commit fe2a9990d3
2 changed files with 23 additions and 0 deletions

View File

@ -108,6 +108,7 @@ public class EquipmentEditor extends Editor {
EQUIPPER_GUIS.put(EntityType.ENDERMAN, EndermanEquipperGUI.class);
EQUIPPERS.put(EntityType.SHEEP, new SheepEquipper());
EQUIPPERS.put(EntityType.HORSE, new HorseEquipper());
EQUIPPERS.put(EntityType.WOLF, new WolfEquipper());
for (EntityType type : Util.optionalEntitySet("ZOMBIE_HORSE", "LLAMA", "TRADER_LLAMA", "DONKEY", "MULE",
"SKELETON_HORSE", "CAMEL")) {
EQUIPPERS.put(type, new HorseEquipper());

View File

@ -0,0 +1,22 @@
package net.citizensnpcs.editor;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.inventory.ItemStack;
import net.citizensnpcs.api.npc.NPC;
public class WolfEquipper implements Equipper {
@Override
public void equip(Player equipper, NPC toEquip) {
ItemStack hand = equipper.getInventory().getItemInHand();
Wolf wolf = (Wolf) toEquip.getEntity();
if (hand.getType().name().equals("WOLF_ARMOR")) {
ItemStack armor = hand.clone();
hand.setAmount(hand.getAmount() - 1);
armor.setAmount(1);
wolf.getEquipment().setChestplate(armor);
equipper.getInventory().setItemInHand(hand);
}
}
}