From 3d38aad8d2125fea8be3bd8b2fcaa924932301f1 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 22 Mar 2020 19:58:29 +1300 Subject: [PATCH] Parse itemstacks and itemstack[]s correctly --- .../utilities/params/types/custom/ParamInfoItemStack.java | 4 ++-- .../params/types/custom/ParamInfoItemStackArray.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoItemStack.java b/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoItemStack.java index cfc5086e..94c50396 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoItemStack.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoItemStack.java @@ -106,10 +106,10 @@ public class ParamInfoItemStack extends ParamInfoEnum { split = string.substring(0, string.indexOf("{") - 1).split("[ -]"); split = Arrays.copyOf(split, split.length + 1); split[split.length - 1] = string.substring(string.indexOf("{")); - } else if (string.matches("[^{ ]+?\\{.+?}( [0-9]+?)")) { // /give @p stone[data] + } else if (string.matches("[^{ ]+?\\{.+?}( [0-9]+)?")) { // /give @p stone[data] split = new String[string.endsWith("}") ? 2 : 3]; split[0] = string.substring(0, string.indexOf("{")); - split[string.endsWith("}") ? 2 : 1] = string + split[string.endsWith("}") ? 1 : 2] = string .substring(string.indexOf("{"), string.lastIndexOf("}") + 1); if (!string.endsWith("}")) { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoItemStackArray.java b/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoItemStackArray.java index 8c5336a2..aced1d66 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoItemStackArray.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoItemStackArray.java @@ -75,6 +75,7 @@ public class ParamInfoItemStackArray extends ParamInfoItemStack { } } + // TODO Replace this with better String[] split = string.split(",", -1); if (split.length != 4) { @@ -85,7 +86,7 @@ public class ParamInfoItemStackArray extends ParamInfoItemStack { ItemStack[] items = new ItemStack[4]; for (int a = 0; a < 4; a++) { - items[a] = parseToItemstack(split[a].split(":")); + items[a] = parseToItemstack(split[a]); } return items;