diff --git a/src/main/java/ch/njol/skript/effects/EffEquip.java b/src/main/java/ch/njol/skript/effects/EffEquip.java index b0e0ba9b638..58fba0945a0 100644 --- a/src/main/java/ch/njol/skript/effects/EffEquip.java +++ b/src/main/java/ch/njol/skript/effects/EffEquip.java @@ -12,6 +12,7 @@ import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.util.Kleenean; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.entity.AbstractHorse; @@ -19,7 +20,6 @@ import org.bukkit.entity.Horse; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Llama; -import org.bukkit.entity.Pig; import org.bukkit.entity.Player; import org.bukkit.entity.Steerable; import org.bukkit.entity.Wolf; @@ -81,8 +81,6 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye return true; } - private static final boolean SUPPORTS_STEERABLE = Skript.classExists("org.bukkit.entity.Steerable"); - private static ItemType CHESTPLATE; private static ItemType LEGGINGS; private static ItemType BOOTS; @@ -152,19 +150,12 @@ protected void execute(Event event) { unequipHelmet = true; } for (LivingEntity entity : entities.getArray(event)) { - if (SUPPORTS_STEERABLE && entity instanceof Steerable steerable) { + if (entity instanceof Steerable steerable) { for (ItemType itemType : itemTypes) { if (SADDLE.isOfType(itemType.getMaterial())) { steerable.setSaddle(equip); } } - } else if (entity instanceof Pig pig) { - for (ItemType itemType : itemTypes) { - if (itemType.isOfType(Material.SADDLE)) { - pig.setSaddle(equip); - break; - } - } } else if (entity instanceof Llama llama) { LlamaInventory inv = llama.getInventory(); for (ItemType itemType : itemTypes) { diff --git a/src/test/skript/tests/syntaxes/effects/EffEquip.sk b/src/test/skript/tests/syntaxes/effects/EffEquip.sk index db44f7afcec..5c34ca80df1 100644 --- a/src/test/skript/tests/syntaxes/effects/EffEquip.sk +++ b/src/test/skript/tests/syntaxes/effects/EffEquip.sk @@ -1,11 +1,19 @@ test "equip effect": + + # === ARMOUR === + spawn a zombie at (spawn of world "world"): set {_z} to entity - assert helmet of {_z} is air with "a normally spawned zombie shouldn't be wearing a helmet" - assert chestplate of {_z} is air with "a normally spawned zombie shouldn't be wearing a chestplate" - assert leggings of {_z} is air with "a normally spawned zombie shouldn't be wearing leggings" - assert boots of {_z} is air with "a normally spawned zombie shouldn't be wearing boots" + clear helmet of {_z} + clear chestplate of {_z} + clear leggings of {_z} + clear boots of {_z} + + assert helmet of {_z} is air with "the modified zombie shouldn't be wearing a helmet" + assert chestplate of {_z} is air with "the modified zombie shouldn't be wearing a chestplate" + assert leggings of {_z} is air with "the modified zombie shouldn't be wearing leggings" + assert boots of {_z} is air with "the modified zombie shouldn't be wearing boots" equip {_z} with iron helmet equip {_z} with diamond chestplate @@ -22,19 +30,32 @@ test "equip effect": assert leggings of {_z} is air with "unequipping an entity should remove its armour" assert boots of {_z} is air with "unequipping an entity should remove its armour" + # === SADDLES === + spawn a horse at (spawn of world "world"): set {_h} to entity spawn a pig at (spawn of world "world"): set {_p} to entity + assert {_h} and {_p} don't have saddles with "normally spawned horses and pigs should not have saddles" + equip {_h} and {_p} with saddle - # not sure how to assert here that the horse and pig are equipped with a saddle, or that they didnt spawn with one + assert {_h} and {_p} have saddles with "equipping a horse or pig with a saddle should do exactly that" + + 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" delete entity within {_z} delete entity within {_h}