8000 Add the option to retrieve raw arguments by DerEchtePilz · Pull Request #459 · CommandAPI/CommandAPI · GitHub
[go: up one dir, main page]

Skip to content

Add the option to retrieve raw arguments #459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3c7aa7f
Add the option to retrieve raw arguments
DerEchtePilz Jun 8, 2023
4baa0a4
Fix SuggestionsBranch.java. Change String[]::new to new String[0]
DerEchtePilz Jun 8, 2023
b186494
Fix CommandArgument.java
DerEchtePilz Jun 8, 2023
b50afe8
Merge dev/dev into dev/raw-argument-input
DerEchtePilz Jun 15, 2023
8981a2a
Add tests for retrieving raw arguments
DerEchtePilz Jun 15, 2023
6cf237d
Move raw argument creation into CommandAPIHandler
DerEchtePilz Jun 15, 2023
c24d084
Fix raw argument tests failing when using the ChatComponentArgument o…
JorelAli Jun 15, 2023
46deb77
Add empty documentation page
DerEchtePilz Jun 17, 2023
bafaacf
Add documentation (1)
DerEchtePilz Jun 23, 2023
ff7fcc1
Add documentation (2)
DerEchtePilz Jun 27, 2023
a0cfc2d
Modify CommandArguments to remove deprecations and add getOrDefault m…
DerEchtePilz Jun 28, 2023
eb431b0
Address some code review
DerEchtePilz Jun 30, 2023
9fe5879
Fix markdownlint issues
DerEchtePilz Jun 30, 2023
d0b59d3
Make sure commandarguments.md lists every method
DerEchtePilz Jun 30, 2023
3af41ab
Link CommandArguments references to commandarguments.md
DerEchtePilz Jun 30, 2023
f67a012
Merge branch 'dev/dev' into dev/raw-argument-input
DerEchtePilz Jun 30, 2023
5643f0d
Update intro.md, optional_arguments.md and upgrading.md
DerEchtePilz Jul 1, 2023
6ebf8e1
Remove 'What terms are used' section, refactor 'Access the inner stru…
DerEchtePilz Jul 3, 2023
e2fd959
Improve explanation for unsafe arguments
DerEchtePilz Jul 4, 2023
a3db5ea
Add an explanation of raw arguments to the JavaDocs for methods deali…
DerEchtePilz Jul 4, 2023
c8c1de6
Remove unnecessary sentence from commandarguments.md
DerEchtePilz Jul 4, 2023
7ff5cf6
Convert CommandArguments.java into a record
DerEchtePilz Jul 4, 2023
c5916bb
Replace usage of CommandArguments#getFullInput in CommandAPIExecutor …
DerEchtePilz Jul 4, 2023
b1104a3
Make Java examples use the node name to access arguments
DerEchtePilz Jul 5, 2023
3f096b8
Make Kotlin examples use the node name to access arguments
DerEchtePilz Jul 5, 2023
cae4298
Make Kotlin DSL examples use the node name to access arguments
DerEchtePilz Jul 5, 2023
ec80dc5
Fix Bukkit Core dependencies
DerEchtePilz Jul 5, 2023
d05c9eb
Add documentation examples
DerEchtePilz Jul 5, 2023
0641607
Update global changelog
DerEchtePilz Jul 5, 2023
4753950
Merge branch 'dev/dev' into dev/raw-argument-input
DerEchtePilz Jul 5, 2023
897739d
Add JavaDocs to record parameters
DerEchtePilz Jul 12, 2023
ad1621d
Merge branch 'dev/raw-argument-input' of https://github.com/JorelAli/…
DerEchtePilz Jul 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Link CommandArguments references to commandarguments.md
  • Loading branch information
DerEchtePilz committed Jun 30, 2023
commit 3af41ab3b03f02f7888658a4f3d9e3764da6630a
2 changes: 1 addition & 1 deletion docssrc/src/argument_entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ There are four `EntitySelectorArgument` subclasses that determine what type of d
- `EntitySelectorArgument.OnePlayer` - A single player, which returns a `Player` object.
- `EntitySelectorArgument.ManyPlayers` - A collection of 8000 players, which returns a `Collection<Player>` object.

The return type is the type to be cast when retrieved from the `CommandArguments args` in the command declaration.
The return type is the type to be cast when retrieved from the [`CommandArguments args`](./commandarguments.md) in the command declaration.

<div class="example">

Expand Down
2 changes: 1 addition & 1 deletion docssrc/src/argument_literal.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ There is a simpler alternative to the `LiteralArgument` class! Instead of having

## Literal arguments vs regular arguments

Unlike regular arguments that are shown in this chapter, the literal argument is _technically_ not an argument. Due to this fact, literal arguments are [unlisted](./listed.md) by default. In other words, **the literal argument is not present in the `CommandArguments args` for the command declaration.**
Unlike regular arguments that are shown in this chapter, the literal argument is _technically_ not an argument. Due to this fact, literal arguments are [unlisted](./listed.md) by default. In other words, **the literal argument is not present in the [`CommandArguments args`](./commandarguments.md) for the command declaration.**

<div class="example">

Expand Down
4 changes: 2 additions & 2 deletions docssrc/src/argument_multiliteral.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Multi literal arguments

So far, we've described normal arguments and literal arguments. We've described the nuances with literal arguments and how they're not really "arguments", so they don't appear in the `CommandArguments args` for commands.
So far, we've described normal arguments and literal arguments. We've described the nuances with literal arguments and how they're not really "arguments", so they don't appear in the [`CommandArguments args`](./commandarguments.md) for commands.

Now forget all of that. Multi literal arguments are the same as literal arguments but they _do_ appear in the `CommandArguments args` for commands (i.e. they are [listed](./listed.md)). Multi literal arguments are just a way better alternative to literal arguments. The multi literal argument constructor allows you to provide a `String nodeName` and a `String... literals` of possible values which you can use for your command declaration.
Now forget all of that. Multi literal arguments are the same as literal arguments but they _do_ appear in the [`CommandArguments args`](./commandarguments.md) for commands (i.e. they are [listed](./listed.md)). Multi literal arguments are just a way better alternative to literal arguments. The multi literal argument constructor allows you to provide a `String nodeName` and a `String... literals` of possible values which you can use for your command declaration.

The multi literal argument has all of the same benefits of a regular literal argument - they are hardcoded options that the user must enter - they don't allow other values.

Expand Down
4 changes: 2 additions & 2 deletions docssrc/src/arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The CommandAPI is very flexible when it comes to registering arguments, and lets

## Argument Casting

To access arguments, they have to be casted to the type that the argument represents. The order of the arguments in the `CommandArguments args` is the same as the order in which the arguments were declared.
To access arguments, they have to be casted to the type that the argument represents. The order of the arguments in the [`CommandArguments args`](./commandarguments.md) is the same as the order in which the arguments were declared.

<div class="multi-pre">

Expand Down Expand Up @@ -133,7 +133,7 @@ The type to cast each argument (declared in the `dev.jorel.commandapi.arguments`
| [`LocationArgument`](./argument_locations.md#location-3d-space) | `org.bukkit.Location` |
| [`LongArgument`](./argument_primitives.md#numerical-arguments) | `long` |
| [`LootTableArgument`](./argument_loottable.md) | `org.bukkit.loot.LootTable` |
| [`MapArgument`](./argument_map.md) | `java.util.LinkedhashMap` |
| [`MapArgument`](./argument_map.md) | `java.util.LinkedHashMap` |
| [`MathOperationArgument`](./argument_mathoperation.md) | `dev.jorel.commandapi.wrappers.MathOperation` |
| [`MultiLiteralArgument`](./argument_multiliteral.md) | `String` |
| [`NamespacedKeyArgument`](./argument_namespacedkey.md) | `org.bukkit.NamespacedKey` |
Expand Down
8 changes: 4 additions & 4 deletions docssrc/src/listed.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Listed arguments

Arguments have a setting which determine whether or not they are present in the `CommandArguments args` that is populated when executing a command.
Arguments have a setting which determine whether or not they are present in the [`CommandArguments args`](./commandarguments.md) that is populated when executing a command.

By default, the `LiteralArgument` has this setting set to `false`, hence the literal values are _not_ present in the `CommandArguments args`.
By default, the `LiteralArgument` has this setting set to `false`, hence the literal values are _not_ present in the [`CommandArguments args`](commandarguments.md).

This flag is set using the following function:

Expand All @@ -20,7 +20,7 @@ Say we have the following command:
/mycommand <player> <value> <message>
```

Let's also say that in our implementation of this command, we don't actually perform any processing for `<value>`. Hence, listing it in the `CommandArguments args` is unnecessary.
Let's also say that in our implementation of this command, we don't actually perform any processing for `<value>`. Hence, listing it in the [`CommandArguments args`](./commandarguments.md) is unnecessary.

<div class="multi-pre">

Expand All @@ -34,6 +34,6 @@ Let's also say that in our implementation of this command, we don't actually per

</div>

In this scenario, the argument `<value>` is not present in the `CommandArguments args` for the executor.
In this scenario, the argument `<value>` is not present in the [`CommandArguments args`](./commandarguments.md) for the executor.

</div>
2 changes: 1 addition & 1 deletion docssrc/src/normalexecutors.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Normal command executors

Command executors are of the following format, where `sender` is a [`CommandSender`](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/command/CommandSender.html), and `args` is a `CommandArguments` object, which represents arguments which are parsed by the CommandAPI.
Command executors are of the following format, where `sender` is a [`CommandSender`](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/command/CommandSender.html), and `args` is a [`CommandArguments`](./commandarguments.md) object, which represents arguments which are parsed by the CommandAPI.

```java
new CommandAPICommand("...")
Expand Down
2 changes: 1 addition & 1 deletion docssrc/src/optional_arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ However, calling `withOptionalArguments` is safer because it makes sure that the

## Avoiding null values

Previously, we've looked at how to handle null values. To make all of this easier, the CommandAPI implements multiple `getOptional()` methods for `CommandArguments`:
Previously, we've looked at how to handle null values. To make all of this easier, the CommandAPI implements multiple `getOptional()` methods for [`CommandArguments`](./commandarguments.md):

<div class="warning">

Expand Down
2 changes: 1 addition & 1 deletion docssrc/src/stringargumentsuggestions.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ This won't work, because we make use of a redirect:

\\(\texttt{/execute run} \xrightarrow{redirect} \texttt{mycommand arg1 arg2 arg3}\\)

It is not possible to access the `CommandArguments` of previously declared arguments. **If a command occurs via a redirect, the `CommandArguments` of previously declared arguments will be null**.
It is not possible to access the [`CommandArguments`](./commandarguments.md) of previously declared arguments. **If a command occurs via a redirect, the [`CommandArguments`](./commandarguments.md) of previously declared arguments will be null**.

</div>

Expand Down
4 changes: 2 additions & 2 deletions docssrc/src/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ withArguments(new MultiLiteralArgument("gamemodes", "survival", "creative", "adv

### MultiLiteralArgument and LiteralArgument changes

In previous versions, the ability has been introduced to access arguments by their node names. However, while this was possible for every other argument, it wasn't possible for `MultiLiteralArgument`s. This was now changed because the values from the `MultiLiteralArgument` are included in the `CommandArguments` of a command.
In previous versions, the ability has been introduced to access arguments by their node names. However, while this was possible for every other argument, it wasn't possible for `MultiLiteralArgument`s. This was now changed because the values from the `MultiLiteralArgument` are included in the [`CommandArguments`](./commandarguments.md) of a command.

Therefore, the current constructor has been deprecated and the new one should be used:

Expand All @@ -50,7 +50,7 @@ withArguments(new MultiLiteralArgument("gamemodes", List.of("survival", "creativ

</div>

Because it is possible to list `LiteralArgument`s in the `CommandArguments` of a command, there was also an additional constructor add to the `LiteralArgument` class. The other one is not deprecated.
Because it is possible to list `LiteralArgument`s in the [`CommandArguments`](./commandarguments.md) of a command, there was also an additional constructor add to the `LiteralArgument` class. The other one is not deprecated.

Now, the `LiteralArgument` class contains two possible constructors:

Expand Down
0