Problem/Bug Problem with Cooldowns

Discussion in 'Bukkit Help' started by MrWaffleman, Jul 18, 2015.

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


    I'm currently having problems with my cooldowns. What is happening is that I use the sugar and it says you cannot use it if I try using it again, which is normal. But after 10 seconds it still says I can't use it. I can't figure out the problem but my code is shown below, if you know the problem please help ^.^ .

    package me.mrwaffleman;
    import java.util.ArrayList;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    public class Sugar implements Listener {
        ArrayList<String> cooldown = new ArrayList<String>();
        public void onPlayerInteract(PlayerInteractEvent e) {
            Player p = e.getPlayer();
            if(!(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
            if(!(p.getItemInHand().getType() == Material.SUGAR)) return;
            if(cooldown.contains(p.getName())) {
                p.sendMessage(ChatColor.RED + "You cannot use this yet!");
            ItemStack is = p.getItemInHand();
            if(is.getAmount() > 1)
                is.setAmount(is.getAmount() - 1);
            else p.setItemInHand(null);
            p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 200, 0));
            p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 200, 1));
            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {
                public void run() {
            }, 200);
    EDIT: I even tried if(!(cooldown.contains(p.getName())) {
    My code here

    But it still didn't work :/
Thread Status:
Not open for further replies.

Share This Page