aikar / aikar/commands

Empty String argument possible with two subsequent String parameters

Open
#322 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
628
Forks
150
PR merge metrics
No merged PRs in 30d

Description

Consider the following code (to create a chatroom, in this particular case) in a command:
```java
@Subcommand("create")
public void create(CommandSender sender, @Single String name, @Single @Optional String password) {
// some action
}
```

If a user types `/room_create__something` (please think of `_` as a space, a double space was formatted away in this editor) name is an empty string and password will be `something` (because of the double space between `create` and `something`!)
As you cannot call other commands that have a String parameter as the last parameter with an empty string by just adding spaces (e.g. `/room_delete__`), I doubt that this works as intended - I would expect the second argument to actually be the second argument instead of supplying me with an empty string.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.