Create Plugins
Requirements
Java 17
Basic knowledge of programming with Java
Import Library
Let's get started!
To create a plugin you will need to first make a class that we will use as our "Main Class".
This class needs to extend the class called ReePlugin
.
Here is an example of how your main class might look!
After extending the ReePlugin
class, we can go and implement all the new methods we have!
To be exact we have 3 new methods, the first one will be start
then comes stop
and at the end, we have delete
.
Start Method
This method will be called when the plugin is being run by Ree6 and everything is successfully loaded.
Stop Method
This one will be called when you stop the plugin this includes situations where you delete or unload it via the Plugin Manager.
Delete Method
This will only be called when the Plugin Manager is asked to delete the given plugin, so you have a chance to give a goodbye message or something.
Once you implement the methods you want to use it should look something like this!
Creating a command!
To create a command we need to first understand the concept behind the Ree6 Command System.
We have a CommandManager
which is handling all the internal works like command parameter parsing and more!
For a command, we need to create a class that implements the ICommand
class and has the Command
Annunciation.
Let's make a command together called PongCommand
:
When creating the commands you will need to implement these 3 methods to work with them.
The onPerform
method is where you are going to do most of the stuff.
I will give you a CommandEvent
parameter which will contain information like:
Has this Command been executed as SlashCommand?
Who executed this Command?
In which Guild has this Command been executed?
Now, let's continue with our work!
Since we want the Bot to respond with Pong!
when someone writes /ping
or ree!ping
We need to go into the onPerform
method and respond to it!
For this, we can use the internal reply method, just like this!
Register the command.
Well now that we finished our great PongCommand
we will need to register it!
How do we do that?
Unlike the old Addon system, we don't need to manually register it! The new plugin system will automatically detect that the plugin has a few classes that implement the interface and register them!
The missing plugin.yml
To let Ree6 know where to look you will need to create a plugin.yml
!
In this, you will need to add the name of the plugin, the author's name, the path to the main class, the version of the plugin, and the version of Ree6 it has been made for!
For example, a correct plugin.yml
would look like this:
Finishing up!
You should be ready to go with your plugin! Now you will need to export it either via Maven, Gradle, or any desired way you have!
On how to load the plugins refer to Installing Plugins
Last updated