Hello ! How can i make a delay for a day after the command was executed ? Code: public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { // Server Description if (cmd.getName().equalsIgnoreCase("dice")) { Random rand = new Random(); Player player = ((OfflinePlayer) sender).getPlayer(); int dice1 = rand.nextInt(6)+1; int dice2 = rand.nextInt(6)+1; player.sendMessage("§8[§bDICE§8] §fDice were thrown away..."); // Here delay for a day without can be possible to execute again the command, and can't be possible to reconnect and then use the command again. } return false; }
This: Code: import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; public final class ExamplePlugin extends JavaPlugin { @Override public void onEnable() { new ExampleListener(this); } } class ExampleListener implements Listener { private final ExamplePlugin plugin; public ExampleListener(ExamplePlugin plugin) { this.plugin = plugin; this.plugin.getServer().getPluginManager().registerEvents(this, plugin); } @EventHandler public void onJoin(PlayerJoinEvent event) { // Create the task and schedule to run it once, after 20 ticks BukkitTask task = new ExampleTask(this.plugin).runTaskLater(this.plugin, 20); } }
Well, what is ExampleTask? Does it have any code that is supposed to stop the player from sending the command?
I solved the problem. I had used a global boolean and the classic runnable bukkit and it work . Thank you for help !
I don't know if work multiplayer, now i develop this plugin. The server will be multiplayer next week.
You need to save the timestamp when the command is allowed to be used again by that player. That would be in a map that gets saved to the config in the onDisable and loaded on onEnable.