mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Multi arguments handling
This commit is contained in:
parent
c95d2d2f47
commit
00099b5332
1 changed files with 36 additions and 8 deletions
|
@ -120,18 +120,17 @@ public class JavaServerDeclareCommandsTranslator extends PacketTranslator<Server
|
||||||
ParamInfo rootParam = new ParamInfo(commandNode, null);
|
ParamInfo rootParam = new ParamInfo(commandNode, null);
|
||||||
rootParam.buildChildren(allNodes);
|
rootParam.buildChildren(allNodes);
|
||||||
|
|
||||||
try {
|
if (commandNode.getName().equals("gamerule")) {
|
||||||
new ObjectMapper().writeValueAsString(rootParam.getChildren());
|
GeyserConnector.getInstance().getLogger().debug("BREAK HERE");
|
||||||
} catch (JsonProcessingException e) { }
|
}
|
||||||
|
|
||||||
CommandParamData[][] params = new CommandParamData[rootParam.getChildren().size()][];
|
List<CommandParamData[]> treeData = rootParam.getTree();
|
||||||
|
CommandParamData[][] params = new CommandParamData[treeData.size()][];
|
||||||
|
|
||||||
// Fill the nested params array
|
// Fill the nested params array
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ParamInfo parmInfo : rootParam.getChildren()) {
|
for (CommandParamData[] tree : treeData) {
|
||||||
CommandParamData[] paramParts = new CommandParamData[1];
|
params[i] = tree;
|
||||||
paramParts[0] = parmInfo.getParamData();
|
|
||||||
params[i] = paramParts;
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,6 +252,35 @@ public class JavaServerDeclareCommandsTranslator extends PacketTranslator<Server
|
||||||
children.add(new ParamInfo(paramNode, new CommandParamData(paramNode.getName(), false, null, mapCommandType(paramNode.getParser()), null, Collections.emptyList())));
|
children.add(new ParamInfo(paramNode, new CommandParamData(paramNode.getName(), false, null, mapCommandType(paramNode.getParser()), null, Collections.emptyList())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Recursively build all child options
|
||||||
|
for (ParamInfo child : children) {
|
||||||
|
child.buildChildren(allNodes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CommandParamData[]> getTree() {
|
||||||
|
List<CommandParamData[]> treeParamData = new ArrayList<>();
|
||||||
|
|
||||||
|
for (ParamInfo child : children) {
|
||||||
|
List<CommandParamData[]> childTree = child.getTree();
|
||||||
|
for (CommandParamData[] subchild : childTree) {
|
||||||
|
CommandParamData[] tmpTree = new ArrayList<CommandParamData>() {
|
||||||
|
{
|
||||||
|
add(child.getParamData());
|
||||||
|
addAll(Arrays.asList(subchild));
|
||||||
|
}
|
||||||
|
}.toArray(new CommandParamData[0]);
|
||||||
|
|
||||||
|
treeParamData.add(tmpTree);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (childTree.size() == 0) {
|
||||||
|
treeParamData.add(new CommandParamData[] { child.getParamData() });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return treeParamData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue