Merge branch 'custom-formatting' into quests-5

# Conflicts:
#	src/main/java/net/knarcraft/dynmapcitizens/handler/trait/quests/NPCQuestInfo.java
#	src/main/java/net/knarcraft/dynmapcitizens/handler/trait/quests/QuestAreaHandler.java
#	src/main/java/net/knarcraft/dynmapcitizens/handler/trait/quests/QuestPlannerInfoGenerator.java
#	src/main/java/net/knarcraft/dynmapcitizens/handler/trait/quests/QuestRequirementsInfoGenerator.java
#	src/main/java/net/knarcraft/dynmapcitizens/handler/trait/quests/QuestRewardsInfoGenerator.java
#	src/main/java/net/knarcraft/dynmapcitizens/handler/trait/quests/QuestStagesInfoGenerator.java
#	src/main/java/net/knarcraft/dynmapcitizens/handler/trait/quests/QuestsHandler.java
#	src/main/java/net/knarcraft/dynmapcitizens/util/QuestsHelper.java
This commit is contained in:
Kristian Knarvik 2024-01-02 22:04:43 +01:00
commit 6e2832d616
27 changed files with 159 additions and 115 deletions

View File

@ -19,6 +19,7 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.dynmap.DynmapAPI; import org.dynmap.DynmapAPI;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -112,7 +113,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 @NotNull GlobalSettings getGlobalSettings() {
return this.globalSettings; return this.globalSettings;
} }
@ -121,7 +122,7 @@ public final class DynmapCitizens extends JavaPlugin {
* *
* @return <p>The Vault handler</p> * @return <p>The Vault handler</p>
*/ */
public VaultHandler getVaultHandler() { public @NotNull VaultHandler getVaultHandler() {
return this.vaultHandler; return this.vaultHandler;
} }
@ -130,7 +131,7 @@ public final class DynmapCitizens extends JavaPlugin {
* *
* @return <p>A reference to the Dynmap API</p> * @return <p>A reference to the Dynmap API</p>
*/ */
public DynmapAPI getDynmapAPI() { public @NotNull DynmapAPI getDynmapAPI() {
return this.dynmapAPIInstance; return this.dynmapAPIInstance;
} }
@ -148,7 +149,7 @@ public final class DynmapCitizens extends JavaPlugin {
* *
* @param configuration <p>The configuration to read settings from</p> * @param configuration <p>The configuration to read settings from</p>
*/ */
private void initializeTraitHandlers(FileConfiguration configuration) { private void initializeTraitHandlers(@NotNull FileConfiguration configuration) {
//Register all trait handlers //Register all trait handlers
this.traitHandlers = new ArrayList<>(); this.traitHandlers = new ArrayList<>();
this.traitHandlers.add(new BlacksmithHandler()); this.traitHandlers.add(new BlacksmithHandler());

View File

@ -3,6 +3,7 @@ package net.knarcraft.dynmapcitizens.handler;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicesManager; import org.bukkit.plugin.ServicesManager;
import org.jetbrains.annotations.NotNull;
/** /**
* A class to keep track of everything Vault * A class to keep track of everything Vault
@ -16,7 +17,7 @@ public class VaultHandler {
* *
* @param servicesManager <p>The services manager to get the Vault service from</p> * @param servicesManager <p>The services manager to get the Vault service from</p>
*/ */
public VaultHandler(ServicesManager servicesManager) { public VaultHandler(@NotNull ServicesManager servicesManager) {
RegisteredServiceProvider<Economy> economyProvider = servicesManager.getRegistration(Economy.class); RegisteredServiceProvider<Economy> economyProvider = servicesManager.getRegistration(Economy.class);
if (economyProvider != null) { if (economyProvider != null) {
economy = economyProvider.getProvider(); economy = economyProvider.getProvider();
@ -37,7 +38,7 @@ public class VaultHandler {
* *
* @return <p>The currency name</p> * @return <p>The currency name</p>
*/ */
public String getCurrency(boolean plural) { public @NotNull String getCurrency(boolean plural) {
if (plural) { if (plural) {
return economy.currencyNamePlural(); return economy.currencyNamePlural();
} else { } else {

View File

@ -12,6 +12,7 @@ import org.dynmap.DynmapAPI;
import org.dynmap.markers.Marker; import org.dynmap.markers.Marker;
import org.dynmap.markers.MarkerIcon; import org.dynmap.markers.MarkerIcon;
import org.dynmap.markers.MarkerSet; import org.dynmap.markers.MarkerSet;
import org.jetbrains.annotations.NotNull;
import java.util.UUID; import java.util.UUID;
@ -51,7 +52,8 @@ public abstract class AbstractTraitHandler implements CitizensTraitHandler {
* @param icon <p>The icon used for the marker</p> * @param icon <p>The icon used for the marker</p>
* @param markerSet <p>The marker set to add the marker to</p> * @param markerSet <p>The marker set to add the marker to</p>
*/ */
protected void addNPCMarker(UUID npcId, String markerName, String markerDescription, MarkerIcon icon, MarkerSet markerSet) { protected void addNPCMarker(@NotNull UUID npcId, @NotNull String markerName, @NotNull String markerDescription,
@NotNull MarkerIcon icon, @NotNull MarkerSet markerSet) {
NPC npc = CitizensAPI.getNPCRegistry().getByUniqueId(npcId); NPC npc = CitizensAPI.getNPCRegistry().getByUniqueId(npcId);
//If the NPC has been removed, abort //If the NPC has been removed, abort
if (npc == null) { if (npc == null) {
@ -89,7 +91,7 @@ public abstract class AbstractTraitHandler implements CitizensTraitHandler {
* @param npc <p>The NPC to check</p> * @param npc <p>The NPC to check</p>
* @return <p>True if the NPC is currently moving about</p> * @return <p>True if the NPC is currently moving about</p>
*/ */
protected boolean isMoving(NPC npc) { protected boolean isMoving(@NotNull NPC npc) {
return npc.getNavigator().getTargetAsLocation() != null; return npc.getNavigator().getTargetAsLocation() != null;
} }

View File

@ -13,6 +13,7 @@ import net.knarcraft.dynmapcitizens.settings.TraitSettings;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.dynmap.markers.GenericMarker; import org.dynmap.markers.GenericMarker;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -27,7 +28,8 @@ public class BlacksmithHandler extends AbstractTraitHandler {
@Override @Override
public void initialize() { public void initialize() {
BlacksmithPlugin blacksmithPlugin = (BlacksmithPlugin) Bukkit.getServer().getPluginManager().getPlugin("Blacksmith"); BlacksmithPlugin blacksmithPlugin = (BlacksmithPlugin) Bukkit.getServer().getPluginManager().getPlugin(
"Blacksmith");
if (blacksmithPlugin != null) { if (blacksmithPlugin != null) {
super.initializeMarkerSet(); super.initializeMarkerSet();
} else { } else {
@ -36,7 +38,7 @@ public class BlacksmithHandler extends AbstractTraitHandler {
} }
@Override @Override
public TraitSettings getSettings() { public @NotNull TraitSettings getSettings() {
return this.settings; return this.settings;
} }
@ -49,7 +51,7 @@ public class BlacksmithHandler extends AbstractTraitHandler {
for (NPC npc : CitizensAPI.getNPCRegistry()) { for (NPC npc : CitizensAPI.getNPCRegistry()) {
if (npc.hasTrait(blacksmithTrait)) { if (npc.hasTrait(blacksmithTrait)) {
BlacksmithTrait trait = npc.getTraitNullable(BlacksmithTrait.class); BlacksmithTrait trait = npc.getTraitNullable(BlacksmithTrait.class);
String description = null; String description = "";
if (trait == null) { if (trait == null) {
DynmapCitizens.getInstance().getLogger().log(Level.WARNING, "Unable to get blacksmith trait"); DynmapCitizens.getInstance().getLogger().log(Level.WARNING, "Unable to get blacksmith trait");
} else { } else {
@ -69,7 +71,7 @@ public class BlacksmithHandler extends AbstractTraitHandler {
* @param npcSettings <p>The settings to search for information</p> * @param npcSettings <p>The settings to search for information</p>
* @return <p>A string describing the blacksmith</p> * @return <p>A string describing the blacksmith</p>
*/ */
private String getDetailedBlacksmithInfo(NPC npc, NPCSettings npcSettings) { private @NotNull String getDetailedBlacksmithInfo(@NotNull NPC npc, @NotNull NPCSettings npcSettings) {
String info = "<h2>" + npc.getName() + " the " + String info = "<h2>" + npc.getName() + " the " +
npcSettings.getBlacksmithTitle() + "</h2>"; npcSettings.getBlacksmithTitle() + "</h2>";
if (settings.displayBlacksmithSettings()) { if (settings.displayBlacksmithSettings()) {
@ -91,7 +93,7 @@ public class BlacksmithHandler extends AbstractTraitHandler {
* @param materials <p>The materials specified as reforge-able items</p> * @param materials <p>The materials specified as reforge-able items</p>
* @return <p>The reforge-able items</p> * @return <p>The reforge-able items</p>
*/ */
private static String getReforgeAbleItemsString(List<Material> materials) { private static @NotNull String getReforgeAbleItemsString(@NotNull List<Material> materials) {
List<String> materialNames = new ArrayList<>(); List<String> materialNames = new ArrayList<>();
for (Material material : materials) { for (Material material : materials) {
materialNames.add(material.name()); materialNames.add(material.name());

View File

@ -1,6 +1,7 @@
package net.knarcraft.dynmapcitizens.handler.trait; package net.knarcraft.dynmapcitizens.handler.trait;
import net.knarcraft.dynmapcitizens.settings.TraitSettings; import net.knarcraft.dynmapcitizens.settings.TraitSettings;
import org.jetbrains.annotations.NotNull;
/** /**
* A handler which takes care of everything for one citizen trait * A handler which takes care of everything for one citizen trait
@ -24,7 +25,7 @@ public interface CitizensTraitHandler {
* *
* @return <p>The settings for this trait</p> * @return <p>The settings for this trait</p>
*/ */
TraitSettings getSettings(); @NotNull TraitSettings getSettings();
/** /**
* Updates all markers used for this handler * Updates all markers used for this handler

View File

@ -8,6 +8,7 @@ import net.knarcraft.dynmapcitizens.property.Icon;
import net.knarcraft.dynmapcitizens.settings.DTLTradersSettings; import net.knarcraft.dynmapcitizens.settings.DTLTradersSettings;
import net.knarcraft.dynmapcitizens.settings.TraitSettings; import net.knarcraft.dynmapcitizens.settings.TraitSettings;
import org.dynmap.markers.GenericMarker; import org.dynmap.markers.GenericMarker;
import org.jetbrains.annotations.NotNull;
/** /**
* A handler class for the minstrel trait * A handler class for the minstrel trait
@ -31,7 +32,7 @@ public class DTLTradersHandler extends AbstractTraitHandler {
} }
@Override @Override
public TraitSettings getSettings() { public @NotNull TraitSettings getSettings() {
return this.settings; return this.settings;
} }

View File

@ -12,6 +12,7 @@ import net.knarcraft.minstrel.music.Song;
import net.knarcraft.minstrel.trait.MinstrelTrait; import net.knarcraft.minstrel.trait.MinstrelTrait;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.dynmap.markers.GenericMarker; import org.dynmap.markers.GenericMarker;
import org.jetbrains.annotations.NotNull;
import java.util.logging.Level; import java.util.logging.Level;
@ -33,7 +34,7 @@ public class MinstrelHandler extends AbstractTraitHandler {
} }
@Override @Override
public TraitSettings getSettings() { public @NotNull TraitSettings getSettings() {
return this.settings; return this.settings;
} }
@ -46,7 +47,7 @@ public class MinstrelHandler extends AbstractTraitHandler {
for (NPC npc : CitizensAPI.getNPCRegistry()) { for (NPC npc : CitizensAPI.getNPCRegistry()) {
if (npc.hasTrait(minstrelTrait)) { if (npc.hasTrait(minstrelTrait)) {
MinstrelTrait trait = npc.getTraitNullable(MinstrelTrait.class); MinstrelTrait trait = npc.getTraitNullable(MinstrelTrait.class);
String description = null; String description = "";
if (trait == null) { if (trait == null) {
DynmapCitizens.getInstance().getLogger().log(Level.WARNING, "Unable to get minstrel trait"); DynmapCitizens.getInstance().getLogger().log(Level.WARNING, "Unable to get minstrel trait");
} else { } else {

View File

@ -9,6 +9,7 @@ import net.knarcraft.dynmapcitizens.settings.SentinelSettings;
import net.knarcraft.dynmapcitizens.settings.TraitSettings; import net.knarcraft.dynmapcitizens.settings.TraitSettings;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.dynmap.markers.GenericMarker; import org.dynmap.markers.GenericMarker;
import org.jetbrains.annotations.NotNull;
import org.mcmonkey.sentinel.SentinelPlugin; import org.mcmonkey.sentinel.SentinelPlugin;
import org.mcmonkey.sentinel.SentinelTrait; import org.mcmonkey.sentinel.SentinelTrait;
@ -30,7 +31,7 @@ public class SentinelHandler extends AbstractTraitHandler {
} }
@Override @Override
public TraitSettings getSettings() { public @NotNull TraitSettings getSettings() {
return this.settings; return this.settings;
} }

View File

@ -2,6 +2,7 @@ package net.knarcraft.dynmapcitizens.handler.trait.quests;
import me.pikamug.quests.quests.Quest; import me.pikamug.quests.quests.Quest;
import net.knarcraft.dynmapcitizens.property.Icon; import net.knarcraft.dynmapcitizens.property.Icon;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -21,7 +22,7 @@ public class NPCQuestInfo {
* *
* @param quest <p>The quest to add</p> * @param quest <p>The quest to add</p>
*/ */
public void addQuestStart(Quest quest) { public void addQuestStart(@NotNull Quest quest) {
this.questStart.add(quest); this.questStart.add(quest);
} }
@ -30,7 +31,7 @@ public class NPCQuestInfo {
* *
* @param quest <p>The quest to add</p> * @param quest <p>The quest to add</p>
*/ */
public void addQuestKill(Quest quest) { public void addQuestKill(@NotNull Quest quest) {
this.questKill.add(quest); this.questKill.add(quest);
} }
@ -39,7 +40,7 @@ public class NPCQuestInfo {
* *
* @param quest <p>The quest to add</p> * @param quest <p>The quest to add</p>
*/ */
public void addQuestDeliver(Quest quest) { public void addQuestDeliver(@NotNull Quest quest) {
this.questDeliver.add(quest); this.questDeliver.add(quest);
} }
@ -48,7 +49,7 @@ public class NPCQuestInfo {
* *
* @param quest <p>The quest to add</p> * @param quest <p>The quest to add</p>
*/ */
public void addQuestInteract(Quest quest) { public void addQuestInteract(@NotNull Quest quest) {
this.questInteract.add(quest); this.questInteract.add(quest);
} }
@ -57,7 +58,7 @@ public class NPCQuestInfo {
* *
* @return <p>All quests this NPC is used to start</p> * @return <p>All quests this NPC is used to start</p>
*/ */
public List<Quest> getQuestStarts() { public @NotNull List<Quest> getQuestStarts() {
return new ArrayList<>(this.questStart); return new ArrayList<>(this.questStart);
} }
@ -66,7 +67,7 @@ public class NPCQuestInfo {
* *
* @return <p>All kill quests involving this NPC</p> * @return <p>All kill quests involving this NPC</p>
*/ */
public List<Quest> getQuestKills() { public @NotNull List<Quest> getQuestKills() {
return new ArrayList<>(this.questKill); return new ArrayList<>(this.questKill);
} }
@ -75,7 +76,7 @@ public class NPCQuestInfo {
* *
* @return <p>All quests delivering to this NPC</p> * @return <p>All quests delivering to this NPC</p>
*/ */
public List<Quest> getQuestDeliveries() { public @NotNull List<Quest> getQuestDeliveries() {
return new ArrayList<>(this.questDeliver); return new ArrayList<>(this.questDeliver);
} }
@ -84,7 +85,7 @@ public class NPCQuestInfo {
* *
* @return <p>All quests requiring interaction with this NPC</p> * @return <p>All quests requiring interaction with this NPC</p>
*/ */
public List<Quest> getQuestInteractions() { public @NotNull List<Quest> getQuestInteractions() {
return new ArrayList<>(this.questInteract); return new ArrayList<>(this.questInteract);
} }
@ -93,7 +94,7 @@ public class NPCQuestInfo {
* *
* @return <p>The main type of the quest NPC</p> * @return <p>The main type of the quest NPC</p>
*/ */
public QuestNPCType getQuestNPCType() { public @NotNull QuestNPCType getQuestNPCType() {
if (!questStart.isEmpty()) { if (!questStart.isEmpty()) {
return QuestNPCType.GIVER; return QuestNPCType.GIVER;
} else if (!questKill.isEmpty() && questInteract.isEmpty() && questDeliver.isEmpty()) { } else if (!questKill.isEmpty() && questInteract.isEmpty() && questDeliver.isEmpty()) {
@ -112,7 +113,7 @@ public class NPCQuestInfo {
* *
* @return <p>The icon used to mark this NPC</p> * @return <p>The icon used to mark this NPC</p>
*/ */
public Icon getNPCIcon() { public @NotNull Icon getNPCIcon() {
QuestNPCType type = getQuestNPCType(); QuestNPCType type = getQuestNPCType();
return switch (type) { return switch (type) {
case KILL -> Icon.QUEST_KILL; case KILL -> Icon.QUEST_KILL;

View File

@ -15,6 +15,7 @@ import org.bukkit.entity.EntityType;
import org.dynmap.DynmapAPI; import org.dynmap.DynmapAPI;
import org.dynmap.markers.GenericMarker; import org.dynmap.markers.GenericMarker;
import org.dynmap.markers.MarkerSet; import org.dynmap.markers.MarkerSet;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
@ -43,8 +44,8 @@ public class QuestAreaHandler {
* @param settings <p>The quests settings to use</p> * @param settings <p>The quests settings to use</p>
* @param unavailableQuests <p>The list of currently unavailable quests to possibly skip</p> * @param unavailableQuests <p>The list of currently unavailable quests to possibly skip</p>
*/ */
public QuestAreaHandler(Quests questsAPI, DynmapAPI dynmapAPI, QuestsSettings settings, public QuestAreaHandler(@NotNull Quests questsAPI, @NotNull DynmapAPI dynmapAPI, @NotNull QuestsSettings settings,
List<Quest> unavailableQuests) { @NotNull List<Quest> unavailableQuests) {
this.questsAPI = questsAPI; this.questsAPI = questsAPI;
this.settings = settings; this.settings = settings;
this.unavailableQuests = unavailableQuests; this.unavailableQuests = unavailableQuests;
@ -78,7 +79,7 @@ public class QuestAreaHandler {
* @param quest <p>The quest the stage belongs to</p> * @param quest <p>The quest the stage belongs to</p>
* @param stage <p>The stage to search for reach locations</p> * @param stage <p>The stage to search for reach locations</p>
*/ */
private void markReachLocations(Quest quest, Stage stage) { private void markReachLocations(@NotNull Quest quest, @NotNull Stage stage) {
if (settings.getReachAreaSettings().isDisabled()) { if (settings.getReachAreaSettings().isDisabled()) {
return; return;
} }
@ -106,7 +107,7 @@ public class QuestAreaHandler {
* @param quest <p>The quest the stage belongs to</p> * @param quest <p>The quest the stage belongs to</p>
* @param stage <p>The stage to search for kill locations</p> * @param stage <p>The stage to search for kill locations</p>
*/ */
private void markKillLocations(Quest quest, Stage stage) { private void markKillLocations(@NotNull Quest quest, @NotNull Stage stage) {
if (settings.getKillAreaSettings().isDisabled()) { if (settings.getKillAreaSettings().isDisabled()) {
return; return;
} }

View File

@ -1,5 +1,7 @@
package net.knarcraft.dynmapcitizens.handler.trait.quests; package net.knarcraft.dynmapcitizens.handler.trait.quests;
import org.jetbrains.annotations.NotNull;
/** /**
* A specifier for a quest NPC's main type * A specifier for a quest NPC's main type
*/ */
@ -8,26 +10,47 @@ public enum QuestNPCType {
/** /**
* An NPC responsible for giving quests * An NPC responsible for giving quests
*/ */
GIVER, GIVER("Quest Start NPC: "),
/** /**
* An NPC killed in a quest * An NPC killed in a quest
*/ */
KILL, KILL("Quest Kill NPC: "),
/** /**
* An NPC set as the delivery target in a quest * An NPC set as the delivery target in a quest
*/ */
DELIVER, DELIVER("Quest Deliver NPC: "),
/** /**
* An NPC to be interacted with in a quest * An NPC to be interacted with in a quest
*/ */
INTERACT, INTERACT("Quest Interact NPC: "),
/** /**
* An NPC which is not a quest giver, but has several tasks as part of other quests * An NPC which is not a quest giver, but has several tasks as part of other quests
*/ */
CHAIN CHAIN("Quest Chain NPC: "),
;
private final String markerTitle;
/**
* Instantiates a new Quest NPC type
*
* @param markerTitle <p>The title of the marker for this type of quest NPC</p>
*/
QuestNPCType(@NotNull String markerTitle) {
this.markerTitle = markerTitle;
}
/**
* Gets the marker title for this Quest NPC type
*
* @return <p>The marker title</p>
*/
public String getMarkerTitle() {
return this.markerTitle;
}
} }

View File

@ -4,6 +4,7 @@ import me.pikamug.quests.quests.Quest;
import me.pikamug.quests.quests.components.Planner; import me.pikamug.quests.quests.components.Planner;
import net.knarcraft.dynmapcitizens.DynmapCitizens; import net.knarcraft.dynmapcitizens.DynmapCitizens;
import net.knarcraft.knarlib.formatting.TimeFormatter; import net.knarcraft.knarlib.formatting.TimeFormatter;
import org.jetbrains.annotations.NotNull;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -21,7 +22,7 @@ public class QuestPlannerInfoGenerator {
* *
* @param quest <p>The quest to generate information about</p> * @param quest <p>The quest to generate information about</p>
*/ */
public QuestPlannerInfoGenerator(Quest quest) { public QuestPlannerInfoGenerator(@NotNull Quest quest) {
this.quest = quest; this.quest = quest;
} }
@ -30,7 +31,7 @@ public class QuestPlannerInfoGenerator {
* *
* @return <p>Information about when the quest is available</p> * @return <p>Information about when the quest is available</p>
*/ */
public String getQuestPlannerInfo() { public @NotNull String getQuestPlannerInfo() {
Planner planner = quest.getPlanner(); Planner planner = quest.getPlanner();
StringBuilder plannerInfo = new StringBuilder(); StringBuilder plannerInfo = new StringBuilder();
plannerInfo.append("<b>Planner:</b><ul>"); plannerInfo.append("<b>Planner:</b><ul>");
@ -74,7 +75,7 @@ public class QuestPlannerInfoGenerator {
* @param timestamp <p>A timestamp in milliseconds</p> * @param timestamp <p>A timestamp in milliseconds</p>
* @return <p>A datetime string</p> * @return <p>A datetime string</p>
*/ */
private String formatTimestamp(long timestamp) { private @NotNull String formatTimestamp(long timestamp) {
DateFormat format = new SimpleDateFormat("dd MM yyyy HH:mm:ss"); DateFormat format = new SimpleDateFormat("dd MM yyyy HH:mm:ss");
Date date = new Date(timestamp); Date date = new Date(timestamp);
return format.format(date); return format.format(date);

View File

@ -9,6 +9,8 @@ import net.knarcraft.knarlib.formatting.StringFormatter;
import net.knarcraft.knarlib.formatting.StringReplacer; import net.knarcraft.knarlib.formatting.StringReplacer;
import net.knarcraft.knarlib.formatting.TranslatableMessage; import net.knarcraft.knarlib.formatting.TranslatableMessage;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -42,7 +44,7 @@ public class QuestRequirementsInfoGenerator {
* @param questsAPI <p>The API to use for getting quest information</p> * @param questsAPI <p>The API to use for getting quest information</p>
* @param quest <p>The quest to generate information about</p> * @param quest <p>The quest to generate information about</p>
*/ */
public QuestRequirementsInfoGenerator(Quests questsAPI, Quest quest) { public QuestRequirementsInfoGenerator(@NotNull Quests questsAPI, @NotNull Quest quest) {
this.questsAPI = questsAPI; this.questsAPI = questsAPI;
this.quest = quest; this.quest = quest;
formatter = DynmapCitizens.getFormatter(); formatter = DynmapCitizens.getFormatter();
@ -53,7 +55,7 @@ public class QuestRequirementsInfoGenerator {
* *
* @return <p>Information about the quest's requirements</p> * @return <p>Information about the quest's requirements</p>
*/ */
public String getQuestRequirementsInfo() { public @NotNull String getQuestRequirementsInfo() {
Requirements requirements = quest.getRequirements(); Requirements requirements = quest.getRequirements();
if (!requirements.hasRequirement()) { if (!requirements.hasRequirement()) {
return ""; return "";
@ -131,7 +133,7 @@ public class QuestRequirementsInfoGenerator {
* @param items <p>The items to get the names of</p> * @param items <p>The items to get the names of</p>
* @return <p>The names of the given items</p> * @return <p>The names of the given items</p>
*/ */
private List<String> getItemNames(List<?> items) { private @NotNull List<String> getItemNames(@NotNull List<?> items) {
List<String> itemNames = new ArrayList<>(); List<String> itemNames = new ArrayList<>();
for (Object itemStack : items) { for (Object itemStack : items) {
itemNames.add(QuestsHelper.getUpperCasedItemStackString((ItemStack) itemStack)); itemNames.add(QuestsHelper.getUpperCasedItemStackString((ItemStack) itemStack));
@ -145,7 +147,7 @@ public class QuestRequirementsInfoGenerator {
* @param questIds <p>The quests to get names for</p> * @param questIds <p>The quests to get names for</p>
* @return <p>A list of quest names</p> * @return <p>A list of quest names</p>
*/ */
private List<String> getQuestNames(List<String> questIds) { private @NotNull List<String> getQuestNames(@NotNull List<String> questIds) {
List<String> questNames = new ArrayList<>(questIds.size()); List<String> questNames = new ArrayList<>(questIds.size());
for (String questId : questIds) { for (String questId : questIds) {
Quest quest = getQuest(questId); Quest quest = getQuest(questId);
@ -162,7 +164,7 @@ public class QuestRequirementsInfoGenerator {
* @param questId <p>The id of the quest to get</p> * @param questId <p>The id of the quest to get</p>
* @return <p>The quest, or null if not found</p> * @return <p>The quest, or null if not found</p>
*/ */
private Quest getQuest(String questId) { private @Nullable Quest getQuest(@NotNull String questId) {
for (Quest quest : questsAPI.getLoadedQuests()) { for (Quest quest : questsAPI.getLoadedQuests()) {
if (quest.getId().equals(questId)) { if (quest.getId().equals(questId)) {
return quest; return quest;
@ -181,8 +183,9 @@ public class QuestRequirementsInfoGenerator {
* @param itemPlaceholder <p>The placeholder to replace with each item in the list</p> * @param itemPlaceholder <p>The placeholder to replace with each item in the list</p>
* @return <p>The string corresponding to the given requirement list</p> * @return <p>The string corresponding to the given requirement list</p>
*/ */
private String getRequirementList(List<String> itemList, TranslatableMessage formatMessage, String formatPlaceholder, private @NotNull String getRequirementList(@NotNull List<String> itemList, @NotNull TranslatableMessage formatMessage,
TranslatableMessage itemMessage, String itemPlaceholder) { @NotNull String formatPlaceholder, @NotNull TranslatableMessage itemMessage,
@NotNull String itemPlaceholder) {
StringBuilder blockedBuilder = new StringBuilder(); StringBuilder blockedBuilder = new StringBuilder();
for (Object requirements : itemList) { for (Object requirements : itemList) {
blockedBuilder.append(formatter.replacePlaceholder(itemMessage, itemPlaceholder, blockedBuilder.append(formatter.replacePlaceholder(itemMessage, itemPlaceholder,

View File

@ -4,6 +4,8 @@ import me.pikamug.quests.quests.Quest;
import me.pikamug.quests.quests.components.Rewards; import me.pikamug.quests.quests.components.Rewards;
import net.knarcraft.dynmapcitizens.util.QuestsHelper; import net.knarcraft.dynmapcitizens.util.QuestsHelper;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.NotNull;
/** /**
* A class to generate a string containing all information about a quest's rewards * A class to generate a string containing all information about a quest's rewards
@ -17,7 +19,7 @@ public class QuestRewardsInfoGenerator {
* *
* @param quest <p>The quest to generate information about</p> * @param quest <p>The quest to generate information about</p>
*/ */
public QuestRewardsInfoGenerator(Quest quest) { public QuestRewardsInfoGenerator(@NotNull Quest quest) {
this.quest = quest; this.quest = quest;
} }
@ -26,13 +28,14 @@ public class QuestRewardsInfoGenerator {
* *
* @return <p>Information about the quest's rewards</p> * @return <p>Information about the quest's rewards</p>
*/ */
public String getQuestRewardsInfo() { public @NotNull String getQuestRewardsInfo() {
Rewards reward = quest.getRewards(); Rewards reward = quest.getRewards();
StringBuilder rewardInfo = new StringBuilder(); StringBuilder rewardInfo = new StringBuilder();
rewardInfo.append("<b>Rewards:</b><ul>"); rewardInfo.append("<b>Rewards:</b><ul>");
if (reward.getMoney() > 0) { if (reward.getMoney() > 0) {
rewardInfo.append("<li>").append(reward.getMoney()).append(" ").append(QuestsHelper.getCurrency(reward.getMoney())).append("</li>"); rewardInfo.append("<li>").append(reward.getMoney()).append(" ").append(QuestsHelper.getCurrency(
reward.getMoney())).append("</li>");
} }
if (reward.getExp() > 0) { if (reward.getExp() > 0) {

View File

@ -9,6 +9,7 @@ import net.knarcraft.dynmapcitizens.util.QuestsHelper;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -25,7 +26,7 @@ public class QuestStagesInfoGenerator {
* *
* @param quest <p>The quest to generate information about</p> * @param quest <p>The quest to generate information about</p>
*/ */
public QuestStagesInfoGenerator(Quest quest) { public QuestStagesInfoGenerator(@NotNull Quest quest) {
this.quest = quest; this.quest = quest;
} }
@ -34,7 +35,7 @@ public class QuestStagesInfoGenerator {
* *
* @return <p>A string with information about the quest's stages</p> * @return <p>A string with information about the quest's stages</p>
*/ */
public String getQuestStagesInfo() { public @NotNull String getQuestStagesInfo() {
StringBuilder questInfo = new StringBuilder(); StringBuilder questInfo = new StringBuilder();
NPCRegistry registry = CitizensAPI.getNPCRegistry(); NPCRegistry registry = CitizensAPI.getNPCRegistry();
int stageCounter = 1; int stageCounter = 1;
@ -65,7 +66,7 @@ public class QuestStagesInfoGenerator {
* @param registry <p>The registry to get NPC info from</p> * @param registry <p>The registry to get NPC info from</p>
* @return <p>Information about the stage's tasks</p> * @return <p>Information about the stage's tasks</p>
*/ */
private String getStageInfo(Stage stage, NPCRegistry registry) { private @NotNull String getStageInfo(@NotNull Stage stage, @NotNull NPCRegistry registry) {
StringBuilder questInfo = new StringBuilder(); StringBuilder questInfo = new StringBuilder();
int mobTypes = stage.getMobsToKill().size(); int mobTypes = stage.getMobsToKill().size();
for (int i = 0; i < mobTypes; i++) { for (int i = 0; i < mobTypes; i++) {
@ -135,7 +136,7 @@ public class QuestStagesInfoGenerator {
* @param location <p>The location to show</p> * @param location <p>The location to show</p>
* @return <p>A human-friendly location string</p> * @return <p>A human-friendly location string</p>
*/ */
private String getLocationString(Location location) { private @NotNull String getLocationString(@NotNull Location location) {
String locationString = location.getX() + "," + location.getY() + "," + location.getZ(); String locationString = location.getX() + "," + location.getY() + "," + location.getZ();
if (location.getWorld() != null) { if (location.getWorld() != null) {
locationString += " in world \"" + location.getWorld().getName() + "\""; locationString += " in world \"" + location.getWorld().getName() + "\"";
@ -150,7 +151,7 @@ public class QuestStagesInfoGenerator {
* @param explanation <p>The explanation of what the player needs to do with the items</p> * @param explanation <p>The explanation of what the player needs to do with the items</p>
* @return <p>A string describing the necessary tasks</p> * @return <p>A string describing the necessary tasks</p>
*/ */
private String getQuestItemsTaskString(List<?> items, String explanation) { private @NotNull String getQuestItemsTaskString(@NotNull List<?> items, @NotNull String explanation) {
StringBuilder questInfo = new StringBuilder(); StringBuilder questInfo = new StringBuilder();
for (Object itemStack : items) { for (Object itemStack : items) {
questInfo.append(explanation).append(QuestsHelper.getItemStackString((ItemStack) itemStack)); questInfo.append(explanation).append(QuestsHelper.getItemStackString((ItemStack) itemStack));

View File

@ -16,6 +16,7 @@ import org.dynmap.DynmapAPI;
import org.dynmap.markers.GenericMarker; import org.dynmap.markers.GenericMarker;
import org.dynmap.markers.Marker; import org.dynmap.markers.Marker;
import org.dynmap.markers.MarkerIcon; import org.dynmap.markers.MarkerIcon;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -52,7 +53,7 @@ public class QuestsHandler extends AbstractTraitHandler {
} }
@Override @Override
public TraitSettings getSettings() { public @NotNull TraitSettings getSettings() {
return this.settings; return this.settings;
} }
@ -140,7 +141,7 @@ public class QuestsHandler extends AbstractTraitHandler {
existingMarker.setDescription(newDescription); existingMarker.setDescription(newDescription);
} }
} else { } else {
addNPCMarker(npcId, QuestsHelper.getMarkerTitle(info.getQuestNPCType()), newDescription, icon, super.markerSet); addNPCMarker(npcId, info.getQuestNPCType().getMarkerTitle(), newDescription, icon, super.markerSet);
} }
} }
} }
@ -151,7 +152,7 @@ public class QuestsHandler extends AbstractTraitHandler {
* @param stringBuilder <p>The string builder to append to</p> * @param stringBuilder <p>The string builder to append to</p>
* @param offeredQuests <p>The list of quests the NPC offers</p> * @param offeredQuests <p>The list of quests the NPC offers</p>
*/ */
private void appendOfferedQuestsInfo(StringBuilder stringBuilder, List<Quest> offeredQuests) { private void appendOfferedQuestsInfo(@NotNull StringBuilder stringBuilder, @NotNull List<Quest> offeredQuests) {
stringBuilder.append("<h3>Quests offered:</h3><ul>"); stringBuilder.append("<h3>Quests offered:</h3><ul>");
for (Quest quest : offeredQuests) { for (Quest quest : offeredQuests) {
stringBuilder.append("<li><h4><b>").append(quest.getName()).append("</b></h4><h5><b>- "); stringBuilder.append("<li><h4><b>").append(quest.getName()).append("</b></h4><h5><b>- ");
@ -179,7 +180,7 @@ public class QuestsHandler extends AbstractTraitHandler {
* @param info <p>The NPC info to look through</p> * @param info <p>The NPC info to look through</p>
* @return <p>Information about an NPC's involvement in different quests</p> * @return <p>Information about an NPC's involvement in different quests</p>
*/ */
private String getInvolvedInQuestsString(NPCQuestInfo info) { private String getInvolvedInQuestsString(@NotNull NPCQuestInfo info) {
List<Quest> questKills = info.getQuestKills(); List<Quest> questKills = info.getQuestKills();
List<Quest> questInteractions = info.getQuestInteractions(); List<Quest> questInteractions = info.getQuestInteractions();
List<Quest> questDeliveries = info.getQuestDeliveries(); List<Quest> questDeliveries = info.getQuestDeliveries();
@ -203,7 +204,8 @@ public class QuestsHandler extends AbstractTraitHandler {
* @param quests <p>The quests the NPC is involved in</p> * @param quests <p>The quests the NPC is involved in</p>
* @param builder <p>The string builder to append to</p> * @param builder <p>The string builder to append to</p>
*/ */
private void addInvolvedInString(String prefix, List<Quest> quests, StringBuilder builder) { private void addInvolvedInString(@NotNull String prefix, @NotNull List<Quest> quests,
@NotNull StringBuilder builder) {
for (Quest quest : new HashSet<>(quests)) { for (Quest quest : new HashSet<>(quests)) {
builder.append("<li>").append(prefix).append(": ").append(quest.getName()).append("</li>"); builder.append("<li>").append(prefix).append(": ").append(quest.getName()).append("</li>");
} }
@ -216,7 +218,7 @@ public class QuestsHandler extends AbstractTraitHandler {
* @param npcId <p>The id of the NPC to get information about</p> * @param npcId <p>The id of the NPC to get information about</p>
* @return <p>The NPC's info object</p> * @return <p>The NPC's info object</p>
*/ */
private NPCQuestInfo getInfo(UUID npcId) { private @NotNull NPCQuestInfo getInfo(@NotNull UUID npcId) {
if (questGiverInfo.get(npcId) == null) { if (questGiverInfo.get(npcId) == null) {
questGiverInfo.put(npcId, new NPCQuestInfo()); questGiverInfo.put(npcId, new NPCQuestInfo());
} }

View File

@ -1,6 +1,7 @@
package net.knarcraft.dynmapcitizens.settings; package net.knarcraft.dynmapcitizens.settings;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
/** /**
* An abstract implementation of trait settings * An abstract implementation of trait settings
@ -14,7 +15,7 @@ public abstract class AbstractTraitSettings implements TraitSettings {
private String markerSetName; private String markerSetName;
@Override @Override
public void load(FileConfiguration configuration) { public void load(@NotNull FileConfiguration configuration) {
this.isEnabled = configuration.getBoolean(getTraitConfigRoot() + ".enabled", false); this.isEnabled = configuration.getBoolean(getTraitConfigRoot() + ".enabled", false);
this.markerSetId = configuration.getString(getTraitConfigRoot() + ".markerSetId", null); this.markerSetId = configuration.getString(getTraitConfigRoot() + ".markerSetId", null);
this.markerSetPriority = configuration.getInt(getTraitConfigRoot() + ".markerSetPriority", 1); this.markerSetPriority = configuration.getInt(getTraitConfigRoot() + ".markerSetPriority", 1);
@ -28,12 +29,12 @@ public abstract class AbstractTraitSettings implements TraitSettings {
} }
@Override @Override
public String getMarkerSetId() { public @NotNull String getMarkerSetId() {
return markerSetId; return markerSetId;
} }
@Override @Override
public String getMarkerSetName() { public @NotNull String getMarkerSetName() {
return markerSetName; return markerSetName;
} }
@ -52,6 +53,6 @@ public abstract class AbstractTraitSettings implements TraitSettings {
* *
* @return <p>The root config node for this trait's settings</p> * @return <p>The root config node for this trait's settings</p>
*/ */
protected abstract String getTraitConfigRoot(); protected abstract @NotNull String getTraitConfigRoot();
} }

View File

@ -1,6 +1,7 @@
package net.knarcraft.dynmapcitizens.settings; package net.knarcraft.dynmapcitizens.settings;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
/** /**
* Stores information about one kind of area marker * Stores information about one kind of area marker
@ -24,7 +25,7 @@ public class AreaMarkerSettings {
* @param fileConfiguration <p>The file configuration to load settings from</p> * @param fileConfiguration <p>The file configuration to load settings from</p>
* @param configRoot <p>The config root node containing all config values for one marker</p> * @param configRoot <p>The config root node containing all config values for one marker</p>
*/ */
public void load(FileConfiguration fileConfiguration, String configRoot) { public void load(@NotNull FileConfiguration fileConfiguration, @NotNull String configRoot) {
this.enabled = fileConfiguration.getBoolean(configRoot + ".enabled", false); this.enabled = fileConfiguration.getBoolean(configRoot + ".enabled", false);
this.markerSetPriority = fileConfiguration.getInt(configRoot + ".markerSetPriority", 1); this.markerSetPriority = fileConfiguration.getInt(configRoot + ".markerSetPriority", 1);
this.markerSetId = fileConfiguration.getString(configRoot + ".markerSetId", null); this.markerSetId = fileConfiguration.getString(configRoot + ".markerSetId", null);
@ -60,7 +61,7 @@ public class AreaMarkerSettings {
* *
* @return <p>The dynmap id of this marker set</p> * @return <p>The dynmap id of this marker set</p>
*/ */
public String getMarkerSetId() { public @NotNull String getMarkerSetId() {
return this.markerSetId; return this.markerSetId;
} }
@ -69,7 +70,7 @@ public class AreaMarkerSettings {
* *
* @return <p>The name of this marker set</p> * @return <p>The name of this marker set</p>
*/ */
public String getMarkerSetName() { public @NotNull String getMarkerSetName() {
return this.markerSetName; return this.markerSetName;
} }
@ -87,7 +88,7 @@ public class AreaMarkerSettings {
* *
* @return <p>The marker fill color</p> * @return <p>The marker fill color</p>
*/ */
public String getFillColor() { public @NotNull String getFillColor() {
return this.fillColor; return this.fillColor;
} }
@ -96,7 +97,7 @@ public class AreaMarkerSettings {
* *
* @return <p>The marker outline color</p> * @return <p>The marker outline color</p>
*/ */
public String getLineColor() { public @NotNull String getLineColor() {
return this.lineColor; return this.lineColor;
} }

View File

@ -1,6 +1,7 @@
package net.knarcraft.dynmapcitizens.settings; package net.knarcraft.dynmapcitizens.settings;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
/** /**
* All settings for the blacksmith trait * All settings for the blacksmith trait
@ -10,13 +11,13 @@ public class BlacksmithSettings extends AbstractTraitSettings {
private boolean displayBlacksmithSettings; private boolean displayBlacksmithSettings;
@Override @Override
public void load(FileConfiguration configuration) { public void load(@NotNull FileConfiguration configuration) {
super.load(configuration); super.load(configuration);
displayBlacksmithSettings = configuration.getBoolean(getTraitConfigRoot() + ".displayBlacksmithSettings", true); displayBlacksmithSettings = configuration.getBoolean(getTraitConfigRoot() + ".displayBlacksmithSettings", true);
} }
@Override @Override
protected String getTraitConfigRoot() { protected @NotNull String getTraitConfigRoot() {
return "traits.blacksmith"; return "traits.blacksmith";
} }

View File

@ -1,6 +1,7 @@
package net.knarcraft.dynmapcitizens.settings; package net.knarcraft.dynmapcitizens.settings;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
/** /**
* All settings for the minstrel trait * All settings for the minstrel trait
@ -8,12 +9,12 @@ import org.bukkit.configuration.file.FileConfiguration;
public class DTLTradersSettings extends AbstractTraitSettings { public class DTLTradersSettings extends AbstractTraitSettings {
@Override @Override
public void load(FileConfiguration configuration) { public void load(@NotNull FileConfiguration configuration) {
super.load(configuration); super.load(configuration);
} }
@Override @Override
protected String getTraitConfigRoot() { protected @NotNull String getTraitConfigRoot() {
return "traits.trader"; return "traits.trader";
} }

View File

@ -6,6 +6,7 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.dynmap.DynmapAPI; import org.dynmap.DynmapAPI;
import org.dynmap.markers.MarkerAPI; import org.dynmap.markers.MarkerAPI;
import org.dynmap.markers.MarkerIcon; import org.dynmap.markers.MarkerIcon;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -24,7 +25,7 @@ public class GlobalSettings {
* *
* @param configuration <p>The configuration to load from</p> * @param configuration <p>The configuration to load from</p>
*/ */
public void load(FileConfiguration configuration) { public void load(@NotNull FileConfiguration configuration) {
DynmapAPI dynmapAPI = DynmapCitizens.getInstance().getDynmapAPI(); DynmapAPI dynmapAPI = DynmapCitizens.getInstance().getDynmapAPI();
MarkerAPI markerAPI = dynmapAPI.getMarkerAPI(); MarkerAPI markerAPI = dynmapAPI.getMarkerAPI();
@ -43,7 +44,7 @@ public class GlobalSettings {
* *
* @return <p>The marker icons to use</p> * @return <p>The marker icons to use</p>
*/ */
public Map<Icon, MarkerIcon> getMarkerIcons() { public @NotNull Map<Icon, MarkerIcon> getMarkerIcons() {
return new HashMap<>(markerIcons); return new HashMap<>(markerIcons);
} }
@ -71,7 +72,7 @@ public class GlobalSettings {
* @param icon <p>The icon identifier to get the icon for</p> * @param icon <p>The icon identifier to get the icon for</p>
* @return <p>The default icon name</p> * @return <p>The default icon name</p>
*/ */
private String getDefaultIconName(Icon icon) { private @NotNull String getDefaultIconName(@NotNull Icon icon) {
//The advantage of this switch over a map is that it will throw an error if a case is missing //The advantage of this switch over a map is that it will throw an error if a case is missing
return switch (icon) { return switch (icon) {
case QUEST_GIVER -> "exclamation"; case QUEST_GIVER -> "exclamation";

View File

@ -1,6 +1,7 @@
package net.knarcraft.dynmapcitizens.settings; package net.knarcraft.dynmapcitizens.settings;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
/** /**
* All settings for the minstrel trait * All settings for the minstrel trait
@ -10,13 +11,13 @@ public class MinstrelSettings extends AbstractTraitSettings {
private boolean displayMinstrelSongs; private boolean displayMinstrelSongs;
@Override @Override
public void load(FileConfiguration configuration) { public void load(@NotNull FileConfiguration configuration) {
super.load(configuration); super.load(configuration);
displayMinstrelSongs = configuration.getBoolean(getTraitConfigRoot() + ".displayMinstrelSongs", true); displayMinstrelSongs = configuration.getBoolean(getTraitConfigRoot() + ".displayMinstrelSongs", true);
} }
@Override @Override
protected String getTraitConfigRoot() { protected @NotNull String getTraitConfigRoot() {
return "traits.minstrel"; return "traits.minstrel";
} }

View File

@ -1,6 +1,7 @@
package net.knarcraft.dynmapcitizens.settings; package net.knarcraft.dynmapcitizens.settings;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
/** /**
* All settings for the quests trait * All settings for the quests trait
@ -16,7 +17,7 @@ public class QuestsSettings extends AbstractTraitSettings {
private final AreaMarkerSettings reachAreaSettings = new AreaMarkerSettings(); private final AreaMarkerSettings reachAreaSettings = new AreaMarkerSettings();
@Override @Override
public void load(FileConfiguration configuration) { public void load(@NotNull FileConfiguration configuration) {
super.load(configuration); super.load(configuration);
this.displayRewardInfo = configuration.getBoolean(getTraitConfigRoot() + ".displayRewardInfo", true); this.displayRewardInfo = configuration.getBoolean(getTraitConfigRoot() + ".displayRewardInfo", true);
this.displayPlannerInfo = configuration.getBoolean(getTraitConfigRoot() + ".displayPlannerInfo", true); this.displayPlannerInfo = configuration.getBoolean(getTraitConfigRoot() + ".displayPlannerInfo", true);
@ -28,7 +29,7 @@ public class QuestsSettings extends AbstractTraitSettings {
} }
@Override @Override
protected String getTraitConfigRoot() { protected @NotNull String getTraitConfigRoot() {
return "traits.quests"; return "traits.quests";
} }
@ -82,7 +83,7 @@ public class QuestsSettings extends AbstractTraitSettings {
* *
* @return <p>Settings for the kill area markers</p> * @return <p>Settings for the kill area markers</p>
*/ */
public AreaMarkerSettings getKillAreaSettings() { public @NotNull AreaMarkerSettings getKillAreaSettings() {
return killAreaSettings; return killAreaSettings;
} }
@ -91,7 +92,7 @@ public class QuestsSettings extends AbstractTraitSettings {
* *
* @return <p>Settings for the reach area markers</p> * @return <p>Settings for the reach area markers</p>
*/ */
public AreaMarkerSettings getReachAreaSettings() { public @NotNull AreaMarkerSettings getReachAreaSettings() {
return reachAreaSettings; return reachAreaSettings;
} }

View File

@ -1,6 +1,7 @@
package net.knarcraft.dynmapcitizens.settings; package net.knarcraft.dynmapcitizens.settings;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
/** /**
* All settings for the sentinel trait * All settings for the sentinel trait
@ -10,13 +11,13 @@ public class SentinelSettings extends AbstractTraitSettings {
private boolean displaySentinelStats; private boolean displaySentinelStats;
@Override @Override
public void load(FileConfiguration configuration) { public void load(@NotNull FileConfiguration configuration) {
super.load(configuration); super.load(configuration);
displaySentinelStats = configuration.getBoolean(getTraitConfigRoot() + ".displaySentinelStats", true); displaySentinelStats = configuration.getBoolean(getTraitConfigRoot() + ".displaySentinelStats", true);
} }
@Override @Override
protected String getTraitConfigRoot() { protected @NotNull String getTraitConfigRoot() {
return "traits.sentinel"; return "traits.sentinel";
} }

View File

@ -1,6 +1,7 @@
package net.knarcraft.dynmapcitizens.settings; package net.knarcraft.dynmapcitizens.settings;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
/** /**
* An interface describing a generic trait settings class * An interface describing a generic trait settings class
@ -12,7 +13,7 @@ public interface TraitSettings {
* *
* @param configuration <p>The configuration to load values from</p> * @param configuration <p>The configuration to load values from</p>
*/ */
void load(FileConfiguration configuration); void load(@NotNull FileConfiguration configuration);
/** /**
* Gets whether this trait type is enabled in the config * Gets whether this trait type is enabled in the config
@ -28,14 +29,14 @@ public interface TraitSettings {
* *
* @return <p>The id of the marker set</p> * @return <p>The id of the marker set</p>
*/ */
String getMarkerSetId(); @NotNull String getMarkerSetId();
/** /**
* Gets the name of this trait's marker set * Gets the name of this trait's marker set
* *
* @return <p>The name of the marker set</p> * @return <p>The name of the marker set</p>
*/ */
String getMarkerSetName(); @NotNull String getMarkerSetName();
/** /**
* Gets the priority of the trait's marker set * Gets the priority of the trait's marker set

View File

@ -7,6 +7,8 @@ import org.bukkit.World;
import org.dynmap.DynmapAPI; import org.dynmap.DynmapAPI;
import org.dynmap.markers.CircleMarker; import org.dynmap.markers.CircleMarker;
import org.dynmap.markers.MarkerSet; import org.dynmap.markers.MarkerSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.logging.Level; import java.util.logging.Level;
@ -20,7 +22,8 @@ public class DynmapHelper {
* @param label <p>The label of the marker set if creation is necessary</p> * @param label <p>The label of the marker set if creation is necessary</p>
* @return <p>The marker set, or null if something went wrong</p> * @return <p>The marker set, or null if something went wrong</p>
*/ */
public static MarkerSet getMarkerSet(DynmapAPI dynmapAPI, String setId, String label) { public static @Nullable MarkerSet getMarkerSet(@NotNull DynmapAPI dynmapAPI, @NotNull String setId,
@NotNull String label) {
MarkerSet markerSet = dynmapAPI.getMarkerAPI().getMarkerSet(setId); MarkerSet markerSet = dynmapAPI.getMarkerAPI().getMarkerSet(setId);
if (markerSet == null) { if (markerSet == null) {
markerSet = dynmapAPI.getMarkerAPI().createMarkerSet(setId, label, null, false); markerSet = dynmapAPI.getMarkerAPI().createMarkerSet(setId, label, null, false);
@ -41,7 +44,8 @@ public class DynmapHelper {
* @param markerSettings <p>The settings to use for initialization</p> * @param markerSettings <p>The settings to use for initialization</p>
* @return <p>The initialized marker</p> * @return <p>The initialized marker</p>
*/ */
public static MarkerSet initializeMarkerSet(DynmapAPI dynmapAPI, AreaMarkerSettings markerSettings) { public static @Nullable MarkerSet initializeMarkerSet(@NotNull DynmapAPI dynmapAPI,
@NotNull AreaMarkerSettings markerSettings) {
MarkerSet markerSet = DynmapHelper.getMarkerSet(dynmapAPI, markerSettings.getMarkerSetId(), MarkerSet markerSet = DynmapHelper.getMarkerSet(dynmapAPI, markerSettings.getMarkerSetId(),
markerSettings.getMarkerSetName()); markerSettings.getMarkerSetName());
if (markerSet != null) { if (markerSet != null) {
@ -60,8 +64,9 @@ public class DynmapHelper {
* @param markerSet <p>The marker set to use when marking the location</p> * @param markerSet <p>The marker set to use when marking the location</p>
* @param markerSettings <p>The settings to use for the marker</p> * @param markerSettings <p>The settings to use for the marker</p>
*/ */
public static void markLocation(Location location, Integer radius, String description, MarkerSet markerSet, public static void markLocation(@NotNull Location location, @NotNull Integer radius,
AreaMarkerSettings markerSettings) { @NotNull String description, @NotNull MarkerSet markerSet,
@NotNull AreaMarkerSettings markerSettings) {
//Skip if location is invalid //Skip if location is invalid
World world = location.getWorld(); World world = location.getWorld();
if (world == null) { if (world == null) {
@ -86,7 +91,7 @@ public class DynmapHelper {
* @param color <p>A hexadecimal color</p> * @param color <p>A hexadecimal color</p>
* @return <p>An integer representation of the color</p> * @return <p>An integer representation of the color</p>
*/ */
private static int getColor(String color) { private static int getColor(@NotNull String color) {
try { try {
return Integer.parseInt(color, 16); return Integer.parseInt(color, 16);
} catch (NumberFormatException exception) { } catch (NumberFormatException exception) {

View File

@ -6,6 +6,7 @@ import net.knarcraft.dynmapcitizens.DynmapCitizens;
import net.knarcraft.dynmapcitizens.handler.VaultHandler; import net.knarcraft.dynmapcitizens.handler.VaultHandler;
import net.knarcraft.dynmapcitizens.handler.trait.quests.QuestNPCType; import net.knarcraft.dynmapcitizens.handler.trait.quests.QuestNPCType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/** /**
* A helper class for various quests-related tasks * A helper class for various quests-related tasks
@ -18,7 +19,7 @@ public class QuestsHelper {
* @param itemStack <p>The item stack to get the string for</p> * @param itemStack <p>The item stack to get the string for</p>
* @return <p>A string describing the item stack</p> * @return <p>A string describing the item stack</p>
*/ */
public static String getUpperCasedItemStackString(ItemStack itemStack) { public static @NotNull String getUpperCasedItemStackString(@NotNull ItemStack itemStack) {
return uppercaseFirst(getItemStackString(itemStack)); return uppercaseFirst(getItemStackString(itemStack));
} }
@ -28,7 +29,7 @@ public class QuestsHelper {
* @param itemStack <p>The item stack to print</p> * @param itemStack <p>The item stack to print</p>
* @return <p>The string representation of the item stack</p> * @return <p>The string representation of the item stack</p>
*/ */
public static String getItemStackString(ItemStack itemStack) { public static @NotNull String getItemStackString(@NotNull ItemStack itemStack) {
return normalizeName(itemStack.getType().name()) + " x " + itemStack.getAmount(); return normalizeName(itemStack.getType().name()) + " x " + itemStack.getAmount();
} }
@ -38,7 +39,7 @@ public class QuestsHelper {
* @param string <p>The string to run on</p> * @param string <p>The string to run on</p>
* @return <p>The same string, with the first character converted to uppercase</p> * @return <p>The same string, with the first character converted to uppercase</p>
*/ */
private static String uppercaseFirst(String string) { private static @NotNull String uppercaseFirst(@NotNull String string) {
return string.substring(0, 1).toUpperCase() + string.substring(1); return string.substring(0, 1).toUpperCase() + string.substring(1);
} }
@ -48,7 +49,7 @@ public class QuestsHelper {
* @param name <p>The name to normalize</p> * @param name <p>The name to normalize</p>
* @return <p>The normalized name</p> * @return <p>The normalized name</p>
*/ */
public static String normalizeName(String name) { public static @NotNull String normalizeName(@NotNull String name) {
return name.toLowerCase().replace("_", " "); return name.toLowerCase().replace("_", " ");
} }
@ -58,7 +59,7 @@ public class QuestsHelper {
* @param money <p>The amount to pay/use</p> * @param money <p>The amount to pay/use</p>
* @return <p>The currency name to use</p> * @return <p>The currency name to use</p>
*/ */
public static String getCurrency(double money) { public static @NotNull String getCurrency(double money) {
VaultHandler vaultHandler = DynmapCitizens.getInstance().getVaultHandler(); VaultHandler vaultHandler = DynmapCitizens.getInstance().getVaultHandler();
if (vaultHandler.isEnabled()) { if (vaultHandler.isEnabled()) {
return vaultHandler.getCurrency(money != 1); return vaultHandler.getCurrency(money != 1);
@ -67,29 +68,13 @@ public class QuestsHelper {
} }
} }
/**
* Gets the marker title to use for the given quest NPC type
*
* @param type <p>The type of marker to get the title for</p>
* @return <p>The title to use for the marker</p>
*/
public static String getMarkerTitle(QuestNPCType type) {
return switch (type) {
case GIVER -> "Quest Start NPC: ";
case INTERACT -> "Quest Interact NPC: ";
case DELIVER -> "Quest Deliver NPC: ";
case KILL -> "Quest Kill NPC: ";
case CHAIN -> "Quest Chain NPC: ";
};
}
/** /**
* Checks whether the given quest is unavailable, according to its planner information * Checks whether the given quest is unavailable, according to its planner information
* *
* @param quest <p>The quest to check for availability</p> * @param quest <p>The quest to check for availability</p>
* @return <p>True if the quest is unavailable</p> * @return <p>True if the quest is unavailable</p>
*/ */
public static boolean isQuestUnavailable(Quest quest) { public static boolean isQuestUnavailable(@NotNull Quest quest) {
Planner planner = quest.getPlanner(); Planner planner = quest.getPlanner();
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();