Hey, I have a problem... I want after joining the server a greace period for the player, who joins. But this doesn't work: http://pastebin.com/cDn9QMc6 Thanks for your help"
@Skionz gave you the solution, and it is EntityDamageByEntityEvent Also in your code there is this: " tasks.remove(p.getName());" but the tasks map contains Player object as key not String object... soo that wouldnt work, Please have different names for variables instead of adding a number next to it like variabe1 and variable, this way you will avoid possible errors. And why are there 2 hashmaps? And last but not least, dont forget to handle player ojects apropriately to avoid ram leaks on world unloads.
@mythbusterma Storing Players has the potential for memory leaks. Storing UUIDs doesn't have the potential for memory leaks. It's all very well saying you'll be careful, but it's not like there's a downside to doing it the safe way.
@adam753 But there is, looking a Player up by UUID is an O(n) operation, looking up a Player by using the Player object reference? An O(1) operation.
@mythbusterma Now you're clutching at technicalities. Having your code run a nanosecond faster is no excuse for giving it to people who could end up with memory leaks because they don't understand the difference.
@adam753 It's not a nanosecond difference, and it's not a technicality, in an expensive operation that can mean many milliseconds.
@adam753 How can removing reference to an object cause memory leaks? You'll be going through the same amount of effort spreading awareness about using UUIDs and that of actually telling them to remove the Player when they leave.
Or you could just use a WeakHashMap and then you won't even need to think about removing the Players when they log out. Storing the Player's name or UUID instead of the Player object itself is actually the bad practice (if running CraftBukkit). CraftServer#getPlayer(UUID), CraftServer#getPlayer(String) and CraftServer#getPlayerExact(String) loop through ALL of the online Players, even if the said Player is not online. Storing OfflinePlayers is either not a valid choice (against Player) because sadly CraftOfflinePlayer#getPlayer() suffers from the same problem..