Parse itemstacks and itemstack[]s correctly

This commit is contained in:
libraryaddict 2020-03-22 19:58:29 +13:00
parent 3231b31282
commit 3d38aad8d2
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
2 changed files with 4 additions and 3 deletions

View File

@ -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] <amount?>
} else if (string.matches("[^{ ]+?\\{.+?}( [0-9]+)?")) { // /give @p stone[data] <amount?>
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("}")) {

View File

@ -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;