Adds customization for quest area descriptions
This commit is contained in:
parent
39c0e81a9e
commit
0811886390
@ -131,7 +131,36 @@ public enum QuestsTranslatableMessage implements TranslatableMessage {
|
|||||||
*
|
*
|
||||||
* <p>Placeholders: {permission}</p>
|
* <p>Placeholders: {permission}</p>
|
||||||
*/
|
*/
|
||||||
QUESTS_REQUIREMENTS_REQUIRED_PERMISSION_ITEM;
|
QUESTS_REQUIREMENTS_REQUIRED_PERMISSION_ITEM,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The format for a quest's reach area name
|
||||||
|
*
|
||||||
|
* <p>Placeholders: {name}</p>
|
||||||
|
*/
|
||||||
|
QUESTS_REACH_AREA_NAME_FORMAT,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The format for a quest's reach area's description
|
||||||
|
*
|
||||||
|
* <p>Placeholders: {areaName}, {questName}</p>
|
||||||
|
*/
|
||||||
|
QUESTS_REACH_AREA_DESCRIPTION_FORMAT,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The format for a quest's kill area name
|
||||||
|
*
|
||||||
|
* <p>Placeholders: {name}</p>
|
||||||
|
*/
|
||||||
|
QUESTS_KILL_AREA_NAME_FORMAT,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The format for a quest's kill area description
|
||||||
|
*
|
||||||
|
* <p>Placeholders: {areaName}, {questName}, {mobName}, {mobAmount}</p>
|
||||||
|
*/
|
||||||
|
QUESTS_KILL_AREA_DESCRIPTION_FORMAT,
|
||||||
|
;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TranslatableMessage[] getAllMessages() {
|
public TranslatableMessage[] getAllMessages() {
|
||||||
|
@ -3,9 +3,13 @@ package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
|||||||
import me.blackvein.quests.QuestsAPI;
|
import me.blackvein.quests.QuestsAPI;
|
||||||
import me.blackvein.quests.quests.IQuest;
|
import me.blackvein.quests.quests.IQuest;
|
||||||
import me.blackvein.quests.quests.IStage;
|
import me.blackvein.quests.quests.IStage;
|
||||||
|
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||||
import net.knarcraft.dynmapcitizens.settings.QuestsSettings;
|
import net.knarcraft.dynmapcitizens.settings.QuestsSettings;
|
||||||
import net.knarcraft.dynmapcitizens.util.DynmapHelper;
|
import net.knarcraft.dynmapcitizens.util.DynmapHelper;
|
||||||
import net.knarcraft.dynmapcitizens.util.QuestsHelper;
|
import net.knarcraft.dynmapcitizens.util.QuestsHelper;
|
||||||
|
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||||
|
import net.knarcraft.knarlib.formatting.StringReplacer;
|
||||||
|
import net.knarcraft.knarlib.formatting.Translator;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.dynmap.DynmapAPI;
|
import org.dynmap.DynmapAPI;
|
||||||
@ -14,6 +18,11 @@ import org.dynmap.markers.MarkerSet;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.knarcraft.dynmapcitizens.formatting.QuestsTranslatableMessage.QUESTS_KILL_AREA_DESCRIPTION_FORMAT;
|
||||||
|
import static net.knarcraft.dynmapcitizens.formatting.QuestsTranslatableMessage.QUESTS_KILL_AREA_NAME_FORMAT;
|
||||||
|
import static net.knarcraft.dynmapcitizens.formatting.QuestsTranslatableMessage.QUESTS_REACH_AREA_DESCRIPTION_FORMAT;
|
||||||
|
import static net.knarcraft.dynmapcitizens.formatting.QuestsTranslatableMessage.QUESTS_REACH_AREA_NAME_FORMAT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A handler class for quest areas
|
* A handler class for quest areas
|
||||||
*/
|
*/
|
||||||
@ -24,6 +33,7 @@ public class QuestAreaHandler {
|
|||||||
private final MarkerSet reachAreaMarkerSet;
|
private final MarkerSet reachAreaMarkerSet;
|
||||||
private final QuestsSettings settings;
|
private final QuestsSettings settings;
|
||||||
private final List<IQuest> unavailableQuests;
|
private final List<IQuest> unavailableQuests;
|
||||||
|
private final StringFormatter formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new quest area handler
|
* Instantiates a new quest area handler
|
||||||
@ -38,6 +48,7 @@ public class QuestAreaHandler {
|
|||||||
this.questsAPI = questsAPI;
|
this.questsAPI = questsAPI;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.unavailableQuests = unavailableQuests;
|
this.unavailableQuests = unavailableQuests;
|
||||||
|
this.formatter = DynmapCitizens.getFormatter();
|
||||||
killAreaMarkerSet = DynmapHelper.initializeMarkerSet(dynmapAPI, settings.getKillAreaSettings());
|
killAreaMarkerSet = DynmapHelper.initializeMarkerSet(dynmapAPI, settings.getKillAreaSettings());
|
||||||
reachAreaMarkerSet = DynmapHelper.initializeMarkerSet(dynmapAPI, settings.getReachAreaSettings());
|
reachAreaMarkerSet = DynmapHelper.initializeMarkerSet(dynmapAPI, settings.getReachAreaSettings());
|
||||||
}
|
}
|
||||||
@ -75,11 +86,16 @@ public class QuestAreaHandler {
|
|||||||
Location location = stage.getLocationsToReach().get(i);
|
Location location = stage.getLocationsToReach().get(i);
|
||||||
int radius = stage.getRadiiToReachWithin().get(i);
|
int radius = stage.getRadiiToReachWithin().get(i);
|
||||||
String areaName = stage.getLocationNames().get(i);
|
String areaName = stage.getLocationNames().get(i);
|
||||||
String description = "";
|
|
||||||
|
String formattedAreaName;
|
||||||
if (areaName != null) {
|
if (areaName != null) {
|
||||||
description += "<b>" + areaName + "</b><br>";
|
formattedAreaName = formatter.replacePlaceholder(QUESTS_REACH_AREA_NAME_FORMAT, "{name}", areaName);
|
||||||
|
} else {
|
||||||
|
formattedAreaName = "";
|
||||||
}
|
}
|
||||||
description += "Target location for " + quest.getName();
|
|
||||||
|
String description = formatter.replacePlaceholders(QUESTS_REACH_AREA_DESCRIPTION_FORMAT,
|
||||||
|
new String[]{"{areaName}", "{questName}"}, new String[]{formattedAreaName, quest.getName()});
|
||||||
DynmapHelper.markLocation(location, radius, description, reachAreaMarkerSet, settings.getReachAreaSettings());
|
DynmapHelper.markLocation(location, radius, description, reachAreaMarkerSet, settings.getReachAreaSettings());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,13 +117,20 @@ public class QuestAreaHandler {
|
|||||||
int mobAmount = stage.getMobNumToKill().get(i);
|
int mobAmount = stage.getMobNumToKill().get(i);
|
||||||
String areaName = stage.getKillNames().get(i);
|
String areaName = stage.getKillNames().get(i);
|
||||||
|
|
||||||
String description = "";
|
String formattedAreaName;
|
||||||
if (areaName != null) {
|
if (areaName != null) {
|
||||||
description += "<b>" + areaName + "</b><br>";
|
formattedAreaName = formatter.replacePlaceholder(QUESTS_KILL_AREA_NAME_FORMAT, "{name}", areaName);
|
||||||
|
} else {
|
||||||
|
formattedAreaName = "";
|
||||||
}
|
}
|
||||||
description += "Kill location for " + quest.getName() +
|
|
||||||
"<br>Kill " + QuestsHelper.normalizeName(mob.name()) + " x " + mobAmount;
|
Translator translator = DynmapCitizens.getTranslator();
|
||||||
DynmapHelper.markLocation(location, radius, description, killAreaMarkerSet, settings.getKillAreaSettings());
|
StringReplacer replacer = new StringReplacer(translator.getTranslatedMessage(QUESTS_KILL_AREA_DESCRIPTION_FORMAT));
|
||||||
|
replacer.add("{areaName}", formattedAreaName);
|
||||||
|
replacer.add("{questName}", quest.getName());
|
||||||
|
replacer.add("{mobName}", QuestsHelper.normalizeName(mob.name()));
|
||||||
|
replacer.add("{mobAmount}", String.valueOf(mobAmount));
|
||||||
|
DynmapHelper.markLocation(location, radius, replacer.replace(), killAreaMarkerSet, settings.getKillAreaSettings());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,10 @@ en:
|
|||||||
QUESTS_REQUIREMENTS_MC_MMO_SKILL: "<li>Requires mcMMO skill {skill} at level {level}</li>"
|
QUESTS_REQUIREMENTS_MC_MMO_SKILL: "<li>Requires mcMMO skill {skill} at level {level}</li>"
|
||||||
QUESTS_REQUIREMENTS_REQUIRED_PERMISSION_FORMAT: "<li>Required permissions:<ul>{permissions}</ul></li>"
|
QUESTS_REQUIREMENTS_REQUIRED_PERMISSION_FORMAT: "<li>Required permissions:<ul>{permissions}</ul></li>"
|
||||||
QUESTS_REQUIREMENTS_REQUIRED_PERMISSION_ITEM: "<li>{permission}</li>"
|
QUESTS_REQUIREMENTS_REQUIRED_PERMISSION_ITEM: "<li>{permission}</li>"
|
||||||
|
QUESTS_REACH_AREA_NAME_FORMAT: "<b>{name}</b><br>"
|
||||||
|
QUESTS_REACH_AREA_DESCRIPTION_FORMAT: "{areaName}Target location for {questName}"
|
||||||
|
QUESTS_KILL_AREA_NAME_FORMAT: "<b>{name}</b><br>"
|
||||||
|
QUESTS_KILL_AREA_DESCRIPTION_FORMAT: "{areaName}Kill location for {questName}<br>Kill {mobName} x {mobAmount}"
|
||||||
DURATION_FORMAT: "in {time} {unit}"
|
DURATION_FORMAT: "in {time} {unit}"
|
||||||
UNIT_NOW: "imminently"
|
UNIT_NOW: "imminently"
|
||||||
UNIT_SECOND: "second"
|
UNIT_SECOND: "second"
|
||||||
|
Loading…
Reference in New Issue
Block a user