Implements settings for limiting quest information

This commit is contained in:
2022-11-03 16:11:46 +01:00
parent be127d0733
commit 0cbc7ae1b2
4 changed files with 96 additions and 33 deletions

View File

@ -61,7 +61,7 @@ public class QuestsHandler extends AbstractTraitHandler {
@Override
public TraitSettings getSettings() {
return settings;
return this.settings;
}
@Override
@ -121,22 +121,14 @@ public class QuestsHandler extends AbstractTraitHandler {
for (UUID npcId : questGiverInfo.keySet()) {
NPCQuestInfo info = questGiverInfo.get(npcId);
MarkerIcon icon = markerIcons.get(info.getNPCIcon());
List<IQuest> questStarts = info.getQuestStarts();
List<IQuest> offeredQuests = info.getQuestStarts();
StringBuilder markerDescription = new StringBuilder();
markerDescription.append("<h2>").append(registry.getByUniqueId(npcId).getName()).append("</h2>");
if (!questStarts.isEmpty()) {
markerDescription.append("<h3>Quests offered:</h3><ul>");
for (IQuest quest : questStarts) {
markerDescription.append("<li><h4><b>").append(quest.getName()).append("</b></h4><h5><b>- ");
markerDescription.append(quest.getDescription()).append("</b></h5>").append(
new QuestStagesInfoGenerator(quest).getQuestStagesInfo());
markerDescription.append(new QuestRewardsInfoGenerator(quest).getQuestRewardsInfo());
markerDescription.append(new QuestRequirementsInfoGenerator(quest).getQuestRequirementsInfo());
markerDescription.append(new QuestPlannerInfoGenerator(quest).getQuestPlannerInfo()).append("</li>");
}
markerDescription.append("</ul>");
//Print info about any offered quests
if (!offeredQuests.isEmpty()) {
appendOfferedQuestsInfo(markerDescription, offeredQuests);
}
markerDescription.append(getInvolvedInQuestsString(info));
@ -153,6 +145,34 @@ public class QuestsHandler extends AbstractTraitHandler {
}
}
/**
* Appends information about an NPC's offered quests to the given string builder
*
* @param stringBuilder <p>The string builder to append to</p>
* @param offeredQuests <p>The list of quests the NPC offers</p>
*/
private void appendOfferedQuestsInfo(StringBuilder stringBuilder, List<IQuest> offeredQuests) {
stringBuilder.append("<h3>Quests offered:</h3><ul>");
for (IQuest quest : offeredQuests) {
stringBuilder.append("<li><h4><b>").append(quest.getName()).append("</b></h4><h5><b>- ");
stringBuilder.append(quest.getDescription()).append("</b></h5>");
if (settings.displayStageInfo()) {
stringBuilder.append(new QuestStagesInfoGenerator(quest).getQuestStagesInfo());
}
if (settings.displayRewardInfo()) {
stringBuilder.append(new QuestRewardsInfoGenerator(quest).getQuestRewardsInfo());
}
if (settings.displayRequirementInfo()) {
stringBuilder.append(new QuestRequirementsInfoGenerator(quest).getQuestRequirementsInfo());
}
if (settings.displayPlannerInfo()) {
stringBuilder.append(new QuestPlannerInfoGenerator(quest).getQuestPlannerInfo());
}
stringBuilder.append("</li>");
}
stringBuilder.append("</ul>");
}
/**
* Gets information about the quests an NPC is involved in
*