diff --git a/core/src/main/java/me/pikamug/quests/storage/implementation/file/BukkitActionYamlStorage.java b/core/src/main/java/me/pikamug/quests/storage/implementation/file/BukkitActionYamlStorage.java index b997931b0..977a3ac80 100644 --- a/core/src/main/java/me/pikamug/quests/storage/implementation/file/BukkitActionYamlStorage.java +++ b/core/src/main/java/me/pikamug/quests/storage/implementation/file/BukkitActionYamlStorage.java @@ -225,12 +225,17 @@ public class BukkitActionYamlStorage implements ActionStorageImpl { for (final Object item : itemList) { final String stack = (String) item; if (stack != null) { - final String itemName = stack.substring(5, stack.indexOf(':')); + final String[] result = stack.split(":"); + if (result.length < 1) { + throw new ActionFormatException("'items' has invalid length", actionKey); + } + final String itemName = result[0].replace("name-", ""); final Material itemMat = Material.matchMaterial(itemName); + final int itemAmt = Integer.parseInt(result[1].replace("amount-", "")); if (itemMat != null) { - temp.add(new ItemStack(itemMat, 1)); + temp.add(new ItemStack(itemMat, itemAmt)); } else { - throw new ActionFormatException("'items' has invalid name" + itemName, actionKey); + throw new ActionFormatException("'items' has invalid name " + itemName, actionKey); } } } diff --git a/core/src/main/java/me/pikamug/quests/storage/implementation/file/BukkitQuestYamlStorage.java b/core/src/main/java/me/pikamug/quests/storage/implementation/file/BukkitQuestYamlStorage.java index e006b1646..d7a68f9cd 100644 --- a/core/src/main/java/me/pikamug/quests/storage/implementation/file/BukkitQuestYamlStorage.java +++ b/core/src/main/java/me/pikamug/quests/storage/implementation/file/BukkitQuestYamlStorage.java @@ -348,12 +348,17 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl { for (final Object item : itemList) { final String stack = (String) item; if (stack != null) { - final String itemName = stack.substring(5, stack.indexOf(':')); + final String[] result = stack.split(":"); + if (result.length < 1) { + throw new QuestFormatException("Reward 'items' has invalid length", questKey); + } + final String itemName = result[0].replace("name-", ""); final Material itemMat = Material.matchMaterial(itemName); + final int itemAmt = Integer.parseInt(result[1].replace("amount-", "")); if (itemMat != null) { - temp.add(new ItemStack(itemMat, 1)); + temp.add(new ItemStack(itemMat, itemAmt)); } else { - throw new QuestFormatException("Reward 'items' has invalid name" + itemName, questKey); + throw new QuestFormatException("Reward 'items' has invalid name " + itemName, questKey); } } } @@ -534,12 +539,17 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl { for (final Object item : itemList) { final String stack = (String) item; if (stack != null) { - final String itemName = stack.substring(5, stack.indexOf(':')); + final String[] result = stack.split(":"); + if (result.length < 1) { + throw new QuestFormatException("Requirement 'items' has invalid length", questKey); + } + final String itemName = result[0].replace("name-", ""); final Material itemMat = Material.matchMaterial(itemName); + final int itemAmt = Integer.parseInt(result[1].replace("amount-", "")); if (itemMat != null) { - temp.add(new ItemStack(itemMat, 1)); + temp.add(new ItemStack(itemMat, itemAmt)); } else { - throw new QuestFormatException("Requirement 'items' has invalid name" + itemName, questKey); + throw new QuestFormatException("Requirement 'items' has invalid name " + itemName, questKey); } } }