3
3
import java .lang .reflect .Constructor ;
4
4
import java .util .*;
5
5
import javax .annotation .Nonnull ;
6
+ import javax .annotation .Nullable ;
6
7
7
8
import com .comphenix .protocol .PacketType ;
8
9
import com .comphenix .protocol .events .PacketContainer ;
9
10
import com .comphenix .protocol .reflect .FuzzyReflection ;
10
11
import com .comphenix .protocol .reflect .StructureModifier ;
11
- import com .comphenix .protocol .reflect .accessors .Accessors ;
12
- import com .comphenix .protocol .reflect .accessors .MethodAccessor ;
13
- import com .comphenix .protocol .reflect .fuzzy .FuzzyFieldContract ;
14
12
import com .comphenix .protocol .reflect .fuzzy .FuzzyMethodContract ;
15
13
import com .comphenix .protocol .utility .MinecraftReflection ;
16
14
import com .comphenix .protocol .utility .MinecraftVersion ;
@@ -35,9 +33,6 @@ public class WrappedAttribute extends AbstractWrapper {
35
33
// The one constructor
36
34
private static Constructor <?> ATTRIBUTE_CONSTRUCTOR ;
37
35
38
- private static Object REGISTRY = null ;
39
- private static MethodAccessor REGISTRY_GET = null ;
40
-
41
36
private static final Map <String , String > REMAP ;
42
37
43
38
static {
@@ -77,7 +72,7 @@ private WrappedAttribute(@Nonnull Object handle) {
77
72
78
73
// Initialize modifier
79
74
if (ATTRIBUTE_MODIFIER == null ) {
80
- ATTRIBUTE_MODIFIER = new StructureModifier <Object >(MinecraftReflection .getAttributeSnapshotClass ());
75
+ ATTRIBUTE_MODIFIER = new StructureModifier <>(MinecraftReflection .getAttributeSnapshotClass ());
81
76
}
82
77
this .modifier = ATTRIBUTE_MODIFIER .withTarget (handle );
83
78
}
@@ -170,8 +165,14 @@ public double getFinalValue() {
170
165
/**
171
166
* Retrieve the parent update attributes packet.
172
167
* @return The parent packet.
168
+ * @deprecated Removed in 1.17
173
169
*/
170
+ @ Nullable
174
171
public PacketContainer getParentPacket () {
172
+ if (MinecraftVersion .CAVES_CLIFFS_1 .atOrAbove ()) {
173
+ return null ;
174
+ }
175
+
175
176
return new PacketContainer (
176
177
PacketType .Play .Server .UPDATE_ATTRIBUTES ,
177
178
modifier .withType (MinecraftReflection .getPacketClass ()).read (0 )
@@ -226,7 +227,7 @@ protected WrappedAttributeModifier toOuter(Object inner) {
226
227
}
227
228
};
228
229
229
- attributeModifiers = new CachedSet <WrappedAttributeModifier >(converted );
230
+ attributeModifiers = new CachedSet <>(converted );
230
231
}
231
232
return Collections .unmodifiableSet (attributeModifiers );
232
233
}
@@ -249,9 +250,7 @@ public boolean equals(Object obj) {
249
250
250
251
if (getBaseValue () == other .getBaseValue () &&
251
252
Objects .equal (getAttributeKey (), other .getAttributeKey ())) {
252
- return getModifiers ().stream ()
253
- .filter ((elem ) -> !other .getModifiers ().contains (elem ))
254
- .count () == 0 ;
253
+ return other .getModifiers ().containsAll (getModifiers ());
255
254
}
256
255
}
257
256
return false ;
@@ -414,7 +413,6 @@ private Set<Object> getUnwrappedModifiers() {
414
413
* @throws RuntimeException If anything went wrong with the reflection.
415
414
*/
416
415
public WrappedAttribute build () {
417
- Preconditions .checkNotNull (packet , "packet cannot be NULL." );
418
416
Preconditions .checkNotNull (attributeKey , "attributeKey cannot be NULL." );
419
417
420
418
// Remember to set the base value
0 commit comments