Solved Clear mob poition effect with bukkit / spigot

Discussion in 'Plugin Development' started by Rebitl, Apr 4, 2024.

Thread Status:
Not open for further replies.
  1. Offline

    Rebitl

    Hello!
    I'm trying to clear the effect of a potion from a mob (entity) through code, however, removePotionEffect only works on the player class.
    Please tell me how can I implement this?


    Code:
    import org.bukkit.entity.LivingEntity;
    
    @EventHandler
    public void onProjectileHit(ProjectileHitEvent event) {
        if (event.getHitEntity() != null) {
            Entity entity = (Entity) event.getHitEntity();
            entity.removePotionEffect(PotionEffectType.GLOWING);
        }
    }
    removePotionEffect - lights up red and I can't do anything about it, because it's waiting for the Player class, not the entity. This is logical, however, I need to remove the effect of the mob, not the player.
     
  2. Offline

    timtower Administrator Administrator Moderator

    Rebitl likes this.
  3. Offline

    Rebitl

    Thanks, it worked! I really should have just defined "entity" as "LivingEntity".
     
  4. Offline

    timtower Administrator Administrator Moderator

    Might want to consider checking if it is a LivingEntity first btw.
     
    Rebitl likes this.
Thread Status:
Not open for further replies.

Share This Page