Delegate
  • Delegate Framework
    • Framework Overview
    • Feature Overview
  • Commands
    • First Command
    • Command Attributes
      • Arguments
      • Actions
      • Properties & Definitions
  • Tutorials / Examples
    • Getting Started
    • 👋Hello, World!
Powered by GitBook
On this page
  • Hooking
  • Your First Command
  1. Commands

First Command

This page will describe how you can create your first command with Delegate

Hooking

Delegate is platform agnostic, but it still needs a way to hook itself into the platform you are using. This is done by hooking your plugin. Hooking your plugin is easy. The example below shows you how to hook using the Paper/Spigot/Bukkit implementation.

Plugin plugin = Bukkit.getServer().getPluginManager("<your plugin>");
Delegate.hook(plugin);

Make sure to hook your plugin. If your plugin is not hooked, commands will not work!

Your First Command

public class Example {
    
    /**
      * Creates a simple "Hello, World!" command.
      */
    public void createCommand() {
        Delegate.create("hello", "Sends hello to the whole server")
            .withAction(() -> Bukkit.broadcastMessage("Hello, World!"))
            .build();
    }
    
}

Let's break down what is happening here. A command in delegate is always created using the create()-method which can be called on the Delegate object:

Delegate.create(String name, String description);

This will create a ICommandBuilder depending on your selected platform (e.g. if you are using the Paper implementation, this will be a PaperCommandBuilder). This is a builder that can be used to chain attributes to your command. Furthermore, depending on your platform, some builders may offer other attribute options. In the next section we'll take a closer look at what these command attributes are.

PreviousCommandsNextCommand Attributes

Last updated 1 year ago