Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Events implements Listener {
- private int cooldowntime = 5;
- private HashMap<UUID, Long> cooldown = new HashMap<UUID, Long>();
- @EventHandler
- public void onPlayerInteract(PlayerInteractEvent event) {
- final Player player = event.getPlayer();
- Action action = event.getAction();
- Block block = event.getClickedBlock();
- if (player.getItemInHand().getType() == Material.DIAMOND_PICKAXE) {
- if (event.getAction() == Action.RIGHT_CLICK_AIR) {
- player.performCommand("sellall");
- }
- {
- long secondsleft = ((cooldown.get(player.getUniqueId()) / 1000) + cooldowntime)
- - (System.currentTimeMillis() / 1000);
- if (secondsleft > 0) {
- player.sendMessage(
- ChatColor.RED + "You must wait" + ChatColor.YELLOW + secondsleft + ChatColor.RED + "seconds!");
- }
- event.setCancelled(true);
- player.sendMessage(ChatColor.RED + "You need to wait 3 seconds!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement