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:
commit
6e2832d616
@ -19,6 +19,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.dynmap.DynmapAPI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -112,7 +113,7 @@ public final class DynmapCitizens extends JavaPlugin {
|
||||
*
|
||||
* @return <p>The global settings for this plugin</p>
|
||||
*/
|
||||
public GlobalSettings getGlobalSettings() {
|
||||
public @NotNull GlobalSettings getGlobalSettings() {
|
||||
return this.globalSettings;
|
||||
}
|
||||
|
||||
@ -121,7 +122,7 @@ public final class DynmapCitizens extends JavaPlugin {
|
||||
*
|
||||
* @return <p>The Vault handler</p>
|
||||
*/
|
||||
public VaultHandler getVaultHandler() {
|
||||
public @NotNull VaultHandler getVaultHandler() {
|
||||
return this.vaultHandler;
|
||||
}
|
||||
|
||||
@ -130,7 +131,7 @@ public final class DynmapCitizens extends JavaPlugin {
|
||||
*
|
||||
* @return <p>A reference to the Dynmap API</p>
|
||||
*/
|
||||
public DynmapAPI getDynmapAPI() {
|
||||
public @NotNull DynmapAPI getDynmapAPI() {
|
||||
return this.dynmapAPIInstance;
|
||||
}
|
||||
|
||||
@ -148,7 +149,7 @@ public final class DynmapCitizens extends JavaPlugin {
|
||||
*
|
||||
* @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
|
||||
this.traitHandlers = new ArrayList<>();
|
||||
this.traitHandlers.add(new BlacksmithHandler());
|
||||
|
@ -3,6 +3,7 @@ package net.knarcraft.dynmapcitizens.handler;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
public VaultHandler(ServicesManager servicesManager) {
|
||||
public VaultHandler(@NotNull ServicesManager servicesManager) {
|
||||
RegisteredServiceProvider<Economy> economyProvider = servicesManager.getRegistration(Economy.class);
|
||||
if (economyProvider != null) {
|
||||
economy = economyProvider.getProvider();
|
||||
@ -37,7 +38,7 @@ public class VaultHandler {
|
||||
*
|
||||
* @return <p>The currency name</p>
|
||||
*/
|
||||
public String getCurrency(boolean plural) {
|
||||
public @NotNull String getCurrency(boolean plural) {
|
||||
if (plural) {
|
||||
return economy.currencyNamePlural();
|
||||
} else {
|
||||
|
@ -12,6 +12,7 @@ import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.markers.Marker;
|
||||
import org.dynmap.markers.MarkerIcon;
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
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 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);
|
||||
//If the NPC has been removed, abort
|
||||
if (npc == null) {
|
||||
@ -89,7 +91,7 @@ public abstract class AbstractTraitHandler implements CitizensTraitHandler {
|
||||
* @param npc <p>The NPC to check</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;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import net.knarcraft.dynmapcitizens.settings.TraitSettings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.dynmap.markers.GenericMarker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -27,7 +28,8 @@ public class BlacksmithHandler extends AbstractTraitHandler {
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
BlacksmithPlugin blacksmithPlugin = (BlacksmithPlugin) Bukkit.getServer().getPluginManager().getPlugin("Blacksmith");
|
||||
BlacksmithPlugin blacksmithPlugin = (BlacksmithPlugin) Bukkit.getServer().getPluginManager().getPlugin(
|
||||
"Blacksmith");
|
||||
if (blacksmithPlugin != null) {
|
||||
super.initializeMarkerSet();
|
||||
} else {
|
||||
@ -36,7 +38,7 @@ public class BlacksmithHandler extends AbstractTraitHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraitSettings getSettings() {
|
||||
public @NotNull TraitSettings getSettings() {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
@ -49,7 +51,7 @@ public class BlacksmithHandler extends AbstractTraitHandler {
|
||||
for (NPC npc : CitizensAPI.getNPCRegistry()) {
|
||||
if (npc.hasTrait(blacksmithTrait)) {
|
||||
BlacksmithTrait trait = npc.getTraitNullable(BlacksmithTrait.class);
|
||||
String description = null;
|
||||
String description = "";
|
||||
if (trait == null) {
|
||||
DynmapCitizens.getInstance().getLogger().log(Level.WARNING, "Unable to get blacksmith trait");
|
||||
} else {
|
||||
@ -69,7 +71,7 @@ public class BlacksmithHandler extends AbstractTraitHandler {
|
||||
* @param npcSettings <p>The settings to search for information</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 " +
|
||||
npcSettings.getBlacksmithTitle() + "</h2>";
|
||||
if (settings.displayBlacksmithSettings()) {
|
||||
@ -91,7 +93,7 @@ public class BlacksmithHandler extends AbstractTraitHandler {
|
||||
* @param materials <p>The materials specified as 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<>();
|
||||
for (Material material : materials) {
|
||||
materialNames.add(material.name());
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.dynmapcitizens.handler.trait;
|
||||
|
||||
import net.knarcraft.dynmapcitizens.settings.TraitSettings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
TraitSettings getSettings();
|
||||
@NotNull TraitSettings getSettings();
|
||||
|
||||
/**
|
||||
* Updates all markers used for this handler
|
||||
|
@ -8,6 +8,7 @@ import net.knarcraft.dynmapcitizens.property.Icon;
|
||||
import net.knarcraft.dynmapcitizens.settings.DTLTradersSettings;
|
||||
import net.knarcraft.dynmapcitizens.settings.TraitSettings;
|
||||
import org.dynmap.markers.GenericMarker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A handler class for the minstrel trait
|
||||
@ -31,7 +32,7 @@ public class DTLTradersHandler extends AbstractTraitHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraitSettings getSettings() {
|
||||
public @NotNull TraitSettings getSettings() {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import net.knarcraft.minstrel.music.Song;
|
||||
import net.knarcraft.minstrel.trait.MinstrelTrait;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.dynmap.markers.GenericMarker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -33,7 +34,7 @@ public class MinstrelHandler extends AbstractTraitHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraitSettings getSettings() {
|
||||
public @NotNull TraitSettings getSettings() {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
@ -46,7 +47,7 @@ public class MinstrelHandler extends AbstractTraitHandler {
|
||||
for (NPC npc : CitizensAPI.getNPCRegistry()) {
|
||||
if (npc.hasTrait(minstrelTrait)) {
|
||||
MinstrelTrait trait = npc.getTraitNullable(MinstrelTrait.class);
|
||||
String description = null;
|
||||
String description = "";
|
||||
if (trait == null) {
|
||||
DynmapCitizens.getInstance().getLogger().log(Level.WARNING, "Unable to get minstrel trait");
|
||||
} else {
|
||||
|
@ -9,6 +9,7 @@ import net.knarcraft.dynmapcitizens.settings.SentinelSettings;
|
||||
import net.knarcraft.dynmapcitizens.settings.TraitSettings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.dynmap.markers.GenericMarker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.mcmonkey.sentinel.SentinelPlugin;
|
||||
import org.mcmonkey.sentinel.SentinelTrait;
|
||||
|
||||
@ -30,7 +31,7 @@ public class SentinelHandler extends AbstractTraitHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraitSettings getSettings() {
|
||||
public @NotNull TraitSettings getSettings() {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
||||
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import net.knarcraft.dynmapcitizens.property.Icon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -21,7 +22,7 @@ public class NPCQuestInfo {
|
||||
*
|
||||
* @param quest <p>The quest to add</p>
|
||||
*/
|
||||
public void addQuestStart(Quest quest) {
|
||||
public void addQuestStart(@NotNull Quest quest) {
|
||||
this.questStart.add(quest);
|
||||
}
|
||||
|
||||
@ -30,7 +31,7 @@ public class NPCQuestInfo {
|
||||
*
|
||||
* @param quest <p>The quest to add</p>
|
||||
*/
|
||||
public void addQuestKill(Quest quest) {
|
||||
public void addQuestKill(@NotNull Quest quest) {
|
||||
this.questKill.add(quest);
|
||||
}
|
||||
|
||||
@ -39,7 +40,7 @@ public class NPCQuestInfo {
|
||||
*
|
||||
* @param quest <p>The quest to add</p>
|
||||
*/
|
||||
public void addQuestDeliver(Quest quest) {
|
||||
public void addQuestDeliver(@NotNull Quest quest) {
|
||||
this.questDeliver.add(quest);
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ public class NPCQuestInfo {
|
||||
*
|
||||
* @param quest <p>The quest to add</p>
|
||||
*/
|
||||
public void addQuestInteract(Quest quest) {
|
||||
public void addQuestInteract(@NotNull Quest quest) {
|
||||
this.questInteract.add(quest);
|
||||
}
|
||||
|
||||
@ -57,7 +58,7 @@ public class NPCQuestInfo {
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -66,7 +67,7 @@ public class NPCQuestInfo {
|
||||
*
|
||||
* @return <p>All kill quests involving this NPC</p>
|
||||
*/
|
||||
public List<Quest> getQuestKills() {
|
||||
public @NotNull List<Quest> getQuestKills() {
|
||||
return new ArrayList<>(this.questKill);
|
||||
}
|
||||
|
||||
@ -75,7 +76,7 @@ public class NPCQuestInfo {
|
||||
*
|
||||
* @return <p>All quests delivering to this NPC</p>
|
||||
*/
|
||||
public List<Quest> getQuestDeliveries() {
|
||||
public @NotNull List<Quest> getQuestDeliveries() {
|
||||
return new ArrayList<>(this.questDeliver);
|
||||
}
|
||||
|
||||
@ -84,7 +85,7 @@ public class NPCQuestInfo {
|
||||
*
|
||||
* @return <p>All quests requiring interaction with this NPC</p>
|
||||
*/
|
||||
public List<Quest> getQuestInteractions() {
|
||||
public @NotNull List<Quest> getQuestInteractions() {
|
||||
return new ArrayList<>(this.questInteract);
|
||||
}
|
||||
|
||||
@ -93,7 +94,7 @@ public class NPCQuestInfo {
|
||||
*
|
||||
* @return <p>The main type of the quest NPC</p>
|
||||
*/
|
||||
public QuestNPCType getQuestNPCType() {
|
||||
public @NotNull QuestNPCType getQuestNPCType() {
|
||||
if (!questStart.isEmpty()) {
|
||||
return QuestNPCType.GIVER;
|
||||
} 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>
|
||||
*/
|
||||
public Icon getNPCIcon() {
|
||||
public @NotNull Icon getNPCIcon() {
|
||||
QuestNPCType type = getQuestNPCType();
|
||||
return switch (type) {
|
||||
case KILL -> Icon.QUEST_KILL;
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.entity.EntityType;
|
||||
import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.markers.GenericMarker;
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -43,8 +44,8 @@ public class QuestAreaHandler {
|
||||
* @param settings <p>The quests settings to use</p>
|
||||
* @param unavailableQuests <p>The list of currently unavailable quests to possibly skip</p>
|
||||
*/
|
||||
public QuestAreaHandler(Quests questsAPI, DynmapAPI dynmapAPI, QuestsSettings settings,
|
||||
List<Quest> unavailableQuests) {
|
||||
public QuestAreaHandler(@NotNull Quests questsAPI, @NotNull DynmapAPI dynmapAPI, @NotNull QuestsSettings settings,
|
||||
@NotNull List<Quest> unavailableQuests) {
|
||||
this.questsAPI = questsAPI;
|
||||
this.settings = settings;
|
||||
this.unavailableQuests = unavailableQuests;
|
||||
@ -78,7 +79,7 @@ public class QuestAreaHandler {
|
||||
* @param quest <p>The quest the stage belongs to</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()) {
|
||||
return;
|
||||
}
|
||||
@ -106,7 +107,7 @@ public class QuestAreaHandler {
|
||||
* @param quest <p>The quest the stage belongs to</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()) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A specifier for a quest NPC's main type
|
||||
*/
|
||||
@ -8,26 +10,47 @@ public enum QuestNPCType {
|
||||
/**
|
||||
* An NPC responsible for giving quests
|
||||
*/
|
||||
GIVER,
|
||||
GIVER("Quest Start NPC: "),
|
||||
|
||||
/**
|
||||
* An NPC killed in a quest
|
||||
*/
|
||||
KILL,
|
||||
KILL("Quest Kill NPC: "),
|
||||
|
||||
/**
|
||||
* An NPC set as the delivery target in a quest
|
||||
*/
|
||||
DELIVER,
|
||||
DELIVER("Quest Deliver NPC: "),
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.quests.components.Planner;
|
||||
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||
import net.knarcraft.knarlib.formatting.TimeFormatter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -21,7 +22,7 @@ public class QuestPlannerInfoGenerator {
|
||||
*
|
||||
* @param quest <p>The quest to generate information about</p>
|
||||
*/
|
||||
public QuestPlannerInfoGenerator(Quest quest) {
|
||||
public QuestPlannerInfoGenerator(@NotNull Quest quest) {
|
||||
this.quest = quest;
|
||||
}
|
||||
|
||||
@ -30,7 +31,7 @@ public class QuestPlannerInfoGenerator {
|
||||
*
|
||||
* @return <p>Information about when the quest is available</p>
|
||||
*/
|
||||
public String getQuestPlannerInfo() {
|
||||
public @NotNull String getQuestPlannerInfo() {
|
||||
Planner planner = quest.getPlanner();
|
||||
StringBuilder plannerInfo = new StringBuilder();
|
||||
plannerInfo.append("<b>Planner:</b><ul>");
|
||||
@ -74,7 +75,7 @@ public class QuestPlannerInfoGenerator {
|
||||
* @param timestamp <p>A timestamp in milliseconds</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");
|
||||
Date date = new Date(timestamp);
|
||||
return format.format(date);
|
||||
|
@ -9,6 +9,8 @@ import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.knarlib.formatting.StringReplacer;
|
||||
import net.knarcraft.knarlib.formatting.TranslatableMessage;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -42,7 +44,7 @@ public class QuestRequirementsInfoGenerator {
|
||||
* @param questsAPI <p>The API to use for getting quest information</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.quest = quest;
|
||||
formatter = DynmapCitizens.getFormatter();
|
||||
@ -53,7 +55,7 @@ public class QuestRequirementsInfoGenerator {
|
||||
*
|
||||
* @return <p>Information about the quest's requirements</p>
|
||||
*/
|
||||
public String getQuestRequirementsInfo() {
|
||||
public @NotNull String getQuestRequirementsInfo() {
|
||||
Requirements requirements = quest.getRequirements();
|
||||
if (!requirements.hasRequirement()) {
|
||||
return "";
|
||||
@ -131,7 +133,7 @@ public class QuestRequirementsInfoGenerator {
|
||||
* @param items <p>The items to get the names of</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<>();
|
||||
for (Object itemStack : items) {
|
||||
itemNames.add(QuestsHelper.getUpperCasedItemStackString((ItemStack) itemStack));
|
||||
@ -145,7 +147,7 @@ public class QuestRequirementsInfoGenerator {
|
||||
* @param questIds <p>The quests to get names for</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());
|
||||
for (String questId : questIds) {
|
||||
Quest quest = getQuest(questId);
|
||||
@ -162,7 +164,7 @@ public class QuestRequirementsInfoGenerator {
|
||||
* @param questId <p>The id of the quest to get</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()) {
|
||||
if (quest.getId().equals(questId)) {
|
||||
return quest;
|
||||
@ -181,8 +183,9 @@ public class QuestRequirementsInfoGenerator {
|
||||
* @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>
|
||||
*/
|
||||
private String getRequirementList(List<String> itemList, TranslatableMessage formatMessage, String formatPlaceholder,
|
||||
TranslatableMessage itemMessage, String itemPlaceholder) {
|
||||
private @NotNull String getRequirementList(@NotNull List<String> itemList, @NotNull TranslatableMessage formatMessage,
|
||||
@NotNull String formatPlaceholder, @NotNull TranslatableMessage itemMessage,
|
||||
@NotNull String itemPlaceholder) {
|
||||
StringBuilder blockedBuilder = new StringBuilder();
|
||||
for (Object requirements : itemList) {
|
||||
blockedBuilder.append(formatter.replacePlaceholder(itemMessage, itemPlaceholder,
|
||||
|
@ -4,6 +4,8 @@ import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.quests.components.Rewards;
|
||||
import net.knarcraft.dynmapcitizens.util.QuestsHelper;
|
||||
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
|
||||
@ -17,7 +19,7 @@ public class QuestRewardsInfoGenerator {
|
||||
*
|
||||
* @param quest <p>The quest to generate information about</p>
|
||||
*/
|
||||
public QuestRewardsInfoGenerator(Quest quest) {
|
||||
public QuestRewardsInfoGenerator(@NotNull Quest quest) {
|
||||
this.quest = quest;
|
||||
}
|
||||
|
||||
@ -26,13 +28,14 @@ public class QuestRewardsInfoGenerator {
|
||||
*
|
||||
* @return <p>Information about the quest's rewards</p>
|
||||
*/
|
||||
public String getQuestRewardsInfo() {
|
||||
public @NotNull String getQuestRewardsInfo() {
|
||||
Rewards reward = quest.getRewards();
|
||||
StringBuilder rewardInfo = new StringBuilder();
|
||||
rewardInfo.append("<b>Rewards:</b><ul>");
|
||||
|
||||
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) {
|
||||
|
@ -9,6 +9,7 @@ import net.knarcraft.dynmapcitizens.util.QuestsHelper;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -25,7 +26,7 @@ public class QuestStagesInfoGenerator {
|
||||
*
|
||||
* @param quest <p>The quest to generate information about</p>
|
||||
*/
|
||||
public QuestStagesInfoGenerator(Quest quest) {
|
||||
public QuestStagesInfoGenerator(@NotNull Quest quest) {
|
||||
this.quest = quest;
|
||||
}
|
||||
|
||||
@ -34,7 +35,7 @@ public class QuestStagesInfoGenerator {
|
||||
*
|
||||
* @return <p>A string with information about the quest's stages</p>
|
||||
*/
|
||||
public String getQuestStagesInfo() {
|
||||
public @NotNull String getQuestStagesInfo() {
|
||||
StringBuilder questInfo = new StringBuilder();
|
||||
NPCRegistry registry = CitizensAPI.getNPCRegistry();
|
||||
int stageCounter = 1;
|
||||
@ -65,7 +66,7 @@ public class QuestStagesInfoGenerator {
|
||||
* @param registry <p>The registry to get NPC info from</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();
|
||||
int mobTypes = stage.getMobsToKill().size();
|
||||
for (int i = 0; i < mobTypes; i++) {
|
||||
@ -135,7 +136,7 @@ public class QuestStagesInfoGenerator {
|
||||
* @param location <p>The location to show</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();
|
||||
if (location.getWorld() != null) {
|
||||
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>
|
||||
* @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();
|
||||
for (Object itemStack : items) {
|
||||
questInfo.append(explanation).append(QuestsHelper.getItemStackString((ItemStack) itemStack));
|
||||
|
@ -16,6 +16,7 @@ import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.markers.GenericMarker;
|
||||
import org.dynmap.markers.Marker;
|
||||
import org.dynmap.markers.MarkerIcon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -52,7 +53,7 @@ public class QuestsHandler extends AbstractTraitHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraitSettings getSettings() {
|
||||
public @NotNull TraitSettings getSettings() {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
@ -140,7 +141,7 @@ public class QuestsHandler extends AbstractTraitHandler {
|
||||
existingMarker.setDescription(newDescription);
|
||||
}
|
||||
} 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 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>");
|
||||
for (Quest quest : offeredQuests) {
|
||||
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>
|
||||
* @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> questInteractions = info.getQuestInteractions();
|
||||
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 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)) {
|
||||
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>
|
||||
* @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) {
|
||||
questGiverInfo.put(npcId, new NPCQuestInfo());
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.dynmapcitizens.settings;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An abstract implementation of trait settings
|
||||
@ -14,7 +15,7 @@ public abstract class AbstractTraitSettings implements TraitSettings {
|
||||
private String markerSetName;
|
||||
|
||||
@Override
|
||||
public void load(FileConfiguration configuration) {
|
||||
public void load(@NotNull FileConfiguration configuration) {
|
||||
this.isEnabled = configuration.getBoolean(getTraitConfigRoot() + ".enabled", false);
|
||||
this.markerSetId = configuration.getString(getTraitConfigRoot() + ".markerSetId", null);
|
||||
this.markerSetPriority = configuration.getInt(getTraitConfigRoot() + ".markerSetPriority", 1);
|
||||
@ -28,12 +29,12 @@ public abstract class AbstractTraitSettings implements TraitSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerSetId() {
|
||||
public @NotNull String getMarkerSetId() {
|
||||
return markerSetId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerSetName() {
|
||||
public @NotNull String getMarkerSetName() {
|
||||
return markerSetName;
|
||||
}
|
||||
|
||||
@ -52,6 +53,6 @@ public abstract class AbstractTraitSettings implements TraitSettings {
|
||||
*
|
||||
* @return <p>The root config node for this trait's settings</p>
|
||||
*/
|
||||
protected abstract String getTraitConfigRoot();
|
||||
protected abstract @NotNull String getTraitConfigRoot();
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.dynmapcitizens.settings;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* 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 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.markerSetPriority = fileConfiguration.getInt(configRoot + ".markerSetPriority", 1);
|
||||
this.markerSetId = fileConfiguration.getString(configRoot + ".markerSetId", null);
|
||||
@ -60,7 +61,7 @@ public class AreaMarkerSettings {
|
||||
*
|
||||
* @return <p>The dynmap id of this marker set</p>
|
||||
*/
|
||||
public String getMarkerSetId() {
|
||||
public @NotNull String getMarkerSetId() {
|
||||
return this.markerSetId;
|
||||
}
|
||||
|
||||
@ -69,7 +70,7 @@ public class AreaMarkerSettings {
|
||||
*
|
||||
* @return <p>The name of this marker set</p>
|
||||
*/
|
||||
public String getMarkerSetName() {
|
||||
public @NotNull String getMarkerSetName() {
|
||||
return this.markerSetName;
|
||||
}
|
||||
|
||||
@ -87,7 +88,7 @@ public class AreaMarkerSettings {
|
||||
*
|
||||
* @return <p>The marker fill color</p>
|
||||
*/
|
||||
public String getFillColor() {
|
||||
public @NotNull String getFillColor() {
|
||||
return this.fillColor;
|
||||
}
|
||||
|
||||
@ -96,7 +97,7 @@ public class AreaMarkerSettings {
|
||||
*
|
||||
* @return <p>The marker outline color</p>
|
||||
*/
|
||||
public String getLineColor() {
|
||||
public @NotNull String getLineColor() {
|
||||
return this.lineColor;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.dynmapcitizens.settings;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* All settings for the blacksmith trait
|
||||
@ -10,13 +11,13 @@ public class BlacksmithSettings extends AbstractTraitSettings {
|
||||
private boolean displayBlacksmithSettings;
|
||||
|
||||
@Override
|
||||
public void load(FileConfiguration configuration) {
|
||||
public void load(@NotNull FileConfiguration configuration) {
|
||||
super.load(configuration);
|
||||
displayBlacksmithSettings = configuration.getBoolean(getTraitConfigRoot() + ".displayBlacksmithSettings", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTraitConfigRoot() {
|
||||
protected @NotNull String getTraitConfigRoot() {
|
||||
return "traits.blacksmith";
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.dynmapcitizens.settings;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* All settings for the minstrel trait
|
||||
@ -8,12 +9,12 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
public class DTLTradersSettings extends AbstractTraitSettings {
|
||||
|
||||
@Override
|
||||
public void load(FileConfiguration configuration) {
|
||||
public void load(@NotNull FileConfiguration configuration) {
|
||||
super.load(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTraitConfigRoot() {
|
||||
protected @NotNull String getTraitConfigRoot() {
|
||||
return "traits.trader";
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.markers.MarkerAPI;
|
||||
import org.dynmap.markers.MarkerIcon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -24,7 +25,7 @@ public class GlobalSettings {
|
||||
*
|
||||
* @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();
|
||||
MarkerAPI markerAPI = dynmapAPI.getMarkerAPI();
|
||||
|
||||
@ -43,7 +44,7 @@ public class GlobalSettings {
|
||||
*
|
||||
* @return <p>The marker icons to use</p>
|
||||
*/
|
||||
public Map<Icon, MarkerIcon> getMarkerIcons() {
|
||||
public @NotNull Map<Icon, MarkerIcon> getMarkerIcons() {
|
||||
return new HashMap<>(markerIcons);
|
||||
}
|
||||
|
||||
@ -71,7 +72,7 @@ public class GlobalSettings {
|
||||
* @param icon <p>The icon identifier to get the icon for</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
|
||||
return switch (icon) {
|
||||
case QUEST_GIVER -> "exclamation";
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.dynmapcitizens.settings;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* All settings for the minstrel trait
|
||||
@ -10,13 +11,13 @@ public class MinstrelSettings extends AbstractTraitSettings {
|
||||
private boolean displayMinstrelSongs;
|
||||
|
||||
@Override
|
||||
public void load(FileConfiguration configuration) {
|
||||
public void load(@NotNull FileConfiguration configuration) {
|
||||
super.load(configuration);
|
||||
displayMinstrelSongs = configuration.getBoolean(getTraitConfigRoot() + ".displayMinstrelSongs", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTraitConfigRoot() {
|
||||
protected @NotNull String getTraitConfigRoot() {
|
||||
return "traits.minstrel";
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.dynmapcitizens.settings;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* All settings for the quests trait
|
||||
@ -16,7 +17,7 @@ public class QuestsSettings extends AbstractTraitSettings {
|
||||
private final AreaMarkerSettings reachAreaSettings = new AreaMarkerSettings();
|
||||
|
||||
@Override
|
||||
public void load(FileConfiguration configuration) {
|
||||
public void load(@NotNull FileConfiguration configuration) {
|
||||
super.load(configuration);
|
||||
this.displayRewardInfo = configuration.getBoolean(getTraitConfigRoot() + ".displayRewardInfo", true);
|
||||
this.displayPlannerInfo = configuration.getBoolean(getTraitConfigRoot() + ".displayPlannerInfo", true);
|
||||
@ -28,7 +29,7 @@ public class QuestsSettings extends AbstractTraitSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTraitConfigRoot() {
|
||||
protected @NotNull String getTraitConfigRoot() {
|
||||
return "traits.quests";
|
||||
}
|
||||
|
||||
@ -82,7 +83,7 @@ public class QuestsSettings extends AbstractTraitSettings {
|
||||
*
|
||||
* @return <p>Settings for the kill area markers</p>
|
||||
*/
|
||||
public AreaMarkerSettings getKillAreaSettings() {
|
||||
public @NotNull AreaMarkerSettings getKillAreaSettings() {
|
||||
return killAreaSettings;
|
||||
}
|
||||
|
||||
@ -91,7 +92,7 @@ public class QuestsSettings extends AbstractTraitSettings {
|
||||
*
|
||||
* @return <p>Settings for the reach area markers</p>
|
||||
*/
|
||||
public AreaMarkerSettings getReachAreaSettings() {
|
||||
public @NotNull AreaMarkerSettings getReachAreaSettings() {
|
||||
return reachAreaSettings;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.dynmapcitizens.settings;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* All settings for the sentinel trait
|
||||
@ -10,13 +11,13 @@ public class SentinelSettings extends AbstractTraitSettings {
|
||||
private boolean displaySentinelStats;
|
||||
|
||||
@Override
|
||||
public void load(FileConfiguration configuration) {
|
||||
public void load(@NotNull FileConfiguration configuration) {
|
||||
super.load(configuration);
|
||||
displaySentinelStats = configuration.getBoolean(getTraitConfigRoot() + ".displaySentinelStats", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTraitConfigRoot() {
|
||||
protected @NotNull String getTraitConfigRoot() {
|
||||
return "traits.sentinel";
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.dynmapcitizens.settings;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
void load(FileConfiguration configuration);
|
||||
void load(@NotNull FileConfiguration configuration);
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
String getMarkerSetId();
|
||||
@NotNull String getMarkerSetId();
|
||||
|
||||
/**
|
||||
* Gets the name of this trait's marker set
|
||||
*
|
||||
* @return <p>The name of the marker set</p>
|
||||
*/
|
||||
String getMarkerSetName();
|
||||
@NotNull String getMarkerSetName();
|
||||
|
||||
/**
|
||||
* Gets the priority of the trait's marker set
|
||||
|
@ -7,6 +7,8 @@ import org.bukkit.World;
|
||||
import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.markers.CircleMarker;
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
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>
|
||||
* @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);
|
||||
if (markerSet == null) {
|
||||
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>
|
||||
* @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(),
|
||||
markerSettings.getMarkerSetName());
|
||||
if (markerSet != null) {
|
||||
@ -60,8 +64,9 @@ public class DynmapHelper {
|
||||
* @param markerSet <p>The marker set to use when marking the location</p>
|
||||
* @param markerSettings <p>The settings to use for the marker</p>
|
||||
*/
|
||||
public static void markLocation(Location location, Integer radius, String description, MarkerSet markerSet,
|
||||
AreaMarkerSettings markerSettings) {
|
||||
public static void markLocation(@NotNull Location location, @NotNull Integer radius,
|
||||
@NotNull String description, @NotNull MarkerSet markerSet,
|
||||
@NotNull AreaMarkerSettings markerSettings) {
|
||||
//Skip if location is invalid
|
||||
World world = location.getWorld();
|
||||
if (world == null) {
|
||||
@ -86,7 +91,7 @@ public class DynmapHelper {
|
||||
* @param color <p>A hexadecimal 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 {
|
||||
return Integer.parseInt(color, 16);
|
||||
} catch (NumberFormatException exception) {
|
||||
|
@ -6,6 +6,7 @@ import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||
import net.knarcraft.dynmapcitizens.handler.VaultHandler;
|
||||
import net.knarcraft.dynmapcitizens.handler.trait.quests.QuestNPCType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
* @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));
|
||||
}
|
||||
|
||||
@ -28,7 +29,7 @@ public class QuestsHelper {
|
||||
* @param itemStack <p>The item stack to print</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();
|
||||
}
|
||||
|
||||
@ -38,7 +39,7 @@ public class QuestsHelper {
|
||||
* @param string <p>The string to run on</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);
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ public class QuestsHelper {
|
||||
* @param name <p>The name to normalize</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("_", " ");
|
||||
}
|
||||
|
||||
@ -58,7 +59,7 @@ public class QuestsHelper {
|
||||
* @param money <p>The amount to pay/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();
|
||||
if (vaultHandler.isEnabled()) {
|
||||
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
|
||||
*
|
||||
* @param quest <p>The quest to check for availability</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();
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user