Time Left

Discussion in 'Spigot Plugin Development' started by LazerShadow, Jun 3, 2015.

  1. I'm making a tempmute command, the way I'm doing it is that when the player is muted after the
    scheduleSyncDelayedTask they are removed from the HashMap. I want to be able to tell the player how much time until the scheduleSyncDelayedTask is over/done. So basically when a player is muted I send them this messages

    Code (Javascript):
    player.sendMessage("You are muted for another "  + timeleft);
    this is the scheduleSyncDelayedTask

    Code (Javascript):
                            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable(){
                                public void run(){
                            }, 1000);
  2. Check if the player is trying to type in the chat then send that message to them
  3. What exactly is the problem? Is the message not sending, is something going wrong? It helps to clarify ;)
    • Agree Agree x 1
  4. Ok, so I am making a temp mute command. The way I have it set up is when the player is muted I have the
    scheduleSyncDelayedTask go off and once the delay has ended it removed them from the HashMap. I want to know how I can check how much time until the player is removed from the HashMap. For example if they are muted for 10 minutes, and one minute after they are muted and they try to chat it tells them that they are muted for another 9 minutes.

    I just need to know how to get the 9 minutes part.
  5. There's lots of ways to do it. Here's how I'd do it:

    Instead of having a task for every muted player, just have 1 task for them all. This task can be on a 1 second loop, or 1 minute loop (your call). Each time this task runs it will check a hash containing player and time to unmute and unmute each player that has reached that time. This will allow you to know when the players will be unmuted from anywhere at any moment and be able to tell them how much time is left.
    • Like Like x 1
  6. Sounds like a good idea, although how would I do this? I'm still an amateur.
  7. Hit up google :p