Ensure economy plugin is present when checking money reqs, fixes #185

This commit is contained in:
HappyPikachu 2018-01-02 22:06:54 -05:00
parent f98f48ace5
commit bcd1d7ecb0
6 changed files with 26 additions and 11 deletions

View File

@ -194,9 +194,11 @@ 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) {
if (moneyReq != 0 && Quests.economy != null) {
if (Quests.economy.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())) < moneyReq) {
return false;
}
}
PlayerInventory inventory = player.getInventory();
int num = 0;
for (ItemStack is : items) {
@ -334,8 +336,10 @@ public class Quest {
player.giveExp(lb.getExp());
}
if (lb.getMoney() > 0) {
if (Quests.economy != null) {
Quests.economy.depositPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()), lb.getMoney());
}
}
if (lb.getItemList().isEmpty() == false) {
phatLootItems.addAll(lb.getItemList());
for (ItemStack is : lb.getItemList()) {

View File

@ -313,8 +313,10 @@ public class Quester {
Stage stage = q.getStage(0);
if (!override) {
if (q.moneyReq > 0) {
if (Quests.economy != null) {
Quests.economy.withdrawPlayer(getOfflinePlayer(), q.moneyReq);
}
}
for (ItemStack is : q.items) {
if (q.removeItems.get(q.items.indexOf(is)) == true) {
Quests.removeItem(player.getInventory(), is);

View File

@ -192,7 +192,11 @@ public class RequirementsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = Lang.get("reqMoneyPrompt");
if (Quests.economy != null) {
text = text.replaceAll("<money>", ChatColor.DARK_PURPLE + ((Quests.economy.currencyNamePlural().isEmpty() ? Lang.get("money") : Quests.economy.currencyNamePlural())) + ChatColor.YELLOW);
} else {
text = text.replaceAll("<money>", ChatColor.DARK_PURPLE + Lang.get("money") + ChatColor.YELLOW);
}
return ChatColor.YELLOW + text;
}

View File

@ -191,7 +191,12 @@ public class RewardsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = Lang.get("rewMoneyPrompt");
if (Quests.economy != null) {
text = text.replaceAll("<money>", ChatColor.AQUA + (Quests.economy.currencyNamePlural().isEmpty() ? Lang.get("money") : Quests.economy.currencyNamePlural()) + ChatColor.YELLOW);
} else {
text = text.replaceAll("<money>", ChatColor.AQUA + Lang.get("money") + ChatColor.YELLOW);
}
return ChatColor.YELLOW + text;
}