aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2018-10-17 11:49:40 +0100
committerLuck <git@lucko.me>2018-10-17 11:49:40 +0100
commit3e59404e86048c2f1c2deed825aadc261bd63c15 (patch)
treeafa1f82853f250a609a8b1f325c494fa7d9a2c3e
parentf88e0977e2f17f0f29bf91ab8e1470e22aafb8b5 (diff)
downloadspark-3e59404e86048c2f1c2deed825aadc261bd63c15.tar.gz
spark-3e59404e86048c2f1c2deed825aadc261bd63c15.tar.bz2
spark-3e59404e86048c2f1c2deed825aadc261bd63c15.zip
Fix argument processing
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java6
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/Arguments.java5
2 files changed, 5 insertions, 6 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java b/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java
index 1de0ec9..fdf7b49 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java
@@ -84,13 +84,13 @@ public abstract class SparkPlatform<S> {
return;
}
- Arguments arguments = new Arguments(args);
- String alias = arguments.raw().remove(0).toLowerCase();
+ ArrayList<String> rawArgs = new ArrayList<>(Arrays.asList(args));
+ String alias = rawArgs.remove(0).toLowerCase();
for (Command<S> command : this.commands) {
if (command.aliases().contains(alias)) {
try {
- command.executor().execute(this, sender, arguments);
+ command.executor().execute(this, sender, new Arguments(rawArgs));
} catch (IllegalArgumentException e) {
sendMessage(sender, "&c" + e.getMessage());
}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/Arguments.java b/spark-common/src/main/java/me/lucko/spark/common/command/Arguments.java
index 4189174..d240554 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/command/Arguments.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/command/Arguments.java
@@ -24,7 +24,6 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.SetMultimap;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -37,8 +36,8 @@ public class Arguments {
private final List<String> rawArgs;
private final SetMultimap<String, String> parsedArgs;
- public Arguments(String[] args) {
- this.rawArgs = new ArrayList<>(Arrays.asList(args));
+ public Arguments(List<String> rawArgs) {
+ this.rawArgs = rawArgs;
this.parsedArgs = HashMultimap.create();
String flag = null;