Skip to content

Commit ae014c5

Browse files
authored
Merge pull request #1 from Heron4gf/main
Modified the SubCommand constructor
2 parents 72952ee + 8c987c5 commit ae014c5

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/main/java/me/croabeast/command/SubCommand.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,20 @@ public class SubCommand implements BaseCommand {
7878
* </p>
7979
*
8080
* @param parent the parent command (must not be {@code null}).
81-
* @param name the sub-command name, optionally including aliases separated by a semicolon.
81+
* @param aliases the sub-command name, optionally including aliases separated by a semicolon.
8282
* @throws NullPointerException if the parent is {@code null} or if the name is blank.
8383
*/
84-
public SubCommand(Command parent, String name) {
84+
public SubCommand(Command parent, String name, String... aliases) {
8585
this.parent = Objects.requireNonNull(parent, "Parent cannot be null");
8686

8787
if (StringUtils.isBlank(name))
8888
throw new NullPointerException("Name is empty");
89-
89+
9090
// Split the provided name string by semicolons to extract primary name and aliases.
91-
List<String> list = new ArrayList<>(Arrays.asList(name.split(";")));
92-
this.name = list.get(0);
91+
List<String> list = Arrays.asList(aliases);
92+
this.name = name;
9393
this.permission = parent.getPermission() + '.' + this.name;
94-
95-
// Add any aliases if provided.
96-
if (list.size() > 1) {
97-
for (int i = 1; i < list.size(); i++) {
98-
aliases.add(list.get(i));
99-
}
100-
}
94+
this.aliases.addAll(list);
10195
}
10296

10397
/**

0 commit comments

Comments
 (0)