Fix: Send minimal DeclareCommands packet when no Limbo commands available

Previously, when the command list was empty, the server returned null and did not send a DeclareCommands packet.  
This caused the client to lose the slash UI and tab completion entirely.  

Now, when there are no available commands, the server sends a minimal valid tree (only a root node with no children).  
This keeps the client UI functional while still reflecting the fact that no commands are available.
This commit is contained in:
Danbka4Z 2025-08-31 17:49:37 +03:00 committed by GitHub
parent 94ad6d8460
commit 502aa78c3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 4 deletions

View File

@ -34,13 +34,19 @@ public class DeclareCommands {
public static PacketPlayOutDeclareCommands getDeclareCommandsPacket(CommandSender sender) throws IOException { public static PacketPlayOutDeclareCommands getDeclareCommandsPacket(CommandSender sender) throws IOException {
List<String> commands = Limbo.getInstance().getPluginManager().getTabOptions(sender, new String[0]); List<String> commands = Limbo.getInstance().getPluginManager().getTabOptions(sender, new String[0]);
if (commands.isEmpty()) {
return null;
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
if (commands.isEmpty()) {
DataTypeIO.writeVarInt(output, 1);
output.writeByte(0);
DataTypeIO.writeVarInt(output, 0);
DataTypeIO.writeVarInt(output, 0);
return new PacketPlayOutDeclareCommands(buffer.toByteArray());
}
DataTypeIO.writeVarInt(output, commands.size() * 2 + 1); DataTypeIO.writeVarInt(output, commands.size() * 2 + 1);
output.writeByte(0); output.writeByte(0);