Running Things before a Scheduler is going to run

I want a warning message before a scheduler is going to run. For example, if the scheduler runs ever 2 minutes, one minute before it runs I want it to broadcast the message. What do I do to get a message that does this?

This the code I have to send a message and execute the task I want to happen. How do I send a message one minute before the scheduler runs?


 public void init(){
        Task task = Task.builder().execute(VCLag::execute)
                .async().interval(, TimeUnit.MINUTES)
                .name("plugin - Clear Items").submit(core);
    public static void execute(){

You will need to construct a separate task to handle the message, or set up a series of tasks that do what you need. The way I personally would do that is this:

  • Task A runs on an interval
  • Task A broadcasts the warning message
  • Task A starts Task B with a delay
  • Task B clears the items

Because Task B does not have an interval, it runs once and that is canceled and put up for garbage collection. There are a couple other ways you could do this that have (slightly) better performance, but I wouldn’t bother going there yet.

Thank you! That worked