diff --git a/src/main/java/ch/njol/skript/conditions/CondIsWearing.java b/src/main/java/ch/njol/skript/conditions/CondIsWearing.java index 3b43620b6f6..df36355bc48 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsWearing.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsWearing.java @@ -14,9 +14,13 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.event.Event; import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.eclipse.jdt.annotation.Nullable; +import java.util.Arrays; +import java.util.stream.Stream; + /** * @author Peter Güttinger */ @@ -56,8 +60,12 @@ public boolean check(Event event) { EntityEquipment equip = entity.getEquipment(); if (equip == null) return false; // No equipment -> not wearing anything - for (ItemStack armorContent : equip.getArmorContents()) { - if (type.isOfType(armorContent) ^ type.isAll()) + + ItemStack[] contents = Arrays.copyOf(equip.getArmorContents(), equip.getArmorContents().length + 1); + contents[contents.length - 1] = equip.getItem(EquipmentSlot.BODY); + + for (ItemStack content : contents) { + if (type.isOfType(content) ^ type.isAll()) return !type.isAll(); } return type.isAll(); diff --git a/src/test/skript/tests/syntaxes/effects/EffEquip.sk b/src/test/skript/tests/syntaxes/effects/EffEquip.sk index 5c34ca80df1..fa914e28493 100644 --- a/src/test/skript/tests/syntaxes/effects/EffEquip.sk +++ b/src/test/skript/tests/syntaxes/effects/EffEquip.sk @@ -45,19 +45,21 @@ test "equip effect": unequip saddle from {_h} and {_p} assert {_h} and {_p} don't have saddles with "unequipping a saddle from a horse or pig should do exactly that" - # === WOLF ARMOUR === - - parse if running minecraft "1.20.5": - spawn a wolf at (spawn of world "world"): - set {_w} to entity - - equip {_w} with wolf armor - assert {_w} is wearing wolf armor with "equipping a wolf with wolf armor should do exactly that" - - unequip wolf armor from {_w} - assert {_w} is not wearing wolf armor with "unequipping wolf armor from a wolf should do exactly that" + # === CLEANUP === delete entity within {_z} delete entity within {_h} delete entity within {_p} + +test "equip - wolf armor" when running minecraft "1.20.5": + + spawn a wolf at (spawn of world "world"): + set {_w} to entity + + equip {_w} with wolf armor + assert {_w} is wearing wolf armor with "equipping a wolf with wolf armor should do exactly that" + + unequip wolf armor from {_w} + assert {_w} is not wearing wolf armor with "unequipping wolf armor from a wolf should do exactly that" + delete entity within {_w}