Hey Ik this is poosible to not let a player do a command until a certain time. I'm making a Kit Plugin I want them to get kits every 5 H0urs
Use System.currentTimeMillis() to get the time (in milliseconds since midnight 1/1/1970) when they use the command, and save this time + 5 hours in milliseconds (18000000) to a .yml file. Then, when they try to use the command, check if System.currentTimeMillis() >= this time: if it is, it has been at least 5 hours between uses, and you can allow it, otherwise they still have to wait
jay275475 savedTime + TimeUnit.HOURS.toMillis(5) >= System.currentTimeMillis(). Were "savedTime" is the saved time.
Use a database to save the time rather than yaml/plaintext. It's probably the safest way and will cause the least hassle I think.
When the player used the command, do getConfig().set("cooldown." + player.getName(), System.currentTimeMillis()); but before executing the command do: if(getConfig().getLong("cooldown." + player.getName) + TimeUnit.HOURS.toMillis(5) <= System.currentTimeMillis()) { //do the command } else { //command was executed in the last 5 hours } tommycake50 I think a database should only be used if it is really needed, because setting the database up and requiring that the plugin users have a database for saving cooldowns is not tbe best idea. EDIT by Moderator: merged posts, please use the edit button instead of double posting.