Fix NPE in Gambleshops and add missing messages for gamble shops.

This commit is contained in:
Len 2024-08-04 11:27:49 +02:00 committed by destro174
parent 7cfd147f1e
commit 7f3f01eda3
3 changed files with 7 additions and 7 deletions

View File

@ -57,6 +57,7 @@ public class ShopTypeConfig {
public String playerNoFunds = "<red>You do not have sufficient funds to trade with this shop.";
public String playerNoItems = "<red>You do not have sufficient items to trade with this shop.";
public String playerBought = "<white>You bought <amount> <item>(s) from <ownername> for <price>.";
public String playerGambled = "<white>You gambled <amount> <item>(s) from <ownername> for <price>.";
public String playerSold = "<white>You sold <amount> <item>(s) to <ownername> for <price>.";
public String shopBought = "<white><user> sold <amount> <item>(s) to you for <price>.";
public String shopSold = "<white><user> bought <amount> <item>(s) from you for <price>.";

View File

@ -208,12 +208,11 @@ public class TransactionListener extends EventListener {
}
return;
}
if (shop.getType().equals(ShopType.BUY))
player.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().playerSold, placeholders));
else if (shop.getType().equals(ShopType.SELL)) {
player.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().playerBought, placeholders));
} else { //TODO add messages for all shop types
player.sendActionBar(Util.parseMiniMessage("NOT IMPLEMENTED", placeholders));
switch (shop.getType()) {
case BUY -> player.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().playerSold, placeholders));
case SELL -> player.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().playerBought, placeholders));
case GAMBLE -> player.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().playerGambled, placeholders));
default -> player.sendActionBar(Util.parseMiniMessage("NOT IMPLEMENTED", placeholders));
}
plugin.getDatabaseHelper().logTransaction(player, shop, orders);
}

View File

@ -308,7 +308,7 @@ public class PlayerShop {
private TransactionError executeGambleTransaction(Player player) {
ItemStack itemStack = getRandomItem();
if (itemStack == null)
return null;
return TransactionError.INSUFFICIENT_FUNDS_SHOP;
itemStack = itemStack.clone();
double price = getPrice();