mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-24 00:51:34 +01:00
ArgumentLoop cleanup
This commit is contained in:
parent
e0d0c14933
commit
df2ee23a7c
@ -414,7 +414,7 @@ public final class CommandManager {
|
||||
|
||||
DeclareCommandsPacket.Node literalNode = createMainNode(name, syntaxes.isEmpty());
|
||||
|
||||
addCommandNameNode(literalNode, rootChildren, nodes);
|
||||
final int literalNodeId = addCommandNameNode(literalNode, rootChildren, nodes);
|
||||
|
||||
// Contains the arguments of the already-parsed syntaxes
|
||||
List<Argument<?>[]> syntaxesArguments = new ArrayList<>();
|
||||
@ -434,7 +434,7 @@ public final class CommandManager {
|
||||
// Represent the children of the last node
|
||||
IntList argChildren = cmdChildren;
|
||||
|
||||
NodeMaker nodeMaker = new NodeMaker(lastNodes);
|
||||
NodeMaker nodeMaker = new NodeMaker(lastNodes, literalNodeId);
|
||||
int lastArgumentNodeIndex = nodeMaker.getNodesCount();
|
||||
|
||||
final Argument<?>[] arguments = syntax.getArguments();
|
||||
@ -525,10 +525,12 @@ public final class CommandManager {
|
||||
return literalNode;
|
||||
}
|
||||
|
||||
private void addCommandNameNode(@NotNull DeclareCommandsPacket.Node commandNode,
|
||||
@NotNull IntList rootChildren,
|
||||
@NotNull List<DeclareCommandsPacket.Node> nodes) {
|
||||
rootChildren.add(nodes.size());
|
||||
private int addCommandNameNode(@NotNull DeclareCommandsPacket.Node commandNode,
|
||||
@NotNull IntList rootChildren,
|
||||
@NotNull List<DeclareCommandsPacket.Node> nodes) {
|
||||
final int node = nodes.size();
|
||||
rootChildren.add(node);
|
||||
nodes.add(commandNode);
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,11 @@ public class NodeMaker {
|
||||
private Rule rule;
|
||||
private int ruleCount;
|
||||
|
||||
public NodeMaker(@NotNull DeclareCommandsPacket.Node[] commandNodes){
|
||||
public NodeMaker(@NotNull DeclareCommandsPacket.Node[] commandNodes, int id) {
|
||||
addNodes(commandNodes);
|
||||
for (DeclareCommandsPacket.Node node : commandNodes) {
|
||||
this.nodeIdsMap.put(node, id);
|
||||
}
|
||||
}
|
||||
|
||||
public ConfiguredNodes getLatestConfiguredNodes() {
|
||||
|
@ -66,12 +66,11 @@ public class ArgumentLoop<T> extends Argument<List<T>> {
|
||||
final int id = nodeMaker.getNodeIdsMap().getInt(latestNode);
|
||||
|
||||
for (Argument<T> argument : arguments) {
|
||||
DeclareCommandsPacket.Node[] latestCache = nodeMaker.getLatestNodes();
|
||||
argument.processNodes(nodeMaker, executable);
|
||||
|
||||
NodeMaker.ConfiguredNodes configuredNodes = nodeMaker.getLatestConfiguredNodes();
|
||||
// For the next loop argument to start at the same place
|
||||
configuredNodes.getOptions().setPreviousNodes(latestCache);
|
||||
configuredNodes.getOptions().setPreviousNodes(latestNodes);
|
||||
for (DeclareCommandsPacket.Node lastArgumentNode : configuredNodes.getNodes()) {
|
||||
lastArgumentNode.flags |= 0x08;
|
||||
lastArgumentNode.redirectedNode = id;
|
||||
|
Loading…
Reference in New Issue
Block a user