From 6ac02914cf0a6420a6cca3ef8c5bb8283fb2f45c Mon Sep 17 00:00:00 2001 From: HappyPikachu Date: Sun, 21 Jan 2018 02:30:24 -0500 Subject: [PATCH] Fix objective duplication, resolves #247 --- .../java/me/blackvein/quests/Quester.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index 735262ab1..0ea23085b 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -1960,13 +1960,13 @@ public class Quester { List durability = questSec.getShortList("blocks-broken-durability"); for (String s : names) { ItemStack is; - if (durability.indexOf((short)names.indexOf(s)) != -1) { + try { is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); - } else { + } catch (IndexOutOfBoundsException e) { // Legacy is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), (short) 0); } - getQuestData(quest).blocksBroken.add(names.indexOf(s), is); + getQuestData(quest).blocksBroken.set(names.indexOf(s), is); } } if (questSec.contains("blocks-damaged-names")) { @@ -1975,9 +1975,9 @@ public class Quester { List durability = questSec.getShortList("blocks-damaged-durability"); for (String s : names) { ItemStack is; - if (durability.indexOf((short)names.indexOf(s)) != -1) { + try { is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); - } else { + } catch (IndexOutOfBoundsException e) { // Legacy is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), (short) 0); } @@ -1990,9 +1990,9 @@ public class Quester { List durability = questSec.getShortList("blocks-placed-durability"); for (String s : names) { ItemStack is; - if (durability.indexOf((short)names.indexOf(s)) != -1) { + try { is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); - } else { + } catch (IndexOutOfBoundsException e) { // Legacy is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), (short) 0); } @@ -2005,9 +2005,9 @@ public class Quester { List durability = questSec.getShortList("blocks-used-durability"); for (String s : names) { ItemStack is; - if (durability.indexOf((short)names.indexOf(s)) != -1) { + try { is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); - } else { + } catch (IndexOutOfBoundsException e) { // Legacy is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), (short) 0); } @@ -2020,9 +2020,9 @@ public class Quester { List durability = questSec.getShortList("blocks-cut-durability"); for (String s : names) { ItemStack is; - if (durability.indexOf((short)names.indexOf(s)) != -1) { + try { is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); - } else { + } catch (IndexOutOfBoundsException e) { // Legacy is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), (short) 0); }