[SPIGOT-6944] Incorrect tab complete documentation Created: 20/Feb/22  Updated: 21/Feb/22  Resolved: 21/Feb/22

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Simon Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: Spigot
Environment:

Windows


Attachments: Java Source File TabTest.java    
Version: This server is running CraftBukkit version 3360-Spigot-f65de01-c2e0bbd (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

In the method onTabComplete([CommandSender|https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/command/CommandSender.html] sender, Command command, String alias, String[] args) is a mistake.
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/command/TabCompleter.html
As the documentation says the parameter args is an array that contains all passed arguments including final partial argument and command label.

This means if we enter a command and press TAB we should recceive the same string as the one in the chat bar excluding the slash. Why? So the command syntax is as following:
/<label> [args0] [arg1] [arg2] [and so on]

If we now enter a command e.g. /tabtest foo and use TAB. We should receive an array which would look like this: ["tabtest", "foo"]. But that isn't our result. Our result is ["foo"]! So the label isn't there as it should. Where is it? It's a little bit hidden inside Command.
Right here:
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/command/Command.html#getLabel()
so we need to do command.getLabel() to get our label. Or if we're fine with the alias we're able to use the alias parameter.

 

Parts copied from:
https://www.spigotmc.org/threads/spigot-bug-or-documentation-mistake.547577/


Generated at Tue Apr 22 06:07:33 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.