Properly display custom objectives, fixes #625

This commit is contained in:
BuildTools 2019-01-23 02:31:32 -05:00
parent 96b3bceacd
commit 55352f6a66
2 changed files with 7 additions and 22 deletions

View File

@ -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<String, Integer> entry : getQuestData(quest).customObjectiveCounts.entrySet()) {
if (co.getName().equals(entry.getKey())) {
Entry<String, Object> 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;
}

View File

@ -1990,14 +1990,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
continue;
} else {
ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data");
for (Entry<String,Object> prompt : found.get().getData()) {
Entry<String, Object> 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<String,Object> prompt : found.get().getData()) {
Entry<String, Object> data = populateCustoms(sec2, prompt);
oStage.customObjectiveData.add(data);
}
}