ActionLib - Creating An Action

Oct 22, 2017
ActionLib - Creating An Action
  • This tutorial will teach how to create your custom Action.

    Method 1, Addon Action:
    If you want to create an Action and export it in a jar file (Like a plugin) you need to follow this steps:

    • Create a blank java project in your IDE.
    • Add ActionLib as a dependency.
    • In the main directory of the jar (SRC) create a yaml file named "addon.yml", this file has the same function as the "plugin.yml" file.
    • Inside the file add the following keys:
      • main (The main class of your addon)
      • name (The name of the addon)
      • description (A short description of your addon)
      • author (Your name or nick)
      • version (The version of your addon)
    • Create the Action (See below)
    • Compile the project and put the jar file on the "plugins/ActionLib/addons" directory
    • Restart your server and execute "/actionlib addons" and check if your plugin is there.

    Method 2, Integrated Action:
    If you use this method, the Action will be inside your plugin and you will need to register it.

    • Add ActionLib as a dependency for your plugin
    • Create the action (See below)
    • Register the action on the onEnable() method:
      Code (Text):
      actionManager.registerAction(new YourClass(), true);
    • Compile the plugin and put the jar file on your plugins folder
    • Restart the server and execute "/actionlib addons"
    Creating the action:
    • Create a class inside a package extending Action (me.sraldeano.actionlib)
    • Create the constructor:
      Code (Text):
      public class TestAction extends Action {
          public TestAction() {
              super("Test");
          }
      }
    • Add the code:
      Code (Text):
      public class TestAction extends Action {
          public TestAction() {
              super("Test");
          }

          @Override
          public void onExecute() {
              getPlayer().sendMessage("This is just a test message!")
          }
      }
    • If you choose the method 1: In the "addon.yml" set the class as the main class. If you choose the method 2: Register the class in your onEnable() with:
      Code (Text):
      actionManager.registerAction(new YourClass(), true);
  • Loading...
  • Loading...