-
Notifications
You must be signed in to change notification settings - Fork 3
Plugin Tutorial (First Steps)
DanTheTechMan edited this page Jan 8, 2022
·
2 revisions
Steps 2-6 should be carried out when the plugin is enabled. Example code is provided.
- Extend the AbstractPonderPlugin class.
class LanguageBarriers extends AbstractPonderPlugin-
Implement the required inherited methods.
-
Initialize the config service.
HashMap<String, Object> configOptions = new HashMap<>();
configOptions.put("debugMode", false);
getPonderAPI().getConfigService().initialize(configOptions);- 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();
}- Register your event handlers.
ArrayList<Listener> listeners = new ArrayList<>();
listeners.add(new JoinHandler());
getToolbox().getEventHandlerRegistry().registerEventHandlers(listeners, this);- 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.");- Add the onCommand() method. (TODO: add more here)
You're now ready to use the Ponder library!