mirror of https://github.com/LOOHP/Limbo.git
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:
parent
94ad6d8460
commit
502aa78c3b
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue