How can I make all schedulers complete on plugin shutdown

Discussion in 'Plugin Development' started by istorhow, Sep 21, 2022.

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

    istorhow

    I have a scheduler that says that after 5 seconds the broken block is restored, and if in these 5 seconds I start to restart the server, then the block will not be restored. How can I make all schedulers automatically perform actions in onDisable
     
  2. Offline

    CraftCreeper6

    @istorhow
    I don't think there's a built in mechanism for quick completing a scheduler, I.E. setting its tick time to 0.

    I assume you have a list of some kind to store the blocks that need replacing, could just foreach loop the list and place the remaining blocks manually with no delays, after cancelling the scheduler of course.
     
  3. Offline

    istorhow

    I don't have a list for storing blocks, I use I create a scheduler directly in the BreakBlockEvent event
     
  4. Offline

    CraftCreeper6

    @istorhow
    I'd be inclined to suggest you avoid this, if an explosion goes off, triggers another explosion, and another... you get the picture, all of a sudden you have 2000 schedulers. But in any case, you can keep your current system and also add the blocks to a list, remove them from the list once the scheduler places them back and then do as I said above with the remainder in onDisable.
     
  5. Offline

    istorhow

    for explosions this event not working, for explosions have a another event. OK i add blocks to list. Thank u
     
  6. Offline

    Smeary_Subset

    If this is solved, mark as so
     
Thread Status:
Not open for further replies.

Share This Page