The Vault handler
+ */ + public VaultHandler getVaultHandler() { + return vaultHandler; } /** diff --git a/src/main/java/net/knarcraft/dynmapcitizens/VaultHandler.java b/src/main/java/net/knarcraft/dynmapcitizens/VaultHandler.java new file mode 100644 index 0000000..1ea5723 --- /dev/null +++ b/src/main/java/net/knarcraft/dynmapcitizens/VaultHandler.java @@ -0,0 +1,48 @@ +package net.knarcraft.dynmapcitizens; + +import net.milkbowl.vault.economy.Economy; +import org.bukkit.plugin.RegisteredServiceProvider; +import org.bukkit.plugin.ServicesManager; + +/** + * A class to keep track of everything Vault + */ +public class VaultHandler { + + private Economy economy = null; + + /** + * Instantiates a new Vault handler + * + * @param servicesManagerThe services manager to get the Vault service from
+ */ + public VaultHandler(ServicesManager servicesManager) { + RegisteredServiceProviderTrue if Vault is enabled
+ */ + public boolean isEnabled() { + return economy != null && economy.isEnabled(); + } + + /** + * Gets the name of the used currency + * + * @returnThe currency name
+ */ + public String getCurrency(boolean plural) { + if (plural) { + return economy.currencyNamePlural(); + } else { + return economy.currencyNameSingular(); + } + } + +} diff --git a/src/main/java/net/knarcraft/dynmapcitizens/trait/quests/QuestsHandler.java b/src/main/java/net/knarcraft/dynmapcitizens/trait/quests/QuestsHandler.java index 5a3f226..3e69e57 100644 --- a/src/main/java/net/knarcraft/dynmapcitizens/trait/quests/QuestsHandler.java +++ b/src/main/java/net/knarcraft/dynmapcitizens/trait/quests/QuestsHandler.java @@ -12,6 +12,7 @@ import net.citizensnpcs.api.npc.NPCRegistry; import net.knarcraft.dynmapcitizens.DynmapCitizens; import net.knarcraft.dynmapcitizens.Icon; import net.knarcraft.dynmapcitizens.UpdateRate; +import net.knarcraft.dynmapcitizens.VaultHandler; import net.knarcraft.dynmapcitizens.trait.AbstractTraitHandler; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -169,14 +170,12 @@ public class QuestsHandler extends AbstractTraitHandler { StringBuilder plannerInfo = new StringBuilder(); plannerInfo.append("Planner:The amount to pay/use
+ * @returnThe currency name to use
+ */ + private String getCurrency(double money) { + VaultHandler vaultHandler = DynmapCitizens.getInstance().getVaultHandler(); + if (vaultHandler.isEnabled()) { + return vaultHandler.getCurrency(money != 1); + } else { + return "money"; + } + } + /** * Gets the marker title to use for the given quest NPC type * diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b31a804..44e9440 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,6 +4,6 @@ main: net.knarcraft.dynmapcitizens.DynmapCitizens api-version: 1.19 prefix: DynmapCitizens depend: [ dynmap, Citizens ] -softdepend: [ Blacksmith, Sentinel, Quests, Minstrel ] +softdepend: [ Blacksmith, Sentinel, Quests, Minstrel, Vault ] authors: [ EpicKnarvik97 ] description: A plugin for displaying citizens info on the dynmap map