After having to watch TheBCBroz for my plugin coding tutorials, I realize how inaccurate it is. So how do I use cooldowns? Here are my two classes for it that have errors: MyCommandExecutor (Only acknowledge 'sptest4' & the beginning lines): Code: package me.TheLazeboy.superpowers; import java.util.ArrayList; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; public class MyCommandExecutor implements CommandExecutor { private ArrayList<Player> cantDoCommand = new ArrayList<Player>(); Countdown d = new Countdown(); public MyCommandExecutor(Superpowers plugin) { } @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; if(cmd.getName().equalsIgnoreCase("sptest1")) { player.sendMessage(ChatColor.GOLD + "Sent!"); return true; } if(cmd.getName().equalsIgnoreCase("spheal")) { if(player.hasPermission("superpowers.spheal")) { player.sendMessage(ChatColor.GREEN + "Healing!"); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 1000, 1)); return true; } if(cmd.getName().equalsIgnoreCase("sptest2")) { player.sendMessage(ChatColor.BOLD + "I AM A BOLD SENTENCE!"); return true; } if(cmd.getName().equalsIgnoreCase("sptest3")) { player.sendMessage(ChatColor.AQUA + "Feed!"); player.setFoodLevel(20); return true; } if(cmd.getName().equalsIgnoreCase("sptest4")) { if(!cantDoCommand.contains(player)) { sender.sendMessage(ChatColor.BLUE + "DONE!"); cantDoCommand.add(player); d.setList(cantDoCommand); d.setPlayer(player); new Thread(d).start(); return true; } return false; } return false;} return false;} } MyCooldown: Code: package me.TheLazeboy.superpowers; import java.util.ArrayList; import org.bukkit.entity.Player; public class MyCooldown implements Runnable { private ArrayList<Player> cantDoCommand = new ArrayList<Player>(); Countdown d = new Countdown(); public final Player player = null; public ArrayList<Player> cantDoCommand = new ArrayList<Player>(); public void setPlayer(Player player) { player1 = player; } public void setList(ArrayList<Player> list) { this.cantDoCommand = list; } public ArrayList<Player> getList() { return cantDoCommand1; } public void run() { try{ Thread.sleep(5000); cantDoCommand1.remove(player1); } catch (Exception ignored) { } } } And I don't have any knowledge about Java, plugin coding, and indents. So please refrain from using advanced terms. Thank you for help you may offer.
Don't save a player's instance to a HashMap, save their name. But here is a good resource on cooldowns, I recommend using it: http://forums.bukkit.org/threads/easycooldown.128219/