Adding a custom module with the API

You can add custom options, steps, conditions and triggers with the API

I recommend checking by yourself the code of the current modules to see how I coded that (with normal IDE import the dependency and you will be able to see the code of the plugin decompiled, go to the package blueprints and check the method loadDefaultInterpreter() in the class ConversationGlobalLoader in this package you also have all the class of the modules sort by package name of the type of the module (steps, conditions, options, triggers)

To create a new module, you need to create a class representing the module that extends the type of module, and after registering a config interpreter

Ex:

The module class

public class ConsoleCommandStep extends ConversationStep {

    private final String command;

    public ConsoleCommandStep(String command) {
        this.command = command;
    }

    @Override
    public void start(Player p, ActiveConversation activeConversation) {
        Bukkit.getScheduler().runTask(ConversationPlugin.getInst(), () -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), ConversationFormatUtils.preSendTextFormat(command, p)));
        activeConversation.finishStep(underBranches);
    }


}

The interpreter register

conversationManager.registerStepInterpreter("console-command", (stepSection, loader) -> {
            String command = stepSection.getString("command");
            return new ConversationLoader.ConversationStepInLoading(new ConsoleCommandStep(command));
});

🔴 Register the interpreters using the bukkit event

ConversationInterpreterLoadEvent

else you will have problem, when the plugin reload all the interpreter is also reloaded

Last updated