Solved can not remove potion effects from players

Discussion in 'Plugin Development' started by King V, Oct 6, 2016.

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

    King V

    problem is pretty simple, i can not remove potion effects in anyway from a player. I have tried every way i can find on google :p no errors at all it doesnt do anything...
     
  2. @King V
    I can remove potion effects just fine using this:
    Code:java
    1. player.removePotionEffect(...)
     
  3. Offline

    King V

    code:

    Code:
                    for(PotionEffect effect : player.getActivePotionEffects())
                    {        
                      player.removePotionEffect(effect.getType());
                    }
     
  4. Offline

    Zombie_Striker

    @King V
    What version of Bukkit/spigot are you using? When are you calling these methods.
     
  5. Offline

    King V

    using latest snapshot version of spigot
    calling it in a damage event handler after checking if the player was hit by a shulker
     
  6. Offline

    Zombie_Striker

    @King V
    That is because the damage event is called before the entity is damaged, and as such, before the effect is applied. You have to delay this bit of code by one tick. Do this by using Delayed Tasks.
     
    King V likes this.
  7. Offline

    King V

    thanks! works now :D
     
Thread Status:
Not open for further replies.

Share This Page