From 9d4c9a90b5e8e589b4726f23efd8d07270590f02 Mon Sep 17 00:00:00 2001 From: Patrick Zhong <18patz@students.harker.org> Date: Mon, 19 Jun 2017 13:31:45 -0700 Subject: [PATCH 1/2] Fix null bug in #329 --- src/main/java/me/blackvein/quests/Quester.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index 885ca852f..39ab8131e 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -2579,10 +2579,11 @@ public class Quester { } else { String[] completed = new String[completedQuests.size()]; + int index = 0; for (String s : completedQuests) { - completed[completedQuests.indexOf(s)] = s; - + completed[index] = s; + index++; } data.set("completed-Quests", completed); From 605b23defd92639bc11826e287eaec0d0dc6831b Mon Sep 17 00:00:00 2001 From: Patrick Zhong <18patz@students.harker.org> Date: Mon, 19 Jun 2017 16:12:48 -0700 Subject: [PATCH 2/2] Fix duplicate entries --- src/main/java/me/blackvein/quests/Quester.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index 39ab8131e..0037522f3 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -2578,9 +2578,14 @@ public class Quester { } else { - String[] completed = new String[completedQuests.size()]; + List noDupe = new ArrayList(); + for(String s : completedQuests) + if(!noDupe.contains(s)) + noDupe.add(s); + + String[] completed = new String[noDupe.size()]; int index = 0; - for (String s : completedQuests) { + for (String s : noDupe) { completed[index] = s; index++;