Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. public static HashMap<UUID, Double> cooldown;
  2.  
  3. public static void setupCooldown() {
  4. cooldown = new HashMap<>();
  5. }
  6.  
  7. public static void setCooldown(Player p, int seconds) {
  8. double delay = System.currentTimeMillis() + (seconds*1000);
  9. cooldown.put(p.getUniqueId(), delay);
  10. }
  11.  
  12. public static int getCooldown(Player p) {
  13. return Math.toIntExact(Math.round((cooldown.get(p.getUniqueId()) - System.currentTimeMillis()/1000)));
  14. }
  15.  
  16. public static boolean checkCooldown(Player p ) {
  17. if(!cooldown.containsKey(p.getUniqueId()) || cooldown.get(p.getUniqueId()) <= System.currentTimeMillis()) {
  18. return true;
  19. }
  20. return false;
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement