From bcd1d7ecb0c669881c8d8036dee873cc659cfc6d Mon Sep 17 00:00:00 2001 From: HappyPikachu Date: Tue, 2 Jan 2018 22:06:54 -0500 Subject: [PATCH] Ensure economy plugin is present when checking money reqs, fixes #185 --- src/main/java/me/blackvein/quests/PlayerListener.java | 2 +- src/main/java/me/blackvein/quests/Quest.java | 10 +++++++--- src/main/java/me/blackvein/quests/Quester.java | 6 ++++-- src/main/java/me/blackvein/quests/Quests.java | 2 +- .../blackvein/quests/prompts/RequirementsPrompt.java | 8 ++++++-- .../me/blackvein/quests/prompts/RewardsPrompt.java | 9 +++++++-- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/blackvein/quests/PlayerListener.java b/src/main/java/me/blackvein/quests/PlayerListener.java index 2e9936d7a..bf0747c53 100644 --- a/src/main/java/me/blackvein/quests/PlayerListener.java +++ b/src/main/java/me/blackvein/quests/PlayerListener.java @@ -700,4 +700,4 @@ public class PlayerListener implements Listener { } } } -} +} \ No newline at end of file diff --git a/src/main/java/me/blackvein/quests/Quest.java b/src/main/java/me/blackvein/quests/Quest.java index 91ed55e83..293f4cade 100644 --- a/src/main/java/me/blackvein/quests/Quest.java +++ b/src/main/java/me/blackvein/quests/Quest.java @@ -194,8 +194,10 @@ public class Quest { public boolean testRequirements(Player player) { Quester quester = plugin.getQuester(player.getUniqueId()); - if (moneyReq != 0 && Quests.economy.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())) < moneyReq) { - return false; + if (moneyReq != 0 && Quests.economy != null) { + if (Quests.economy.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())) < moneyReq) { + return false; + } } PlayerInventory inventory = player.getInventory(); int num = 0; @@ -334,7 +336,9 @@ public class Quest { player.giveExp(lb.getExp()); } if (lb.getMoney() > 0) { - Quests.economy.depositPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()), lb.getMoney()); + if (Quests.economy != null) { + Quests.economy.depositPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()), lb.getMoney()); + } } if (lb.getItemList().isEmpty() == false) { phatLootItems.addAll(lb.getItemList()); diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index 3e9ad8cc6..90ff9d121 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -313,7 +313,9 @@ public class Quester { Stage stage = q.getStage(0); if (!override) { if (q.moneyReq > 0) { - Quests.economy.withdrawPlayer(getOfflinePlayer(), q.moneyReq); + if (Quests.economy != null) { + Quests.economy.withdrawPlayer(getOfflinePlayer(), q.moneyReq); + } } for (ItemStack is : q.items) { if (q.removeItems.get(q.items.indexOf(is)) == true) { @@ -2608,4 +2610,4 @@ public class Quester { break; } } -} +} \ No newline at end of file diff --git a/src/main/java/me/blackvein/quests/Quests.java b/src/main/java/me/blackvein/quests/Quests.java index 38ec33ffd..5cd8782ec 100644 --- a/src/main/java/me/blackvein/quests/Quests.java +++ b/src/main/java/me/blackvein/quests/Quests.java @@ -4036,4 +4036,4 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener questerBlacklist.add(id.toString()); } } -} +} \ No newline at end of file diff --git a/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java b/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java index 4cff0a3f1..e86599baa 100644 --- a/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java @@ -192,7 +192,11 @@ public class RequirementsPrompt extends FixedSetPrompt { @Override public String getPromptText(ConversationContext context) { String text = Lang.get("reqMoneyPrompt"); - text = text.replaceAll("", ChatColor.DARK_PURPLE + ((Quests.economy.currencyNamePlural().isEmpty() ? Lang.get("money") : Quests.economy.currencyNamePlural())) + ChatColor.YELLOW); + if (Quests.economy != null) { + text = text.replaceAll("", ChatColor.DARK_PURPLE + ((Quests.economy.currencyNamePlural().isEmpty() ? Lang.get("money") : Quests.economy.currencyNamePlural())) + ChatColor.YELLOW); + } else { + text = text.replaceAll("", ChatColor.DARK_PURPLE + Lang.get("money") + ChatColor.YELLOW); + } return ChatColor.YELLOW + text; } @@ -901,4 +905,4 @@ public class RequirementsPrompt extends FixedSetPrompt { return new RequirementsPrompt(quests, factory); } } -} +} \ No newline at end of file diff --git a/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java b/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java index a1f04bf18..64ed9681b 100644 --- a/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java @@ -191,7 +191,12 @@ public class RewardsPrompt extends FixedSetPrompt { @Override public String getPromptText(ConversationContext context) { String text = Lang.get("rewMoneyPrompt"); - text = text.replaceAll("", ChatColor.AQUA + (Quests.economy.currencyNamePlural().isEmpty() ? Lang.get("money") : Quests.economy.currencyNamePlural()) + ChatColor.YELLOW); + if (Quests.economy != null) { + text = text.replaceAll("", ChatColor.AQUA + (Quests.economy.currencyNamePlural().isEmpty() ? Lang.get("money") : Quests.economy.currencyNamePlural()) + ChatColor.YELLOW); + } else { + text = text.replaceAll("", ChatColor.AQUA + Lang.get("money") + ChatColor.YELLOW); + + } return ChatColor.YELLOW + text; } @@ -882,4 +887,4 @@ public class RewardsPrompt extends FixedSetPrompt { return new RewardCustomDataListPrompt(); } } -} +} \ No newline at end of file