💬
Conversation Wiki
  • 💬Conversation
  • 📖Basics
    • Folder
    • File
    • Step Architecture
  • 🪜Steps
    • ConsoleCommandStep
    • ForcePlayerCommand
    • ActionBarStep
    • ChatClickChoiceTextStep
    • ClickTextStep
    • DelayTextStep
    • MovementChoiceTextStep
    • StartConversationStep
    • PlayerPlaySound
  • 📕Conditions
    • PAPICondition
    • PermissionCondition
  • 🪝Triggers
    • BlockTrigger
    • NpcTrigger
  • ⚙️Options
    • CancelCommandOption
    • EndStepOption
    • HideChatOption
    • MoveAwayToEndConversationOption
    • NoDamageOption
    • PositionLockOption
    • RotationLockOption
    • ShiftToEndConversationOption
  • 🛠️API
    • Implemented in your project
    • Simple case with the API
    • Adding a custom module with the API
Powered by GitBook
On this page
  1. API

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));
});
ConversationInterpreterLoadEvent

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

PreviousSimple case with the API

Last updated 2 years ago

Register the interpreters using the bukkit event

🛠️
🔴