Question: Timed Commands

Discussion in 'Plugin Development' started by boogagoal1, Aug 30, 2013.

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

    boogagoal1

    Hello guys! I was developing a Votifier Listener and I ran across this question.
    http://pastebin.com/6CY7ZrBF
    I want to make it so that Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "fly " + p.getName()); gets "cancelled" in 24 hours so the player looses fly. how do I do this?
     
  2. Offline

    caseif

    For starters, use Player#setFlyEnabled(true/false) instead of running a command that I'm pretty sure is dependent on Essentials. As for your question:
    Easy way: create a delayed task right after you enable flying for the player. In this task, disable flying for the player. Unfortunately, this will not survive reloads (that is to say, the task will cease to exist and the code within will never run).
    Slightly-harder way: Save the current timestamp to a YAML file after enabling flying. Then, when the plugin is enabled, create a repeating task with a delay of a minute or so which checks all saved timestamps and compares them to the current one. If the difference is greater than 24 hours, disable flying for the player.
     
  3. Offline

    boogagoal1

    Is there any other way? Such as making a command run 24 hours after?
     
  4. Offline

    xTrollxDudex

  5. Offline

    boogagoal1

    I don't know how to! Can you grab the code, add it, and I will figure it out?
     
  6. Offline

    Drkmaster83

  7. Offline

    boogagoal1

  8. Offline

    Saposhiente

    You do not need to create a calendar.
     
  9. Offline

    boogagoal1

    How?
     
Thread Status:
Not open for further replies.

Share This Page