1
1
package ch .njol .skript .effects ;
2
2
3
3
import ch .njol .skript .Skript ;
4
- import ch .njol .skript .aliases .ItemData ;
5
4
import ch .njol .skript .aliases .ItemType ;
6
5
import ch .njol .skript .bukkitutil .PlayerUtils ;
7
6
import ch .njol .skript .doc .Description ;
19
18
import org .bukkit .entity .Horse ;
20
19
import org .bukkit .entity .LivingEntity ;
21
20
import org .bukkit .entity .Llama ;
21
+ import org .bukkit .entity .Mob ;
22
22
import org .bukkit .entity .Player ;
23
23
import org .bukkit .entity .Steerable ;
24
24
import org .bukkit .entity .Wolf ;
43
43
"unequip diamond chestplate from player" ,
44
44
"unequip player's armor"
45
45
})
46
- @ Since ("1.0, 2.7 (multiple entities, unequip), 2.10 (wolves)" )
46
+ @ Since ({
47
+ "1.0, 2.7 (multiple entities, unequip), 2.10 (wolves)" ,
48
+ "INSERT VERSION (happy ghasts)"
49
+ })
47
50
public class EffEquip extends Effect {
48
51
49
- private static ItemType CHESTPLATE ;
50
- private static ItemType LEGGINGS ;
51
- private static ItemType BOOTS ;
52
- private static ItemType CARPET = new ItemType (Tag .WOOL_CARPETS );
53
- private static ItemType WOLF_ARMOR ;
52
+ private static final ItemType CHESTPLATE ;
53
+ private static final ItemType LEGGINGS ;
54
+ private static final ItemType BOOTS ;
55
+ private static final ItemType CARPET = new ItemType (Tag .WOOL_CARPETS );
56
+ private static final ItemType WOLF_ARMOR ;
54
57
private static final ItemType HORSE_ARMOR = new ItemType (Material .LEATHER_HORSE_ARMOR , Material .IRON_HORSE_ARMOR , Material .GOLDEN_HORSE_ARMOR , Material .DIAMOND_HORSE_ARMOR );
55
58
private static final ItemType SADDLE = new ItemType (Material .SADDLE );
56
59
private static final ItemType CHEST = new ItemType (Material .CHEST );
60
+ private static final ItemType HAPPY_GHAST_HARNESS ;
61
+
62
+ private static final Class <?> HAPPY_GHAST_CLASS ;
57
63
58
64
static {
59
- boolean hasWolfArmor = Skript .fieldExists (Material .class , "WOLF_ARMOR" );
60
- WOLF_ARMOR = hasWolfArmor ? new ItemType (Material .WOLF_ARMOR ) : new ItemType ();
65
+ // added in 1.20.5
66
+ if (Skript .fieldExists (Material .class , "WOLF_ARMOR" )) {
67
+ WOLF_ARMOR = new ItemType (Material .WOLF_ARMOR );
68
+ } else {
69
+ WOLF_ARMOR = new ItemType ();
70
+ }
61
71
62
72
// added in 1.20.6
63
73
if (Skript .fieldExists (Tag .class , "ITEM_CHEST_ARMOR" )) {
@@ -71,7 +81,7 @@ public class EffEquip extends Effect {
71
81
Material .GOLDEN_CHESTPLATE ,
72
82
Material .IRON_CHESTPLATE ,
73
83
Material .DIAMOND_CHESTPLATE ,
74
- Material .NETHERITE_CHESTPLATE ,
84
+ Material .NETHERITE_CHESTPLATE ,
75
85
Material .ELYTRA
76
86
);
77
87
@@ -81,7 +91,7 @@ public class EffEquip extends Effect {
81
91
Material .GOLDEN_LEGGINGS ,
82
92
Material .IRON_LEGGINGS ,
83
93
Material .DIAMOND_LEGGINGS ,
84
- Material .NETHERITE_LEGGINGS
94
+ Material .NETHERITE_LEGGINGS
85
95
);
86
96
87
97
BOOTS = new ItemType (
@@ -90,12 +100,25 @@ public class EffEquip extends Effect {
90
100
Material .GOLDEN_BOOTS ,
91
101
Material .IRON_BOOTS ,
92
102
Material .DIAMOND_BOOTS ,
93
- Material .NETHERITE_BOOTS
103
+ Material .NETHERITE_BOOTS
94
104
);
95
105
}
106
+
107
+ // added in 1.21.6
108
+ if (Skript .fieldExists (Tag .class , "ITEMS_HARNESSES" )) {
109
+ HAPPY_GHAST_HARNESS = new ItemType (Tag .ITEMS_HARNESSES );
110
+ try {
111
+ HAPPY_GHAST_CLASS = Class .forName ("org.bukkit.entity.HappyGhast" );
112
+ } catch (ClassNotFoundException e ) {
113
+ throw new RuntimeException (e );
114
+ }
115
+ } else {
116
+ HAPPY_GHAST_HARNESS = new ItemType ();
117
+ HAPPY_GHAST_CLASS = null ;
118
+ }
96
119
}
97
120
98
- private static final ItemType [] ALL_EQUIPMENT = new ItemType [] {CHESTPLATE , LEGGINGS , BOOTS , HORSE_ARMOR , SADDLE , CHEST , CARPET , WOLF_ARMOR };
121
+ private static final ItemType [] ALL_EQUIPMENT = new ItemType [] {CHESTPLATE , LEGGINGS , BOOTS , HORSE_ARMOR , SADDLE , CHEST , CARPET , WOLF_ARMOR , HAPPY_GHAST_HARNESS };
99
122
100
123
static {
101
124
Skript .registerEffect (EffEquip .class ,
@@ -177,6 +200,14 @@ protected void execute(Event event) {
177
200
equipment .setItem (EquipmentSlot .BODY , equip ? item : null );
178
201
}
179
202
}
203
+ } else if (HAPPY_GHAST_CLASS != null && HAPPY_GHAST_CLASS .isInstance (entity )) {
204
+ EntityEquipment equipment = ((Mob ) entity ).getEquipment ();
205
+ for (ItemType itemType : itemTypes ) {
206
+ for (ItemStack itemStack : itemType .getAll ()) {
207
+ if (HAPPY_GHAST_HARNESS .isOfType (itemStack ))
208
+ equipment .setItem (EquipmentSlot .BODY , equip ? itemStack : null );
209
+ }
210
+ }
180
211
} else {
181
212
EntityEquipment equipment = entity .getEquipment ();
182
213
if (equipment == null )
0 commit comments