Cooldown Timer

Discussion in 'Spigot Plugin Development' started by DidactCraft, May 23, 2015.

  1. Ok, so recently I have been developing a kitGUI for a server. And they specified that they needed a timer to be displayed on the lore of the item within the GUI. So far I have accomplished at succeeding with adding the player to a player arraylist and checking if they are in that arraylist and if they are not they can click on the item and it will give them their kit. But I want it to display how long its got left until they can use that kit again!
     
  2. @EventHandler
    public void onInvClick(InventoryClickEvent e){

    // Name of who clicked
    String clicked = e.getWhoClicked().getName();
    final Player p = (Player) e.getWhoClicked();
    // ------------------
    if (e.getInventory().getName() != "§8[§b§lKITS§8]"){
    return;
    }

    if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§8[§bTrooper§8]")){
    e.setCancelled(true);
    if(!cooldownTime.containsKey(p)) {
    trooperKit(clicked, p);
    e.getWhoClicked().closeInventory();
    }
    cooldown.add(p);
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    public void run() {
    cooldown.remove(p);
    }
    }, 200);
    }

    }
     
  3. 200 is a temp time for the kit, just so I can test it out!
     
  4. bump
     
    • Optimistic Optimistic x 1
  5. There's an edit button, don't bump within 24 hours.
     
    • Creative Creative x 1