From cb02c965a790db6c9e667fa4188b8c0ff372aa3f Mon Sep 17 00:00:00 2001 From: PikaMug Date: Tue, 5 Nov 2019 18:36:32 -0500 Subject: [PATCH] Move related utility methods to dependency class, part 3 --- .../me/blackvein/quests/Dependencies.java | 20 +++++++++++++++++ .../main/java/me/blackvein/quests/Quests.java | 22 +++++-------------- .../quests/listeners/CmdExecutor.java | 8 +++---- .../quests/prompts/RequirementsPrompt.java | 4 ++-- .../quests/prompts/RewardsPrompt.java | 4 ++-- 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/Dependencies.java b/main/src/main/java/me/blackvein/quests/Dependencies.java index 94dd2bda0..2218c5299 100644 --- a/main/src/main/java/me/blackvein/quests/Dependencies.java +++ b/main/src/main/java/me/blackvein/quests/Dependencies.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.RegisteredServiceProvider; import me.blackvein.quests.util.DenizenAPI; +import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.WorldGuardAPI; import me.clip.placeholderapi.PlaceholderAPIPlugin; import net.citizensnpcs.api.CitizensPlugin; @@ -223,6 +224,25 @@ public class Dependencies { return (permission != null); } + public String getCurrency(boolean plural) { + if (getVaultEconomy() == null) { + return Lang.get("money"); + } + if (plural) { + if (getVaultEconomy().currencyNamePlural().trim().isEmpty()) { + return Lang.get("money"); + } else { + return getVaultEconomy().currencyNamePlural(); + } + } else { + if (getVaultEconomy().currencyNameSingular().trim().isEmpty()) { + return Lang.get("money"); + } else { + return getVaultEconomy().currencyNameSingular(); + } + } + } + public boolean runDenizenScript(String scriptName, Quester quester) { return plugin.getDenizenTrigger().runDenizenScript(scriptName, quester); } diff --git a/main/src/main/java/me/blackvein/quests/Quests.java b/main/src/main/java/me/blackvein/quests/Quests.java index 3ea096862..dac4d2d8b 100644 --- a/main/src/main/java/me/blackvein/quests/Quests.java +++ b/main/src/main/java/me/blackvein/quests/Quests.java @@ -3395,24 +3395,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } } } - + + /** + * @deprecated + */ public String getCurrency(boolean plural) { - if (depends.getVaultEconomy() == null) { - return Lang.get("money"); - } - if (plural) { - if (depends.getVaultEconomy().currencyNamePlural().trim().isEmpty()) { - return Lang.get("money"); - } else { - return depends.getVaultEconomy().currencyNamePlural(); - } - } else { - if (depends.getVaultEconomy().currencyNameSingular().trim().isEmpty()) { - return Lang.get("money"); - } else { - return depends.getVaultEconomy().currencyNameSingular(); - } - } + return depends.getCurrency(plural); } public static boolean removeItem(Inventory inventory, ItemStack is) { diff --git a/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java b/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java index 70368bf1a..a1dbf95b8 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java +++ b/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java @@ -388,18 +388,18 @@ public class CmdExecutor implements CommandExecutor { .getVaultEconomy().getBalance(quester.getOfflinePlayer()) >= reqs.getMoney()) { if (reqs.getMoney() == 1) { cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " " - + plugin.getCurrency(false)); + + plugin.getDependencies().getCurrency(false)); } else { cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " " - + plugin.getCurrency(true)); + + plugin.getDependencies().getCurrency(true)); } } else { if (reqs.getMoney() == 1) { cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " " - + plugin.getCurrency(false)); + + plugin.getDependencies().getCurrency(false)); } else { cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " " - + plugin.getCurrency(true)); + + plugin.getDependencies().getCurrency(true)); } } } diff --git a/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java b/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java index ecc1f952a..e185d5ac3 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java @@ -159,8 +159,8 @@ public class RequirementsPrompt extends NumericPrompt { } else { int moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY); return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyReq + " " - + (moneyReq > 1 ? plugin.getCurrency(true) : plugin.getCurrency(false)) + ChatColor.GRAY - + ")"; + + (moneyReq > 1 ? plugin.getDependencies().getCurrency(true) + : plugin.getDependencies().getCurrency(false)) + ChatColor.GRAY + ")"; } case 2: if (context.getSessionData(CK.REQ_QUEST_POINTS) == null) { diff --git a/main/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java b/main/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java index faffe4c20..d9672d681 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java @@ -133,8 +133,8 @@ public class RewardsPrompt extends NumericPrompt { } else { int moneyRew = (Integer) context.getSessionData(CK.REW_MONEY); return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyRew + " " - + (moneyRew > 1 ? plugin.getCurrency(true) : plugin.getCurrency(false)) + ChatColor.GRAY - + ")"; + + (moneyRew > 1 ? plugin.getDependencies().getCurrency(true) + : plugin.getDependencies().getCurrency(false)) + ChatColor.GRAY + ")"; } case 2: if (context.getSessionData(CK.REW_QUEST_POINTS) == null) {