Skip to content

Commit 5512583

Browse files
Efnilitesovdeeth
andauthored
Fix leather horse armor being unequipable (SkriptLang#7141)
* init commit * oops * update * update ver * fix paper * hmm * yeah ok * oops * biggera oops * dont run tests on 1.20.6 * requested changes * tabs --------- Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
1 parent 8c91cc8 commit 5512583

File tree

2 files changed

+42
-45
lines changed

2 files changed

+42
-45
lines changed

src/main/java/ch/njol/skript/effects/EffEquip.java

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,7 @@
1-
/**
2-
* This file is part of Skript.
3-
*
4-
* Skript is free software: you can redistribute it and/or modify
5-
* it under the terms of the GNU General Public License as published by
6-
* the Free Software Foundation, either version 3 of the License, or
7-
* (at your option) any later version.
8-
*
9-
* Skript is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
* GNU General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with Skript. If not, see <http://www.gnu.org/licenses/>.
16-
*
17-
* Copyright Peter Güttinger, SkriptLang team and contributors
18-
*/
191
package ch.njol.skript.effects;
202

21-
import ch.njol.skript.aliases.ItemData;
22-
import org.bukkit.Material;
23-
import org.bukkit.Tag;
24-
import org.bukkit.entity.AbstractHorse;
25-
import org.bukkit.entity.ChestedHorse;
26-
import org.bukkit.entity.LivingEntity;
27-
import org.bukkit.entity.Llama;
28-
import org.bukkit.entity.Pig;
29-
import org.bukkit.entity.Player;
30-
import org.bukkit.entity.Steerable;
31-
import org.bukkit.event.Event;
32-
import org.bukkit.inventory.EntityEquipment;
33-
import org.bukkit.inventory.Inventory;
34-
import org.bukkit.inventory.ItemStack;
35-
import org.bukkit.inventory.LlamaInventory;
36-
import org.jetbrains.annotations.Nullable;
37-
383
import ch.njol.skript.Skript;
39-
import ch.njol.skript.aliases.Aliases;
4+
import ch.njol.skript.aliases.ItemData;
405
import ch.njol.skript.aliases.ItemType;
416
import ch.njol.skript.bukkitutil.PlayerUtils;
427
import ch.njol.skript.doc.Description;
@@ -47,26 +12,47 @@
4712
import ch.njol.skript.lang.Expression;
4813
import ch.njol.skript.lang.SkriptParser.ParseResult;
4914
import ch.njol.util.Kleenean;
15+
import org.bukkit.Material;
16+
import org.bukkit.Tag;
17+
import org.bukkit.entity.*;
18+
import org.bukkit.event.Event;
19+
import org.bukkit.inventory.EntityEquipment;
20+
import org.bukkit.inventory.Inventory;
21+
import org.bukkit.inventory.ItemStack;
22+
import org.bukkit.inventory.LlamaInventory;
23+
import org.jetbrains.annotations.Nullable;
5024

5125
@Name("Equip")
52-
@Description("Equips or unequips an entity with some given armor. This will replace any armor that the entity is wearing.")
26+
@Description(
27+
"Equips or unequips an entity with some given armor. " +
28+
"This will replace any armor that the entity is wearing."
29+
)
5330
@Examples({
54-
"equip player with diamond helmet",
55-
"equip player with all diamond armor",
56-
"unequip diamond chestplate from player",
57-
"unequip all armor from player",
58-
"unequip player's armor"
31+
"equip player with diamond helmet",
32+
"equip player with all diamond armor",
33+
"unequip diamond chestplate from player",
34+
"unequip all armor from player",
35+
"unequip player's armor"
5936
})
6037
@Since("1.0, 2.7 (multiple entities, unequip)")
6138
public class EffEquip extends Effect {
6239

40+
private static final ItemType HORSE_ARMOR;
41+
6342
static {
43+
if (Skript.isRunningMinecraft(1, 14)) {
44+
HORSE_ARMOR = new ItemType(Material.IRON_HORSE_ARMOR, Material.GOLDEN_HORSE_ARMOR,
45+
Material.DIAMOND_HORSE_ARMOR, Material.LEATHER_HORSE_ARMOR);
46+
} else {
47+
HORSE_ARMOR = new ItemType(Material.IRON_HORSE_ARMOR, Material.GOLDEN_HORSE_ARMOR,
48+
Material.DIAMOND_HORSE_ARMOR);
49+
}
50+
6451
Skript.registerEffect(EffEquip.class,
6552
"equip [%livingentities%] with %itemtypes%",
6653
"make %livingentities% wear %itemtypes%",
6754
"unequip %itemtypes% [from %livingentities%]",
68-
"unequip %livingentities%'[s] (armor|equipment)"
69-
);
55+
"unequip %livingentities%'[s] (armo[u]r|equipment)");
7056
}
7157

7258
@SuppressWarnings("NotNullFieldNotInitialized")
@@ -99,7 +85,6 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
9985
private static ItemType LEGGINGS;
10086
private static ItemType BOOTS;
10187
private static ItemType CARPET;
102-
private static final ItemType HORSE_ARMOR = new ItemType(Material.IRON_HORSE_ARMOR, Material.GOLDEN_HORSE_ARMOR, Material.DIAMOND_HORSE_ARMOR);
10388
private static final ItemType SADDLE = new ItemType(Material.SADDLE);
10489
private static final ItemType CHEST = new ItemType(Material.CHEST);
10590

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
test "leather horse armor unequipable" when running minecraft "1.14":
2+
if minecraft version is "1.20.6":
3+
stop # horse armor equipping is broken on Paper 1.20.6. see https://github.com/PaperMC/Paper/pull/11139
4+
5+
spawn horse at spawn of world "world":
6+
set {_h} to entity
7+
8+
equip {_h} with leather horse armor
9+
10+
assert {_h} has leather horse armor with "horse doesn't have horse armor"
11+
12+
delete entity within {_h}

0 commit comments

Comments
 (0)