[SPIGOT-7674] PotionEffectType.getByName returns null for several PotionEffectType#getName values Created: 28/May/24 Updated: 25/Dec/24 Resolved: 29/May/24 |
|
Status: | Closed |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | William278 | Assignee: | Unassigned |
Resolution: | Cannot Reproduce | Votes: | 0 |
Labels: | potioneffect | ||
Environment: |
Spigot 1.20.6 / JDK 21 |
Version: | 1.20.6 |
Guidelines Read: | Yes |
Description |
PotionEffectType#getName(), which has been deprecated since the move to registries returns the old API name of the effect type for potion effects with IDs 1-33. However, the counterpart static method PotionEffectType.getByName() - also deprecated - performs lookup against the EFFECT Registry and will return null for PotionEffectType#getName() values where the old API name differs from the registry key value. This breaks backwards compatibility with plugins saving potion effect types by name. For example, PotionEffectType.HASTE#getName() returns "FAST_DIGGING" (as per impl) - but PotionEffectType.getByName("FAST_DIGGING") returns null, because "haste" is the expected registry name. Suggested solution would either be to have getName() return the key value name for IDs 1-33 (may introduce breakages) or have getByName() support legacy lookup (it's deprecated anyway, so may be better for back-compat) |
Comments |
Comment by Marvin Rieple [ 29/May/24 ] |
Cannot reproduce with the following code: @Override public void onEnable() { System.out.println(PotionEffectType.getByName("FAST_DIGGING")); } This will return: CraftPotionEffectType[minecraft:haste], which is correct.
Note that bukkit supports old names via this class. Please provide a minimal test plugin, which can reproduce the error. |