Skip to content

Commit 09c750e

Browse files
made children nodes be stored in a list instead of a set
1 parent 59276aa commit 09c750e

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/main/java/com/datasiqn/commandcore/command/builder/BuilderCommand.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import com.datasiqn.commandcore.command.Command;
88
import com.datasiqn.commandcore.command.CommandContext;
99
import com.datasiqn.commandcore.command.TabComplete;
10+
import com.datasiqn.commandcore.command.builder.CommandLink.Executor;
11+
import com.datasiqn.commandcore.command.builder.CommandLink.Requirement;
1012
import com.datasiqn.resultapi.None;
1113
import com.datasiqn.resultapi.Result;
1214
import org.bukkit.ChatColor;
@@ -17,8 +19,6 @@
1719
import java.util.ArrayList;
1820
import java.util.Collections;
1921
import java.util.List;
20-
import java.util.Set;
21-
import java.util.function.Consumer;
2222

2323
class BuilderCommand implements Command {
2424
private final String name;
@@ -27,9 +27,9 @@ class BuilderCommand implements Command {
2727
private final String permission;
2828
private final List<String> usages;
2929

30-
private final Set<CommandNode<?>> nodes;
31-
private final Consumer<CommandContext> executor;
32-
private final List<CommandLink.Requirement> requires;
30+
private final List<CommandNode<?>> nodes;
31+
private final Executor executor;
32+
private final List<Requirement> requires;
3333

3434
public BuilderCommand(@NotNull CommandBuilder commandBuilder, List<String> usages) {
3535
this.name = commandBuilder.name;
@@ -102,7 +102,7 @@ public BuilderCommand(@NotNull CommandBuilder commandBuilder, List<String> usage
102102
if (args.size() >= 1) {
103103
ArgumentReader reader = args.asReader();
104104
CommandContext newContext = context;
105-
Set<CommandNode<?>> nodeSet = nodes;
105+
List<CommandNode<?>> nodeSet = nodes;
106106

107107
String matchingString = args.getString(args.size() - 1);
108108

@@ -155,7 +155,7 @@ public boolean hasDescription() {
155155
return CommandCore.createContext(context.getSource(), context.getCommand(), context.getLabel(), new StringArguments(result.args));
156156
}
157157

158-
private @NotNull Result<ApplicableNode, List<String>> checkApplicable(@NotNull ArgumentReader reader, @NotNull Set<CommandNode<?>> nodes) {
158+
private @NotNull Result<ApplicableNode, List<String>> checkApplicable(@NotNull ArgumentReader reader, @NotNull List<CommandNode<?>> nodes) {
159159
List<CommandNode<?>> options = new ArrayList<>();
160160
List<String> exceptions = new ArrayList<>();
161161
if (reader.index() != 0 && !reader.atEnd()) reader.next();
@@ -177,7 +177,7 @@ public boolean hasDescription() {
177177

178178
@Contract("_ -> new")
179179
private @NotNull CurrentNode findCurrentNode(@NotNull ArgumentReader reader) {
180-
Set<CommandNode<?>> nodeSet = nodes;
180+
List<CommandNode<?>> nodeSet = nodes;
181181
List<String> args = new ArrayList<>();
182182
List<CommandNode<?>> nodeList = new ArrayList<>();
183183
CommandNode<?> node;

src/main/java/com/datasiqn/commandcore/command/builder/CommandLink.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
import org.jetbrains.annotations.NotNull;
77
import org.jetbrains.annotations.UnmodifiableView;
88

9-
import java.util.*;
10-
import java.util.function.Consumer;
11-
import java.util.function.Function;
9+
import java.util.ArrayList;
10+
import java.util.Collections;
11+
import java.util.List;
1212

1313
/**
1414
* Represents a link in a command tree.
1515
* It shares many common methods that are all present in a {@code CommandBuilder} and a {@code CommandNode}.
1616
* @param <T> The type of "This". It is returned every time a chaining method is called, allowing unique methods on the subclass to be called.
1717
*/
1818
public abstract class CommandLink<T> {
19-
protected final Set<CommandNode<?>> children = new HashSet<>();
19+
protected final List<CommandNode<?>> children = new ArrayList<>();
2020
protected final List<Requirement> requires = new ArrayList<>();
2121

2222
protected Executor executor;
@@ -74,8 +74,8 @@ public T executes(@NotNull Executor executor) {
7474
* @return An unmodifiable view of all children nodes
7575
*/
7676
@UnmodifiableView
77-
public @NotNull Set<CommandNode<?>> getChildren() {
78-
return Collections.unmodifiableSet(children);
77+
public @NotNull List<CommandNode<?>> getChildren() {
78+
return Collections.unmodifiableList(children);
7979
}
8080

8181
/**

0 commit comments

Comments
 (0)