Run methods on reload

Perform validations, print messages, whatever you want.

Run methods before or after the config is reloaded, all you have to do it annotate them with the respective annotation. Both public and private no-args methods are supported. They can be on the base class, or any parent class.

By default, these methods run on the main thread, but you can specify async on the annotation parameter to run the method on another thread (ForkJoinPool).

import com.github.secretx33.sccfg.api.annotation.*;

@Configuration
public class MyConfig {
    
    @BeforeReload
    public void doBefore() {
        // doing something before config is reloaded
    }

    @BeforeReload(async = true)
    private void doBeforeAsync() {
        // doing something before config is reloaded, but async
    }
    
    @AfterReload
    private void doAfter() {
        // doing something after config is reloaded
    }

    @AfterReload(async = true)
    public void doAfterAsync() {
        // doing another thing after config is reloaded, but async
    }
}

Last updated