Command Attributes

This page describes the concept of Command Attributes

Command Attributes

Command attributes are objects that enhance the functionality of commands. They come in various forms such as

  • Arguments

  • Actions

  • Properties

  • Subcommands

  • Etc.

A command can have an unlimited amount of attributes. To make sure Delegate can distinguish between command attributes, each attribute must have a unique identifier associated with it. Normally, these identifiers are assigned automatically (no intervention needed), but in some cases it is useful for the developer to provide these (as we will see later when arguments are covered).

Chaining Command Attributes

As said previously, a command can have an unlimited amount of attributes assigned to it. When creating a command using Delegate.create() , an implementation of an ICommandBuilder is returned. The implementation of this builder depends on your platform. Different platforms will return different types of builders:

  • Paper: PaperCommandBuilder

  • Bukkit: BukkitCommandBuilder

  • Velocity: VelocityCommandBuilder

  • ...

Fluent Interface

The ICommandBuilder interface follows the Fluent Interfacearrow-up-right design pattern. This is a type of design pattern that allows proper chaining. In the case of Delegate, it is used to chain command attributes. In the next sections, we will build up to the following command (which has been deliberately overcomplicated):

Please note that this example is drastically overcomplicated. Delegate can achieve the same functionality with cleaner and less nested code. This is example is for illustration purposes only. Please check the second tab for a simplified version of the command.

In the next few tutorials, we will go over the four built-in command attributes:

  • Arguments

  • Actions

  • Properties

  • Definitions

Last updated