Do not call potion event if no active potion is present.

This commit is contained in:
IzzelAliz 2020-05-17 13:13:02 +08:00
parent 4179627a47
commit add3d5f5af

View File

@ -11,6 +11,9 @@ public class EntityPotionEffectEventDispatcher {
// todo 再检查一遍
@SubscribeEvent(receiveCanceled = true)
public void onPotionRemove(PotionEvent.PotionRemoveEvent event) {
if (event.getPotionEffect() == null) {
return;
}
EntityPotionEffectEvent.Cause cause = ((LivingEntityBridge) event.getEntityLiving()).bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN);
EntityPotionEffectEvent.Action action = ((LivingEntityBridge) event.getEntityLiving()).bridge$getAndResetAction();
EntityPotionEffectEvent bukkitEvent = CraftEventFactory.callEntityPotionEffectChangeEvent(event.getEntityLiving(), event.getPotionEffect(), null, cause, action);