Solved Getting A Player's Current Potion Effects

Discussion in 'Plugin Development' started by mythcaptor, Dec 24, 2012.

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

    mythcaptor

    I'm trying to add a permanent potion effect to players when they enter a region. Thats obviously fairly easy, but the issue that I've encountered is that when I strip that potion effect from them as they leave, they also lose any remaining duration of the effect if they had it before they entered.

    Just in case that's confusing, heres an example:
    •Player has 2 minutes left of Speed from a potion they drank.
    •They enter region getting a permanent speed buff while they're in region.
    •They leave region, and are stripped of all speed buffs, including the one that they had before entering.

    So what I need help with is getting an array/list/whatever of a players current buffs. The player object doesn't seem to have a getPotionEffects() method, and I'm flummoxed on how to go about returning any buffs the player had on entering to them, when they leave.

    I'm aware of p.hasPotionEffect, but that doesn't give any way of actually obtaining the PotionEffect, which I need so that I can get the magnitude, time remaining, etc.

    Any help would be appreciated! Thanks!
     
  2. Offline

    drampelt

    player.getActivePotionEffects() returns a Collection of PotionEffects.
     
  3. Offline

    mythcaptor

    Ah, fantastic, I feel stupid for not finding that on my own! Thanks and Happy Holidays!
     
Thread Status:
Not open for further replies.

Share This Page