Implements settings for limiting quest information
This commit is contained in:
parent
be127d0733
commit
0cbc7ae1b2
@ -29,7 +29,7 @@ public final class DynmapCitizens extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
DynmapCitizens.instance = this;
|
||||||
//Initialize quest and dynmap APIs
|
//Initialize quest and dynmap APIs
|
||||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||||
Plugin dynmapPlugin = pluginManager.getPlugin("dynmap");
|
Plugin dynmapPlugin = pluginManager.getPlugin("dynmap");
|
||||||
@ -40,31 +40,31 @@ public final class DynmapCitizens extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
this.dynmapAPI = dynmapAPI;
|
this.dynmapAPI = dynmapAPI;
|
||||||
|
|
||||||
globalSettings = new GlobalSettings();
|
this.globalSettings = new GlobalSettings();
|
||||||
FileConfiguration configuration = this.getConfig();
|
FileConfiguration configuration = this.getConfig();
|
||||||
this.saveDefaultConfig();
|
this.saveDefaultConfig();
|
||||||
configuration.options().copyDefaults(true);
|
configuration.options().copyDefaults(true);
|
||||||
this.saveConfig();
|
this.saveConfig();
|
||||||
globalSettings.load(configuration);
|
this.globalSettings.load(configuration);
|
||||||
|
|
||||||
//Initialize all enabled traits
|
//Initialize all enabled traits
|
||||||
initializeTraitHandlers(configuration);
|
initializeTraitHandlers(configuration);
|
||||||
|
|
||||||
//Schedule handlers to run periodically
|
//Schedule handlers to run periodically
|
||||||
Bukkit.getScheduler().runTaskTimer(this, () -> {
|
Bukkit.getScheduler().runTaskTimer(this, () -> {
|
||||||
for (CitizensTraitHandler handler : traitHandlers) {
|
for (CitizensTraitHandler handler : this.traitHandlers) {
|
||||||
if (handler.isEnabled()) {
|
if (handler.isEnabled()) {
|
||||||
handler.updateMarkers();
|
handler.updateMarkers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 10 * 20, globalSettings.getUpdateAllMarkersDelay() * 20);
|
}, 10 * 20, this.globalSettings.getUpdateAllMarkersDelay() * 20);
|
||||||
|
|
||||||
vaultHandler = new VaultHandler(this.getServer().getServicesManager());
|
this.vaultHandler = new VaultHandler(this.getServer().getServicesManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
//TODO: Perhaps remove icons, just in case?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,7 +73,7 @@ public final class DynmapCitizens extends JavaPlugin {
|
|||||||
* @return <p>The global settings for this plugin</p>
|
* @return <p>The global settings for this plugin</p>
|
||||||
*/
|
*/
|
||||||
public GlobalSettings getGlobalSettings() {
|
public GlobalSettings getGlobalSettings() {
|
||||||
return globalSettings;
|
return this.globalSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,7 +82,7 @@ public final class DynmapCitizens extends JavaPlugin {
|
|||||||
* @return <p>The Vault handler</p>
|
* @return <p>The Vault handler</p>
|
||||||
*/
|
*/
|
||||||
public VaultHandler getVaultHandler() {
|
public VaultHandler getVaultHandler() {
|
||||||
return vaultHandler;
|
return this.vaultHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,7 +100,7 @@ public final class DynmapCitizens extends JavaPlugin {
|
|||||||
* @return <p>An instance of this plugin</p>
|
* @return <p>An instance of this plugin</p>
|
||||||
*/
|
*/
|
||||||
public static DynmapCitizens getInstance() {
|
public static DynmapCitizens getInstance() {
|
||||||
return instance;
|
return DynmapCitizens.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,14 +110,14 @@ public final class DynmapCitizens extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
private void initializeTraitHandlers(FileConfiguration configuration) {
|
private void initializeTraitHandlers(FileConfiguration configuration) {
|
||||||
//Register all trait handlers
|
//Register all trait handlers
|
||||||
traitHandlers = new ArrayList<>();
|
this.traitHandlers = new ArrayList<>();
|
||||||
traitHandlers.add(new BlacksmithHandler());
|
this.traitHandlers.add(new BlacksmithHandler());
|
||||||
traitHandlers.add(new QuestsHandler());
|
this.traitHandlers.add(new QuestsHandler());
|
||||||
traitHandlers.add(new SentinelHandler());
|
this.traitHandlers.add(new SentinelHandler());
|
||||||
traitHandlers.add(new MinstrelHandler());
|
this.traitHandlers.add(new MinstrelHandler());
|
||||||
|
|
||||||
//Load and initialize all enabled trait handlers
|
//Load and initialize all enabled trait handlers
|
||||||
for (CitizensTraitHandler handler : traitHandlers) {
|
for (CitizensTraitHandler handler : this.traitHandlers) {
|
||||||
//Load configuration values from the config file
|
//Load configuration values from the config file
|
||||||
handler.getSettings().load(configuration);
|
handler.getSettings().load(configuration);
|
||||||
//Check if the handler is enabled in the config before doing anything
|
//Check if the handler is enabled in the config before doing anything
|
||||||
|
@ -61,7 +61,7 @@ public class QuestsHandler extends AbstractTraitHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TraitSettings getSettings() {
|
public TraitSettings getSettings() {
|
||||||
return settings;
|
return this.settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -121,22 +121,14 @@ public class QuestsHandler extends AbstractTraitHandler {
|
|||||||
for (UUID npcId : questGiverInfo.keySet()) {
|
for (UUID npcId : questGiverInfo.keySet()) {
|
||||||
NPCQuestInfo info = questGiverInfo.get(npcId);
|
NPCQuestInfo info = questGiverInfo.get(npcId);
|
||||||
MarkerIcon icon = markerIcons.get(info.getNPCIcon());
|
MarkerIcon icon = markerIcons.get(info.getNPCIcon());
|
||||||
List<IQuest> questStarts = info.getQuestStarts();
|
List<IQuest> offeredQuests = info.getQuestStarts();
|
||||||
StringBuilder markerDescription = new StringBuilder();
|
StringBuilder markerDescription = new StringBuilder();
|
||||||
|
|
||||||
markerDescription.append("<h2>").append(registry.getByUniqueId(npcId).getName()).append("</h2>");
|
markerDescription.append("<h2>").append(registry.getByUniqueId(npcId).getName()).append("</h2>");
|
||||||
|
|
||||||
if (!questStarts.isEmpty()) {
|
//Print info about any offered quests
|
||||||
markerDescription.append("<h3>Quests offered:</h3><ul>");
|
if (!offeredQuests.isEmpty()) {
|
||||||
for (IQuest quest : questStarts) {
|
appendOfferedQuestsInfo(markerDescription, offeredQuests);
|
||||||
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>");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
markerDescription.append(getInvolvedInQuestsString(info));
|
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
|
* Gets information about the quests an NPC is involved in
|
||||||
*
|
*
|
||||||
|
@ -7,9 +7,18 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
*/
|
*/
|
||||||
public class QuestsSettings extends AbstractTraitSettings {
|
public class QuestsSettings extends AbstractTraitSettings {
|
||||||
|
|
||||||
|
private boolean displayRewardInfo;
|
||||||
|
private boolean displayPlannerInfo;
|
||||||
|
private boolean displayStageInfo;
|
||||||
|
private boolean displayRequirementInfo;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(FileConfiguration configuration) {
|
public void load(FileConfiguration configuration) {
|
||||||
super.load(configuration);
|
super.load(configuration);
|
||||||
|
this.displayRewardInfo = configuration.getBoolean(getTraitConfigRoot() + ".displayRewardInfo", true);
|
||||||
|
this.displayPlannerInfo = configuration.getBoolean(getTraitConfigRoot() + ".displayPlannerInfo", true);
|
||||||
|
this.displayStageInfo = configuration.getBoolean(getTraitConfigRoot() + ".displayStageInfo", true);
|
||||||
|
this.displayRequirementInfo = configuration.getBoolean(getTraitConfigRoot() + ".displayRequirementInfo", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -17,4 +26,40 @@ public class QuestsSettings extends AbstractTraitSettings {
|
|||||||
return "traits.quests";
|
return "traits.quests";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether to display reward information as part of quest marker descriptions
|
||||||
|
*
|
||||||
|
* @return <p>True if reward information should be displayed</p>
|
||||||
|
*/
|
||||||
|
public boolean displayRewardInfo() {
|
||||||
|
return this.displayRewardInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether to display planner information, such as cool-down, as part of quest marker descriptions
|
||||||
|
*
|
||||||
|
* @return <p>True if planner information should be displayed</p>
|
||||||
|
*/
|
||||||
|
public boolean displayPlannerInfo() {
|
||||||
|
return this.displayPlannerInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether to display stage (task) information, as part of quest marker descriptions
|
||||||
|
*
|
||||||
|
* @return <p>True if stage information should be displayed</p>
|
||||||
|
*/
|
||||||
|
public boolean displayStageInfo() {
|
||||||
|
return this.displayStageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether to display requirement information, as part of quest marker descriptions
|
||||||
|
*
|
||||||
|
* @return <p>True if reward information should be displayed</p>
|
||||||
|
*/
|
||||||
|
public boolean displayRequirementInfo() {
|
||||||
|
return this.displayRequirementInfo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,6 @@ traits:
|
|||||||
markerSetName: "Quests"
|
markerSetName: "Quests"
|
||||||
# Whether to hide the quest icon layer by default
|
# Whether to hide the quest icon layer by default
|
||||||
markersHiddenByDefault: false
|
markersHiddenByDefault: false
|
||||||
# The priority of quest area markers, such as kill areas
|
|
||||||
areaMarkerPriority: 2
|
|
||||||
# Whether to mark kill areas and similar on the map
|
|
||||||
showAreaMarkers: true
|
|
||||||
# Whether to add information about a quest's rewards to the marker description
|
# Whether to add information about a quest's rewards to the marker description
|
||||||
displayRewardInfo: true
|
displayRewardInfo: true
|
||||||
# Whether to add information about a quest's start date, stop date and cool-down to the marker description
|
# Whether to add information about a quest's start date, stop date and cool-down to the marker description
|
||||||
@ -53,6 +49,7 @@ traits:
|
|||||||
circleMarker:
|
circleMarker:
|
||||||
# Settings for kill zone markers
|
# Settings for kill zone markers
|
||||||
killMarker:
|
killMarker:
|
||||||
|
enabled: true
|
||||||
# The priority of quest kill area markers. Higher priority markers will display on top of lower priority ones
|
# The priority of quest kill area markers. Higher priority markers will display on top of lower priority ones
|
||||||
markerSetPriority: 1
|
markerSetPriority: 1
|
||||||
# The id of the quest kill area marker set. Change if it overlaps with an existing set id
|
# The id of the quest kill area marker set. Change if it overlaps with an existing set id
|
||||||
@ -71,6 +68,7 @@ traits:
|
|||||||
lineThickness: 2
|
lineThickness: 2
|
||||||
# Settings for reach area markers
|
# Settings for reach area markers
|
||||||
reachMarker:
|
reachMarker:
|
||||||
|
enabled: true
|
||||||
# The priority of quest reach area markers. Higher priority markers will display on top of lower priority ones
|
# The priority of quest reach area markers. Higher priority markers will display on top of lower priority ones
|
||||||
markerSetPriority: 1
|
markerSetPriority: 1
|
||||||
# The id of the quest reach area marker set. Change if it overlaps with an existing set id
|
# The id of the quest reach area marker set. Change if it overlaps with an existing set id
|
||||||
|
Loading…
Reference in New Issue
Block a user