Skip to content

BasicCommand won't add an empty string to args when there's a trailing whitespace #11211

Closed
@thomasmny

Description

@thomasmny

Expected behavior

I have a BasicCommand which I want to get suggestion for.

@Override
public @NotNull Collection<String> suggest(@NotNull CommandSourceStack stack, @NotNull String[] args) {
    if (args.length <= 1) {
        return SuggestionHelper.getSchematicSuggestions(this.schematicDirectory, args);
    }
    return Collections.emptyList();
}

If I've typed in my first argument and then add a space attempting to get the completions for the next argument, I should receive no suggestions since I'm returning an empty list.

Observed/Actual behavior

The player still sees their previous suggestions
Screenshot 2024-08-04 at 21 48 09

Only when a non-whitespace character is added, do the correct suggestions show
Screenshot 2024-08-04 at 21 48 17

Steps/models to reproduce

With the code above (where SuggestionHelper.getSchematicSuggestions(this.schematicDirectory, args); just returns a list with some strings), type in the first argument and then after inputting a space the suggestions will remain

Plugin and Datapack List

Paper Plugins:
- Faberium <- The test plugin
Bukkit Plugins:
- Builders-Utilities, BuildSystem, FastAsyncWorldEdit

Paper version

This server is running Paper version 1.21-124-master@df3b654 (2024-08-02T00:02:38Z) (Implementing API version 1.21-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21-123-0a1be9a (MC: 1.21)

Other

https://discord.com/channels/289587909051416579/555462289851940864/1269761853723246622

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.type: bugSomething doesn't work as it was intended to.version: 1.21Game version 1.21

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions