Root node should be at index 0 (to facilitate the future ArgumentCommand)

This commit is contained in:
themode 2021-02-11 00:58:10 +01:00
parent dffb90e1b4
commit 779490064e

View File

@ -297,6 +297,11 @@ public final class CommandManager {
// Contains the children of the main node (all commands name)
IntList rootChildren = new IntArrayList();
// Root node
DeclareCommandsPacket.Node rootNode = new DeclareCommandsPacket.Node();
rootNode.flags = 0;
nodes.add(rootNode);
// Brigadier-like commands
for (Command command : dispatcher.getCommands()) {
// Check if player should see this command
@ -373,14 +378,11 @@ public final class CommandManager {
nodes.add(literalNode);
}
DeclareCommandsPacket.Node rootNode = new DeclareCommandsPacket.Node();
rootNode.flags = 0;
// Add root node children
rootNode.children = ArrayUtils.toArray(rootChildren);
nodes.add(rootNode);
declareCommandsPacket.nodes = nodes.toArray(new DeclareCommandsPacket.Node[0]);
declareCommandsPacket.rootIndex = nodes.size() - 1;
declareCommandsPacket.rootIndex = 0;
return declareCommandsPacket;
}