-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
None
Currently PotionAffectType.values() contains 'null' at index 0, because https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/potion/PotionEffectType.java#205 holding the potion effect types is initialized with a length of 24, and is used to directly map array index to the potion effect type. However, because there is no potion effect type with id 0, the array will contain null at that index.
This might be inconvenient / unexpected for plugins using PotionEffectType.values() (for example to iterate over all potion effect types), because they expect behavior similar to that of Enum.values() (which does not contain null) and plugins will then have to be aware of this and check for this special case.
Maybe it might be preferable to initialize the array with a length of 23 and map the potion effects to id-1 internally.
Or let values() return a sub-array starting at index 1.