[SPIGOT-6338] Tab completion doesn't trigger when I press <space> but only when I begin typing the next argument Created: 03/Feb/21  Updated: 13/Feb/21  Resolved: 13/Feb/21

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

Type: Bug Priority: Minor
Reporter: Matt D. Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Environment:

Fedora 32 64-bit OpenJVM


Attachments: File TabCompletion.jar     GIF File spigot-tab-completion.gif     Zip Archive tab-completion-src.zip    
Version: 3002-Spigot-138d451-085fe67
Guidelines Read: Yes

 Description   

When typing the native command /recipe and then <space> I am given a list of acceptable options "give" and "take".

I want to provide tab completion like this.

I implemented TabCompleter correctly but the onTabComplete() method is only ever called when I begin typing the argument after a space. It does not get called after the initial <space> and therefore does not provide a list of acceptable arguments until you start pressing random keys after the space.

I get the correct list of options when pressing tab at the console but as a player in Minecraft tab will only complete my player name until I begin typing.

My tab completion object is simple. It prints a message to the console every time it is triggered and always returns a list of two options:

 

 

public class OnTabComplete implements TabCompleter {
   @Override
   public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
      System.out.println(command.getName());
   
      return Arrays.asList(new String[] { "apple""pear" });
   }
}

The issue is that it never gets called when I type the command and <space>. It only gets called after I begin typing the first argument.

 



 Comments   
Comment by md_5 [ 13/Feb/21 ]

Cannot reproduce with or without bungeecord (shows as soon as I press space).
As for the spigot.yml settings, the notes about 1.13 and client side are correct — nothing spigot can do there

Comment by blablubbabc [ 04/Feb/21 ]

I don't know if there is a BungeeCoord issue involved in this, but this might also be 'working as intended' because BungeeCoord seems to have certain rules regarding whether or not it passes the tab completion request forward. For instance, if any of the BungeeCoord plugins / commands can provide a non-empty list of suggestions, BungeeCoord will use that and doesn't even inform the underlying Spigot server. So the outcome of this will also depend on your BungeeCoord setup and other plugins.

Comment by Matt D. [ 04/Feb/21 ]

I've had several people confirm that they are NOT experiencing this issue using the same plugin I attached. I am using Spigot over Bungeecord which may be the source of the bug.

 

 Can anyone confirm?

 

My Bungeecord service is configured as "online_mode: true". I don't think any of the other configuration options are important.

Comment by blablubbabc [ 03/Feb/21 ]

I just tested your test plugin (had to recompile it due to incompatible java versions, but the code should be roughly the same) on dev-Spigot-89d6047-c3e684e (MC: 1.16.5), and I am not able to reproduce the issue: I get the tab completion as soon as a space is entered, as you expect it.

Edit: I haven't changed anything on the default settings, as far as I am aware.
Also: Are you connected to the server via a BungeeCoord instance? Try if you can reproduce this on a regular Spigot server. Maybe this is a BungeeCoord-specific issue.

Comment by Matt D. [ 03/Feb/21 ]

The issue is that the tab completion event method is not called after pressing <space>. See the attached animated gif demonstrating the problem case if my summary is still unclear.

 

Comment by Phoenix616 [ 03/Feb/21 ]

I'm not sure why you are going on about the command arguments, that setting refers to the tab completion of the actual command name (see the patch).

I'm pretty sure that patch broke in 1.13 though (beyond simply disabling the tab completion with -1) seeing as 1.13 handles completions client-side now without the server having any influence beyond what is sent initially when the player logs in iirc. (see the PlayerCommandSendEvent)

As for the use case presented in your example plugin: The command argument tab complete is called for every character now, not only when pressing "tab" because of how the new completion system works. If you only want to show argument suggestions starting at a certain length you can test the length of the last argument and return a different list based on that.

Comment by Matt D. [ 03/Feb/21 ]

I've attached a working example plugin and accompanying source code for the test case I'm using which reproduces my problem.
 
The test command is "/tabtest" for this plugin and not "/home2" as shown in the gif.

Comment by Matt D. [ 03/Feb/21 ]

I don't know why this question was closed. I've opened a new one since I can't re-open my own:

 

https://hub.spigotmc.org/jira/browse/SPIGOT-6339

 

Comment by Matt D. [ 03/Feb/21 ]

In my spigot.yml: tab-complete: 0

 

This is the default setting.

 

According to the documentation:

 

https://www.spigotmc.org/wiki/spigot-configuration/

 

0 will tab-complete all commands
-1 will disable tab completely
1 will mean you have to type the first letter
2 will mean you have to type the second letter... etc...

 

 

Comment by Black Hole [ 03/Feb/21 ]

Vanilla commands are completed at the client. For plugin commands the client asks the server for completions. There is an option "tab-complete" in the "spigot.yml" config file to control after how many characters the server sends a reply to the client.

Comment by Matt D. [ 03/Feb/21 ]

I've attached an animated gif demonstrating the issue.

Generated at Wed Sep 03 19:35:48 UTC 2025 using Jira 10.3.9#10030009-sha1:eff8913ed2270ee44ab422c3609af4c4f36536d0.