Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. public class Events implements Listener {
  2. private int cooldowntime = 5;
  3. private HashMap<UUID, Long> cooldown = new HashMap<UUID, Long>();
  4.  
  5. @EventHandler
  6. public void onPlayerInteract(PlayerInteractEvent event) {
  7. final Player player = event.getPlayer();
  8. Action action = event.getAction();
  9. Block block = event.getClickedBlock();
  10. if (player.getItemInHand().getType() == Material.DIAMOND_PICKAXE) {
  11. if (event.getAction() == Action.RIGHT_CLICK_AIR) {
  12. player.performCommand("sellall");
  13. }
  14. {
  15.  
  16. long secondsleft = ((cooldown.get(player.getUniqueId()) / 1000) + cooldowntime)
  17. - (System.currentTimeMillis() / 1000);
  18. if (secondsleft > 0) {
  19. player.sendMessage(
  20. ChatColor.RED + "You must wait" + ChatColor.YELLOW + secondsleft + ChatColor.RED + "seconds!");
  21.  
  22. }
  23. event.setCancelled(true);
  24.  
  25.  
  26. player.sendMessage(ChatColor.RED + "You need to wait 3 seconds!");
  27. }
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement