From 55352f6a666741b5711884f7fd50bc9c7b08edcf Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 23 Jan 2019 02:31:32 -0500 Subject: [PATCH] Properly display custom objectives, fixes #625 --- .../java/me/blackvein/quests/Quester.java | 23 ++++--------------- src/main/java/me/blackvein/quests/Quests.java | 6 ++--- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index 4153c755a..7a6792a3b 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -781,11 +781,9 @@ public class Quester { } } } - int index = 0; for (CustomObjective co : getCurrentStage(quest).customObjectives) { + int index = 0; String display = co.getDisplay(); - boolean addUnfinished = false; - boolean addFinished = false; for (Entry entry : getQuestData(quest).customObjectiveCounts.entrySet()) { if (co.getName().equals(entry.getKey())) { Entry datamap = getCurrentStage(quest).customObjectiveData.get(index); @@ -801,22 +799,16 @@ public class Quester { if (co.canShowCount()) { display = display.replace("%count%", entry.getValue() + "/" + getCurrentStage(quest).customObjectiveCounts.get(index)); } - addUnfinished = true; + unfinishedObjectives.add(ChatColor.GREEN + display); } else { if (co.canShowCount()) { display = display.replace("%count%", getCurrentStage(quest).customObjectiveCounts.get(index) + "/" + getCurrentStage(quest).customObjectiveCounts.get(index)); } - addFinished = true; + finishedObjectives.add(ChatColor.GRAY + display); } } + index++; } - if (addUnfinished) { - unfinishedObjectives.add(ChatColor.GREEN + display); - } - if (addFinished) { - finishedObjectives.add(ChatColor.GRAY + display); - } - index++; } objectives.addAll(unfinishedObjectives); objectives.addAll(finishedObjectives); @@ -893,27 +885,20 @@ public class Quester { public boolean hasCustomObjective(Quest quest, String s) { if (getQuestData(quest) == null) { - System.out.println("bing"); return false; } if (getQuestData(quest).customObjectiveCounts.containsKey(s)) { - System.out.println("bang"); int count = getQuestData(quest).customObjectiveCounts.get(s); int index = -1; for (int i = 0; i < getCurrentStage(quest).customObjectives.size(); i++) { - System.out.println("bong"); if (getCurrentStage(quest).customObjectives.get(i).getName().equals(s)) { - System.out.println("bung"); index = i; break; } } int count2 = getCurrentStage(quest).customObjectiveCounts.get(index); - System.out.println("count= " + count); - System.out.println("count2= " + count2); return count <= count2; } - System.out.println("byng"); return false; } diff --git a/src/main/java/me/blackvein/quests/Quests.java b/src/main/java/me/blackvein/quests/Quests.java index 23ccbede5..d93c535af 100644 --- a/src/main/java/me/blackvein/quests/Quests.java +++ b/src/main/java/me/blackvein/quests/Quests.java @@ -1990,14 +1990,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener continue; } else { ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data"); - for (Entry prompt : found.get().getData()) { - Entry data = populateCustoms(sec2, prompt); - oStage.customObjectives.add(found.get()); + oStage.customObjectives.add(found.get()); if (count <= 0) { oStage.customObjectiveCounts.add(0); } else { oStage.customObjectiveCounts.add(count); } + for (Entry prompt : found.get().getData()) { + Entry data = populateCustoms(sec2, prompt); oStage.customObjectiveData.add(data); } }