Skip to content

Editing API Settings

Dalton edited this page Apr 25, 2022 · 8 revisions

Say you don't want a certain module at all to be initialized, or maybe a specific command to not get automatically registered?, not to fear you can enable/disable many feature of the API if you choose to not use them!

In your main class, you're going to be overriding a new method called onPreApiEnable(), from here you get access to the getApiSettings() method like so:

public class MyPlugin extends BurchAPI {

    @Override
    public void onPreApiEnable() {
        this.getApiSettings()
                .useCommandModule(true)
                .useInventoryModule(true)
                .blockCommandFromLoading(HelpCommand.class);
    }

    @Override
    public void onPluginEnable() {
        // Plugin startup logic
    }

    @Override
    public void onPluginDisable() {
        // Plugin startup logic
    }

    // Other optional overrides can still go here
}

You may notice that in the method blockCommandFromLoading(TestCommand.class) the argument taken here is one of your own command classes that extends ApiCommand see here if you don't know what this means

Any modules the API provides, are automatically enabled, there is no need to redundantly set the arguments of the use() methods to true, they are only here for usage examples

Clone this wiki locally