Properly display custom objectives, reparation. See #625

This commit is contained in:
BuildTools 2019-01-23 03:31:14 -05:00
parent 55352f6a66
commit 0e9be2cf20
2 changed files with 17 additions and 6 deletions

View File

@ -176,9 +176,11 @@ public abstract class CustomObjective implements Listener {
tempIndex++;
}
if (index > -1) {
Entry<String, Object> e = currentStage.customObjectiveData.get(index);
Map<String, Object> m = new HashMap<String, Object>();
m.put(e.getKey(), e.getValue());
for (int i = index; i < index + data.size(); i++) {
Entry<String, Object> e = currentStage.customObjectiveData.get(index);
m.put(e.getKey(), e.getValue());
}
return m;
}
}

View File

@ -784,12 +784,15 @@ public class Quester {
for (CustomObjective co : getCurrentStage(quest).customObjectives) {
int index = 0;
String display = co.getDisplay();
boolean addUnfinished = false;
boolean addFinished = false;
for (Entry<String, Integer> entry : getQuestData(quest).customObjectiveCounts.entrySet()) {
if (co.getName().equals(entry.getKey())) {
Entry<String, Object> datamap = getCurrentStage(quest).customObjectiveData.get(index);
for (Entry<String,Object> prompt : co.getData()) {
String replacement = "%" + prompt.getKey() + "%";
try {
display = display.replace("%" + prompt.getKey() + "%", ((String) datamap.getValue()));
if (display.contains(replacement))
display = display.replace(replacement, ((String) getCurrentStage(quest).customObjectiveData.get(index).getValue()));
} catch (NullPointerException ne) {
plugin.getLogger().severe("Unable to fetch display for " + co.getName() + " on " + quest.getName());
ne.printStackTrace();
@ -799,16 +802,22 @@ public class Quester {
if (co.canShowCount()) {
display = display.replace("%count%", entry.getValue() + "/" + getCurrentStage(quest).customObjectiveCounts.get(index));
}
unfinishedObjectives.add(ChatColor.GREEN + display);
addUnfinished = true;
} else {
if (co.canShowCount()) {
display = display.replace("%count%", getCurrentStage(quest).customObjectiveCounts.get(index) + "/" + getCurrentStage(quest).customObjectiveCounts.get(index));
}
finishedObjectives.add(ChatColor.GRAY + display);
addFinished = true;
}
}
index++;
}
if (addUnfinished) {
unfinishedObjectives.add(ChatColor.GREEN + display);
}
if (addFinished) {
finishedObjectives.add(ChatColor.GRAY + display);
}
}
objectives.addAll(unfinishedObjectives);
objectives.addAll(finishedObjectives);