My cooldown not works

Discussion in 'Plugin Development' started by ProStriker123, Jun 19, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    ProStriker123

    Whats the problem?
    with the cooldown?

    ArrayList<Player> cooldown = new ArrayList<Player>();

    @SuppressWarnings("deprecation")
    @EventHandler
    public void creeperBlast(PlayerInteractEvent event) {
    final Player player = (Player) event.getPlayer();

    if(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
    if(player.getItemInHand().getItemMeta().getDisplayName() != null) {
    if(player.getItemInHand().getItemMeta().getDisplayName().contains("§f§l- Creeper Blast -")) {
    if(cooldown.contains(player)){
    player.sendMessage("§8Cooldown> §7Please wait 5 seconds before re-using.");
    return ;
    }
    event.setCancelled(true);

    PotionEffect potionEffect = new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 1, 10);
    potionEffect.apply(player);

    player.getWorld().createExplosion(player.getLocation(), 4F);

    player.sendMessage("§6Used> §7You used ability §e§lCreeper Blast§7.");
    cooldown.add(player);
    Bukkit.getServer().getScheduler().scheduleAsyncDelayedTask((Plugin) this, new Runnable() {
    public void run() {
    cooldown.remove(player);
    }
    }, 40);
    }
    }
    }
    }
     
  2. Offline

    chasechocolate

    Save the player's name in a List<String> instead of the Player object.
     
  3. Offline

    Rocoty

    ProStriker123 I don't know the problem. You tell me. Tell us what's wrong so we don't have to guess.
     
  4. Offline

    Drew1080

    Using some code tags to put all that code in would be nice as well.
     
  5. Offline

    ProStriker123

    @Rocoty
    well the problem it when you left click on the object its says its works after when you trying again says cooldown, after 5 sec that i needed its still keeps the cooldown

    @chasechocolate
    its dosent let me to do List<String> any another idea you have?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  6. Drew1080 I Thought The Bug Was on My Monitor xD [Your Signature]
     
Thread Status:
Not open for further replies.

Share This Page