Hi, I am working on plugin and I need to use some sort of cooldown for command, for example, 30 seconds. Can you give me an example what to use? I was thinking about delayed tasks, maybe?
Perhaps use a HashMap<String, long> in which the String represents a players name and the long a time value in milliseconds (System.currentTimeMillis())
Using HashMap, that was my first idea, but I did't know how to put it together. Btw. I love your plugin BlockLog
Thanks and its quite easy. HashMap itself Code:java HashMap<String, Long> hashmap = new HashMap<String, Long>(); Check if player has a cooldown Code:java hashmap.containsKey(player.getName()); Give a player a cooldown Code:java hashmap.put(player.getName(), System.currentTimeMillis()); Get a player's cooldown Code:java Long time = hashmap.get(player.getName()); Remove a player's cooldown Code:java hashmap.remove(player.getName());