Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. public class onPlayerDeathEvent implements Listener{
  2.    
  3.     HashMap<Player, Long> shardsCooldown = new HashMap<Player, Long>();
  4.    
  5.     public void onPlayerDeath(PlayerDeathEvent e) {
  6.         Player p = e.getEntity().getKiller();
  7.        
  8.        
  9.         int cooldownShard = 3000; //5 minut w sekundach
  10.        
  11.         if(shardsCooldown.containsKey(p)) {
  12.             long secondsLeft = ((shardsCooldown.get(p)/1000) + cooldownShard)  - (System.currentTimeMillis()/1000);
  13.             if(secondsLeft>0) {
  14.                 p.sendMessage("Tutaj nie wypada shard");
  15.             }else {
  16.                 p.sendMessage("Tutaj wypada");
  17.                 shardsCooldown.put(p, System.currentTimeMillis());
  18.             }
  19.         }else {
  20.             p.sendMessage("Tutaj wypada");
  21.             shardsCooldown.put(p, System.currentTimeMillis());
  22.         }
  23.        
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement