mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-15 15:16:41 +01:00
Ensure economy plugin is present when checking money reqs, fixes #185
This commit is contained in:
parent
f98f48ace5
commit
bcd1d7ecb0
@ -194,9 +194,11 @@ public class Quest {
|
|||||||
|
|
||||||
public boolean testRequirements(Player player) {
|
public boolean testRequirements(Player player) {
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
PlayerInventory inventory = player.getInventory();
|
PlayerInventory inventory = player.getInventory();
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (ItemStack is : items) {
|
for (ItemStack is : items) {
|
||||||
@ -334,8 +336,10 @@ public class Quest {
|
|||||||
player.giveExp(lb.getExp());
|
player.giveExp(lb.getExp());
|
||||||
}
|
}
|
||||||
if (lb.getMoney() > 0) {
|
if (lb.getMoney() > 0) {
|
||||||
|
if (Quests.economy != null) {
|
||||||
Quests.economy.depositPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()), lb.getMoney());
|
Quests.economy.depositPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()), lb.getMoney());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (lb.getItemList().isEmpty() == false) {
|
if (lb.getItemList().isEmpty() == false) {
|
||||||
phatLootItems.addAll(lb.getItemList());
|
phatLootItems.addAll(lb.getItemList());
|
||||||
for (ItemStack is : lb.getItemList()) {
|
for (ItemStack is : lb.getItemList()) {
|
||||||
|
@ -313,8 +313,10 @@ public class Quester {
|
|||||||
Stage stage = q.getStage(0);
|
Stage stage = q.getStage(0);
|
||||||
if (!override) {
|
if (!override) {
|
||||||
if (q.moneyReq > 0) {
|
if (q.moneyReq > 0) {
|
||||||
|
if (Quests.economy != null) {
|
||||||
Quests.economy.withdrawPlayer(getOfflinePlayer(), q.moneyReq);
|
Quests.economy.withdrawPlayer(getOfflinePlayer(), q.moneyReq);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (ItemStack is : q.items) {
|
for (ItemStack is : q.items) {
|
||||||
if (q.removeItems.get(q.items.indexOf(is)) == true) {
|
if (q.removeItems.get(q.items.indexOf(is)) == true) {
|
||||||
Quests.removeItem(player.getInventory(), is);
|
Quests.removeItem(player.getInventory(), is);
|
||||||
|
@ -192,7 +192,11 @@ public class RequirementsPrompt extends FixedSetPrompt {
|
|||||||
@Override
|
@Override
|
||||||
public String getPromptText(ConversationContext context) {
|
public String getPromptText(ConversationContext context) {
|
||||||
String text = Lang.get("reqMoneyPrompt");
|
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);
|
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;
|
return ChatColor.YELLOW + text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,12 @@ public class RewardsPrompt extends FixedSetPrompt {
|
|||||||
@Override
|
@Override
|
||||||
public String getPromptText(ConversationContext context) {
|
public String getPromptText(ConversationContext context) {
|
||||||
String text = Lang.get("rewMoneyPrompt");
|
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);
|
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;
|
return ChatColor.YELLOW + text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user