From 40152b5dd93c87d9e25b52760fe93d4ae5fa500d Mon Sep 17 00:00:00 2001 From: Len <40720638+destro174@users.noreply.github.com> Date: Sat, 20 Jul 2024 17:08:31 +0200 Subject: [PATCH] Cherry pick: * Move to more maintainable `PotionEffectTypeCategory` for potion handling --- .../GriefPrevention/EntityEventHandler.java | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index 611f561..019724b 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -96,6 +96,7 @@ import org.bukkit.metadata.MetadataValue; import org.bukkit.persistence.PersistentDataType; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.bukkit.potion.PotionEffectTypeCategory; import org.bukkit.projectiles.BlockProjectileSource; import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; @@ -1456,7 +1457,7 @@ public class EntityEventHandler implements Listener if (thrower == null) return; //otherwise, no restrictions for positive effects - if (positiveEffects.contains(effectType)) continue; + if (effectType.getCategory() == PotionEffectTypeCategory.BENEFICIAL) continue; for (LivingEntity effected : event.getAffectedEntities()) { @@ -1577,22 +1578,4 @@ public class EntityEventHandler implements Listener } } - - public static final HashSet positiveEffects = new HashSet<>(Arrays.asList - ( - PotionEffectType.ABSORPTION, - PotionEffectType.RESISTANCE, - PotionEffectType.HASTE, - PotionEffectType.FIRE_RESISTANCE, - PotionEffectType.REGENERATION, - PotionEffectType.HEALTH_BOOST, - PotionEffectType.STRENGTH, - PotionEffectType.INVISIBILITY, - PotionEffectType.JUMP_BOOST, - PotionEffectType.NIGHT_VISION, - PotionEffectType.REGENERATION, - PotionEffectType.SATURATION, - PotionEffectType.SPEED, - PotionEffectType.WATER_BREATHING - )); }