Add invincibility for 5 seconds after teleport

Discussion in 'Plugin Development' started by flyingtacoz, Oct 13, 2012.

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

    flyingtacoz

    How would I go about making players invincible for 5 seconds after they teleport?
     
  2. Offline

    Pandemoneus

    Well, upon teleporting you put them into a list. While they are in it, you cancel all damage events that target them. Finally, after 5 seconds, you remove them from said list.
     
  3. Offline

    hakelimopu

    1) HashMap<String,Date> which you add a date+5 seconds to when the player TPs (i.e. during a PlayerTeleportEvent)
    2) When a player takes damage(during an EntityDamageEvent), check for an entry in the HashMap
    3) if there is an entry, and the time has not elapsed, prevent damage
    4) if there is an entry, and the time has elapse,remove entry from HashMap, and allow damage
    5) if there is no entry, allow damage
     
  4. Offline

    Bone008

    1) player.setNoDamageTicks(5 * 20);
    2) ???
    3) Profit!

    Me has less steps ;)
     
    ferrybig and hakelimopu like this.
  5. Offline

    flyingtacoz

    works, thanks! :)
     
Thread Status:
Not open for further replies.

Share This Page