# Arguments

Perhaps the most important part of any command framework is the ability to handle sub commands and command arguments. In this section we'll cover the latter.

## Built-In Arguments

For ease of use, there are various built-in arguments for all platforms. Some arguments are also available for certain platforms. Currently, Delegate supports 4 basic arguments out of the box:

* Float Argument (`FloatArgument`)
* Double Argument (`DoubleArgument`)
* Integer Argument (`IntArgument`)
* String Argument (`StringArgument`)

These arguments will try and process a given input String to a new type. For example, the `FloatArgument` will try to process the input to a floating point number.&#x20;

## Platform-Specific Arguments

As said earlier, there are various platform specific arguments. Currently, the following arguments are supported:

{% tabs %}
{% tab title="Paper/Spigot" %}

| Argument         | Description                                                                                                  |
| ---------------- | ------------------------------------------------------------------------------------------------------------ |
| `PlayerArgument` | Parses an input to a [Player](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html) object |
| `WorldArgument`  | Parses an input to a [World](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/World.html) object          |
|                  |                                                                                                              |
| {% endtab %}     |                                                                                                              |

{% tab title="Velocity" %}
Currently no Velocity-specific arguments are implemented.
{% endtab %}

{% tab title="Sponge" %}
Currently no Sponge-specific arguments are implemented.
{% endtab %}
{% endtabs %}

## Using Arguments

The actual functionality of arguments is the most important part of this section. As explained in the previous section, command attributes can be added to a command by chaining them. Since arguments are command attributes, they must be chained to this builder. To build up the example, we will need one String argument and two Float arguments. We can add them to the command as follows:

```java
Delegate.getFactory().create("math", "Implementation of a arithmetic operations such as addition and  subtraction.")
                .withString("operation", "The operation to perform.")  // String Arg
                .withFloat("a", "The first number to add.")            // Float Arg 
                .withFloat("b", "The second number to add.")           // Float Arg
```

This will add three arguments to the command with identifiers `operation`, `a` and `b`. Please note that these arguments do not have any functionality on their own. How the parsed values of the arguments can be used will be explained in the next section. By default, the command will expect these attributes to be present when executed. This means that an error message will be send back to the command sender when one or multiple attributes are missing. [Properties](https://rocketpencil-studios.gitbook.io/delegate/commands/command-attributes/properties-and-definitions) can be used to mitigate this.

## Methods For Providing Arguments

When executing a command, the following formats are supported:

`/math + 1 2`

`/math operation="+" a="1" b="2"`

While the first method is very concise, it does not allow for arbitrary arguments to be ommited. By using the second method, arguments will automatically be linked together through the identifier that has been specified.
