From 8c987c592e71ddd5958fe84bb93cb374573d4543 Mon Sep 17 00:00:00 2001
From: Heron4gf
Date: Thu, 3 Apr 2025 11:52:32 +0200
Subject: [PATCH] Modified the SubCommand constructor to accept a name and
aliases as array of String
---
.../java/me/croabeast/command/SubCommand.java | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/src/main/java/me/croabeast/command/SubCommand.java b/src/main/java/me/croabeast/command/SubCommand.java
index bc5a3fd..f307c90 100644
--- a/src/main/java/me/croabeast/command/SubCommand.java
+++ b/src/main/java/me/croabeast/command/SubCommand.java
@@ -78,26 +78,20 @@ public class SubCommand implements BaseCommand {
*
*
* @param parent the parent command (must not be {@code null}).
- * @param name the sub-command name, optionally including aliases separated by a semicolon.
+ * @param aliases the sub-command name, optionally including aliases separated by a semicolon.
* @throws NullPointerException if the parent is {@code null} or if the name is blank.
*/
- public SubCommand(Command parent, String name) {
+ public SubCommand(Command parent, String name, String... aliases) {
this.parent = Objects.requireNonNull(parent, "Parent cannot be null");
if (StringUtils.isBlank(name))
throw new NullPointerException("Name is empty");
-
+
// Split the provided name string by semicolons to extract primary name and aliases.
- List list = new ArrayList<>(Arrays.asList(name.split(";")));
- this.name = list.get(0);
+ List list = Arrays.asList(aliases);
+ this.name = name;
this.permission = parent.getPermission() + '.' + this.name;
-
- // Add any aliases if provided.
- if (list.size() > 1) {
- for (int i = 1; i < list.size(); i++) {
- aliases.add(list.get(i));
- }
- }
+ this.aliases.addAll(list);
}
/**