Hello, I made a plugin, but I want a cooldown, i tried some cooldowns, the official Cooldown on the wiki, but I didn't work. I want to wait 60 ticks (3 Seconds) and then do the next task. Code:java FlansPPG.respawners.add(p);// NOW WAIT 3 SECONDSFlansPPG.respawners.remove(p); I hope for an answer.
No, that will force the Bukkit thread to freeze for 3 seconds. You should use a Bukkit scheduler, and it should look something like this. Code:java //Things to do before timer scheduler.scheduleSyncDelayedTask(class that extends JavaPlugin, new Runnable() { @Overridepublic void run() { //Stuff to do after timer }}, 0L, 60L); You can read more about it here http://wiki.bukkit.org/Scheduler_Programming
Flexion You should not use scheduler cooldowns. http://forums.bukkit.org/threads/how-properly-track-countdowns-for-lazy-events.218290/
Yeah, ofc. Sorry, copied from another page and got the wrong code.. Yet another example why copying is bad. @xTrollxDudex In some cases you have to. Using that technique will not execute after a set amount of time, but can be stored and used whenever another action is performed. So if you were to for example send a message to a player after 3 seconds, schedulers would be the way to go.
Well, makes sense I guess. Twist it as much as you want, in some situations you'll have to use schedulers, but if you don't need to you shouldn't.