Discussion in 'Plugin Development' started by flyingtacoz, Oct 13, 2012.
How would I go about making players invincible for 5 seconds after they teleport?
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.
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
1) player.setNoDamageTicks(5 * 20);
Me has less steps
Separate names with a comma.