7
7
import com .github .retrooper .packetevents .wrapper .play .server .WrapperPlayServerEntityEquipment ;
8
8
import me .tofaa .entitylib .EntityLib ;
9
9
import org .jetbrains .annotations .NotNull ;
10
+ import org .jetbrains .annotations .Nullable ;
10
11
11
12
import java .util .ArrayList ;
12
13
import java .util .Arrays ;
@@ -29,39 +30,38 @@ public WrapperEntityEquipment(WrapperLivingEntity entity) {
29
30
Arrays .fill (equipment , ItemStack .EMPTY );
30
31
}
31
32
32
- public void setHelmet (@ NotNull ItemStack itemStack ) {
33
- equipment [5 ] = itemStack ;
33
+ public void setHelmet (@ Nullable ItemStack itemStack ) {
34
+ equipment [5 ] = itemStack == null ? ItemStack . EMPTY : itemStack ;
34
35
refresh ();
35
36
}
36
37
37
- public void setChestplate (@ NotNull ItemStack itemStack ) {
38
- equipment [4 ] = itemStack ;
38
+ public void setChestplate (@ Nullable ItemStack itemStack ) {
39
+ equipment [4 ] = itemStack == null ? ItemStack . EMPTY : itemStack ;
39
40
refresh ();
40
41
}
41
42
42
- public void setLeggings (@ NotNull ItemStack itemStack ) {
43
- equipment [3 ] = itemStack ;
43
+ public void setLeggings (@ Nullable ItemStack itemStack ) {
44
+ equipment [3 ] = itemStack == null ? ItemStack . EMPTY : itemStack ;
44
45
refresh ();
45
46
}
46
47
47
- public void setBoots (@ NotNull ItemStack itemStack ) {
48
- equipment [2 ] = itemStack ;
48
+ public void setBoots (@ Nullable ItemStack itemStack ) {
49
+ equipment [2 ] = itemStack == null ? ItemStack . EMPTY : itemStack ;
49
50
refresh ();
50
51
}
51
52
52
- public void setMainHand (@ NotNull ItemStack itemStack ) {
53
- equipment [0 ] = itemStack ;
53
+ public void setMainHand (@ Nullable ItemStack itemStack ) {
54
+ equipment [0 ] = itemStack == null ? ItemStack . EMPTY : itemStack ;
54
55
refresh ();
55
56
}
56
57
57
- public void setOffhand (@ NotNull ItemStack itemStack ) {
58
- verifyVersion (ServerVersion .V_1_9 , "Offhand is only supported on 1.9+" );
59
- equipment [1 ] = itemStack ;
58
+ public void setOffhand (@ Nullable ItemStack itemStack ) {
59
+ equipment [1 ] = itemStack == null ? ItemStack .EMPTY : itemStack ;
60
60
refresh ();
61
61
}
62
62
63
- public void setItem (@ NotNull EquipmentSlot slot , @ NotNull ItemStack itemStack ) {
64
- equipment [slot .ordinal ()] = itemStack ;
63
+ public void setItem (@ NotNull EquipmentSlot slot , @ Nullable ItemStack itemStack ) {
64
+ equipment [slot .ordinal ()] = itemStack == null ? ItemStack . EMPTY : itemStack ;
65
65
refresh ();
66
66
}
67
67
@@ -102,7 +102,6 @@ public WrapperPlayServerEntityEquipment createPacket() {
102
102
List <Equipment > equipment = new ArrayList <>();
103
103
for (int i = 0 ; i < this .equipment .length ; i ++) {
104
104
ItemStack itemStack = this .equipment [i ];
105
- if (itemStack == null || itemStack .equals (ItemStack .EMPTY )) continue ;
106
105
equipment .add (new Equipment (EQUIPMENT_SLOTS [i ], itemStack ));
107
106
}
108
107
return new WrapperPlayServerEntityEquipment (
@@ -124,8 +123,6 @@ public boolean isNotifyingChanges() {
124
123
125
124
public void setNotifyChanges (boolean notifyChanges ) {
126
125
this .notifyChanges = notifyChanges ;
127
- if (notifyChanges ) {
128
- refresh ();
129
- }
126
+ refresh ();
130
127
}
131
128
}
0 commit comments