Paper
Paper copied to clipboard
Fix potion effect overriding
Removed arbitrary restrictions in CraftAreaEffectCloud, CraftArrow and CraftMetaPotion that prevented adding multiple potion effects of the same type. There seems to be no such restriction in vanilla, and multiple effects of the same type do apply properly.
During testing, I noticed an issue introduced by the handling of EntityPotionEffectEvent that prevented some potion effects from properly applying, when compared to vanilla. I wasn't entirely sure of the best approach to fix this - as such, I tried sticking to the Javadoc description of EntityPotionEffectEvent#isOverride, where if override is true, the previous effect is entirely replaced. As such, a new effect hiding a previous effect is currently not considered "overriding", and EntityPotionEffectEvent#setOverride(true) force applies the new effect, removing the old effect.
Also includes a fix for MC-259832. There's a remaining issue with the /effect command improperly considering applying an effect with a lower amplifier, but longer duration as compared to the current effect, as failing to apply, but I'm unsure of how best to fix that. It only impacts messaging, so I did not attempt to fix it.
This changes some of the "add effect" methods that have a boolean return value to never return false. It feels like too much of an API break to make this change in methods where the expectation is something else. Perhaps new methods to take advantage of this functionality is better? smth like addCustomEffectWithMerge to clarify that it will "combine" effects utilizing the hidden effect functionality.