-
Welcome to skUnity!
Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.
If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!
Now, what are you waiting for? Join the community now!
Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Registering your Addon
-
Now that we have our addon all setup and created from the Getting started section of Addon development.
We now have to enable our addon and tell Skript that we're trying to register a new addon and syntax.
So first we create a method called "onEnable" Spigot will automatically detect this method and run it when the server starts. Keep in mind that your "main" node in your plugin.yml must link to your class name of this class with the onEnable method.
Code (Java):- package me.limeglass.addon;
- import java.io.IOException;
- import org.bukkit.plugin.java.JavaPlugin;
- public class ExampleMain extends JavaPlugin {
- ExampleMain instance;
- SkriptAddon addon;
- public void onEnable() {
- instance = this;
- try {
- //This will register all our syntax for us. Explained below
- addon.loadClasses("me.limeglass.addon", "elements");
- e.printStackTrace();
- }
- Bukkit.getLogger().info("[ExampleAddon] has been enabled!");
- }
- public ExampleMain getInstance() {
- return instance;
- }
- public SkriptAddon getAddonInstance() {
- return addon;
- }
- }
Now to create a set of packages to help Skript register syntax.
In order to do this, we need to create a basic package. I'm calling it elements, this is also how RandomSk calls it's syntax package.
In Eclipse: Click the me.limeglass.addon package and click New -> Package
This is the main package where all our syntax are going to be stored. Keep in mind that what ever you name here, you should update the loadClasses() from the onEnable() method that we setup, to what ever you named it here.
Now our addon should look like this:
Now our addon is registered to Skript! We can now finally start making some Syntax!
Head over to the Creating an Expression section to continue the tutorial, or click the Next button below.