-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
None
-
Environment:
Java 21
-
1.20.5-R0.1-SNAPSHOT
-
Yes
AttributeModifier changed from storing a Nullable EquipmentSlot to a NotNull EquipmentSlotGroup at some point (I think with 1.20.5?), but there's a nullability flaw with the API implementation here.
- Instantiating AttributeModifier without an EquipmentSlotGroup or EquipmentSlot will invoke the fat constructor with `(EquipmentSlotGroup) null` - despite the EquipmentSlotGroup arg there being NotNull annotated [1]
- Since there's no Preconditions.checkArgument for passing null to this Notnull-annotated argument, the constructor works and instantiates an AttriuteModifier with slot as null
- This causes calls to the deprecated getSlot [2] method to throw NullPointerException, since that method tries to invoke getExample() on slot (which is null)
Suggested fix: Add a Preconditions check preventing slot from being passed as null and change the constructor call here to pass null to the other constructor which accepts an EquipmentSlot (which correctly converts EquipmentSlot to EquipmentSlotGroup in a ternary).
Thanks for your hard work.