Skip to content

Plugin Tutorial (First Steps)

DanTheTechMan edited this page Jan 8, 2022 · 2 revisions

First Steps

Steps 2-6 should be carried out when the plugin is enabled. Example code is provided.

  1. Extend the AbstractPonderPlugin class.
class LanguageBarriers extends AbstractPonderPlugin
  1. Implement the required inherited methods.

  2. Initialize the config service.

HashMap<String, Object> configOptions = new HashMap<>();
configOptions.put("debugMode", false);
getPonderAPI().getConfigService().initialize(configOptions);
  1. Initialize the config file.
if (!(new File("./plugins/LanguageBarriers/config.yml").exists())) {
    getPonderAPI().getConfigService().saveMissingConfigDefaultsIfNotPresent();
}
else {
    // pre load compatibility checks
    if (isVersionMismatched()) {
        getPonderAPI().getConfigService().saveMissingConfigDefaultsIfNotPresent();
    }
    reloadConfig();
}
  1. Register your event handlers.
ArrayList<Listener> listeners = new ArrayList<>();
listeners.add(new JoinHandler());
getToolbox().getEventHandlerRegistry().registerEventHandlers(listeners, this);
  1. Initialize the Command Service.
ArrayList<ICommand> commands = new ArrayList<>(Arrays.asList(
        new HelpCommand(), new InfoCommand(),
        new ListCommand(), new CreateCommand(),
        new SpeakCommand(), new ForgetCommand(),
        new TeachCommand(), new LearnCommand()
));
getPonderAPI().getCommandService().initialize(commands, "That command wasn't found.");
  1. Add the onCommand() method. (TODO: add more here)

You're now ready to use the Ponder library!

Clone this wiki locally