Can't remove potion effects?

Discussion in 'Plugin Development' started by Taco, May 4, 2012.

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

    Taco

    It seems either I'm missing something, or the removePotionEffects method is broken. Here's my code:

    Code:
                Iterator<PotionEffect> i = p.getActivePotionEffects().iterator();
                while(i.hasNext())
                {
                    p.removePotionEffect(i.next().getType());
                }
    I hope someone can provide some insight on what's wrong with it.
     
  2. Offline

    Komak57

    might I suggest
    player.getActivePotionEffects().clear()
    instead?
     
  3. Offline

    Taco

    I tried that. No dice.
     
  4. Offline

    Komak57

    Perhaps there's an error with your handler? Which event is handling this? That or make sure it's activating by putting a log.info("Potion Effects removed!"); after the line?
     
  5. Offline

    Taco

    It's being thrown via a method from an onFoodLevelChangeEvent. I can tell the method is being fired because I've already thrown some similar debug code in there. The iterator has all the active effects correct, but it refuses to remove them.
     
  6. Offline

    Komak57

    After running the code in my own template using a command handler, the function WORKS, it just doesn't remove the visual effect?

    In fact, the code will stop the count-down for the visual effect permanently >_> 30 minutes later and Strength II is STILL bubbling >_>

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  7. Offline

    kumpelblase2

    Code:
    p.addPotionEffect(new PotionEffect(i.next().getType(), 0, 0), true);
     
  8. Offline

    ItsHarry

    It's client sided, if you try relogging it will be gone.
     
  9. Offline

    Taco

    Oh, thank you. I guess I'll just kick the player with a message about the potion effects being removed. Thanks!
     
  10. Offline

    ItsHarry

    No problem :)
     
Thread Status:
Not open for further replies.

Share This Page