Print time remaining in cooldown

Discussion in 'Plugin Development' started by RoboticPlayer, Oct 25, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    RoboticPlayer

    So I have a cooldown for a plugin I am working on, and it works fine. However, I would like to be able to tell the player how long is left on the cooldown instead of just saying they have to wait. Originally I had a HashMap containing a player UUID and an Integer (for the time remaining) but I didn't know how to implement that so I just went with a Runnable.
    Code:
            Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                @Override
                public void run() {
                    cooldown.remove(p.getUniqueId());
                }
            }, 60 * 20L);
    Cooldown is an ArraryList<UUID>. So how would I implement printing the time remaining in the cooldown?
     
  2. Offline

    567legodude

    @henderry2019 Take the current time in milliseconds and add the amount of time you want to wait. If the current time is less than the stored time, then subtract them, and convert that to however you want to display it. If the current time is greater, then they should no longer be in cooldown.
     
Thread Status:
Not open for further replies.

Share This Page