Wait Long Amounts of Time

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

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

    blok601

    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?

    Thanks
     
  2. Offline

    FisheyLP

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

    blok601

    Is there a more efficient way?
     
  4. Offline

    FisheyLP

    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

    N00BHUN73R

    @blok601
    @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

    blok601

    @FisheyLP

    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