Keep Potion Effects on Death?

Discussion in 'Plugin Development' started by Polunom, Mar 21, 2013.

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

    Polunom

    How do you keep potion effects on death?
     
  2. Offline

    chasechocolate

    PlayerDeathEvent, save the player's potion effects to a HashMap<String, List<PotionEffect>>, and then listen for PlayerRespawnEvent, and loop through the HashMap's keys for the player and add them.
     
  3. Offline

    Polunom

    I saved it into the HashMap, how do I add the plugins to the player thru PlayerRespawnEvent? Do you mind providing me with some code? :3

    Bump.

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

    Polunom

    Bump. Help anyone?
     
  5. Offline

    macguy8

    Some pseudo code:

    public HashMap<String, List<PotionEffect>> effects = new HashMap<String, List<PotionEffect>>();

    onDeath:
    for (PotionEffect e : player.getPotionEffects()) {
    effects.get(player.getName()).add(e);
    }

    onRespawn:
    for (PotionEffect e : effects.get(player.getName()) {
    player.addPotionEffect(e);
    }
     
  6. Is it possible for someone to make a small easy plugin for this? Coding just really isn't forte! :(
     
  7. Offline

    macguy8

    dscrossland
    Sure. I'll whip it up in about 1/2 an hour
     
  8. macguy8
    If you could do that I would love it! Doesn't have to have commands or permissions, just really simple! I would be forever in your debt!! :D haha
     
  9. Offline

    macguy8

    dscrossland likes this.
  10. No problem! Thank you so much for putting the time and effort in!! :D
    I can't see any download link on the page though? Do I have to wait for it to be approved?
     
  11. Offline

    macguy8

    dscrossland
    Yeah. If you want it before it is approved (I can assure you there's no harmful code in it), just go to the "Files" tab
     
  12. macguy8
    I can't seem to find the files tab, is there any other option to get it? Don't worry I trust there's wrong with it!
     
  13. Offline

    macguy8

  14. macguy8
    It shows no files, probably due to it awaiting approval

    macguy8
    Is there any chance you could put it in a drop box or something along those lines, not sure how long it's going to take to get approved, might be a few days!

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

    jorisk322

    Usually < 12 hours.
     
  16. jorisk322
    It's taken about 27 hours so far following all the guidelines :/

    macguy8
    Got the plugin, works perfectly! Thanks a lot!!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page