Wait Long Amounts of Time

Discussion in 'Plugin Development' started by blok601, Jul 29, 2016.

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


    Hey, I just need some help on something. I am making this plugin where you need to run a command after an hour of time.

    Basically 1 hour in, I just do code.

    How would I wait for that hour?

  2. Offline


    new BukkitRunnable() {
    public void run() {
    }.runTaskLater(plugin, 72000);
    72000 because 20 ticks = 1 second, * 60 = 1 minute, * 60 = 1 hour
  3. Offline


    Is there a more efficient way?
  4. Offline


    Depends on what you want. A cooldown to just check if 1 hour has passed or run code after 1 hour.
    It also depends on how many of these you start. If they're more than ~20 then it would be better to use a global repeating task, checking every of the saved times at once per run.
  5. Offline


    @FisheyLP 's way will work fine.. But if you insist on a different way, you can always use a Map<String, Long> and use the system#CurrentMillis method and compare the times.
  6. Offline



    I just want to run a command after 1 hour. It will be about 5 of them (The time increases by 5 mins for each one). So I don't think it would lag that much.

    @N00BHUN73R I think I will try Fishey's method.

    Thanks, ill reply with results.
Thread Status:
Not open for further replies.

Share This Page