#3938, #3939: Fix TabExecutor when command has the same name as Brigadier command

This commit is contained in:
Rain Heuer
2026-02-13 23:27:40 -06:00
committed by GitHub
parent 1a3f96d919
commit cf5bb43af9
@@ -41,6 +41,7 @@ import net.md_5.bungee.api.event.ServerDisconnectEvent;
import net.md_5.bungee.api.event.ServerKickEvent;
import net.md_5.bungee.api.event.TabCompleteResponseEvent;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.TabExecutor;
import net.md_5.bungee.api.score.Objective;
import net.md_5.bungee.api.score.Position;
import net.md_5.bungee.api.score.Score;
@@ -763,15 +764,33 @@ public class DownstreamBridge extends PacketHandler
for ( Map.Entry<String, Command> command : bungee.getPluginManager().getCommands() )
{
if ( !bungee.getDisabledCommands().contains( command.getKey() ) && commands.getRoot().getChild( command.getKey() ) == null && command.getValue().hasPermission( con ) )
if ( !bungee.getDisabledCommands().contains( command.getKey() ) && command.getValue().hasPermission( con ) )
{
CommandNode dummy = LiteralArgumentBuilder.literal( command.getKey() ).executes( DUMMY_COMMAND )
.then( RequiredArgumentBuilder.argument( "args", StringArgumentType.greedyString() )
.suggests( Commands.SuggestionRegistry.ASK_SERVER ).executes( DUMMY_COMMAND ) )
.build();
commands.getRoot().addChild( dummy );
boolean insertDummy = true;
modified = true;
CommandNode child = commands.getRoot().getChild( command.getKey() );
if ( child != null )
{
if ( command.getValue() instanceof TabExecutor )
{
// Allow Bungee command to handle tab completion rather than Brigadier
commands.getRoot().getChildren().remove( child );
} else
{
insertDummy = false;
}
}
if ( insertDummy )
{
CommandNode dummy = LiteralArgumentBuilder.literal( command.getKey() ).executes( DUMMY_COMMAND )
.then( RequiredArgumentBuilder.argument( "args", StringArgumentType.greedyString() )
.suggests( Commands.SuggestionRegistry.ASK_SERVER ).executes( DUMMY_COMMAND ) )
.build();
commands.getRoot().addChild( dummy );
modified = true;
}
}
}