Send different message for not having enough items/money

This commit is contained in:
Stijn 2022-08-31 20:00:36 +02:00
parent ad656391fb
commit 2228e45ed4
4 changed files with 9 additions and 1 deletions

View File

@ -55,6 +55,7 @@ public class ShopTypeConfig {
public String playerInventoryFull = "<red>You do not have enough space in your inventory to buy from this shop.";
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 playerSold = "<white>You sold <amount> <item>(s) to <ownername> for <price>.";
public String shopBought = "<white><user> sold <amount> <item>(s) to you for <price>.";
@ -66,6 +67,9 @@ public class ShopTypeConfig {
private void transactionMessages() {
playerInventoryFull = getString("transaction.player-inventory-full", playerInventoryFull);
playerNoFunds = getString("transaction.player-no-funds", playerNoFunds);
playerNoItems = getString("transaction.player-no-items", playerNoItems);
playerBought = getString("transaction.player-bought", playerBought);
playerSold = getString("transaction.player-sold", playerSold);
shopInventoryFull = getString("transaction.shop-inventory-full", shopInventoryFull);
shopNoStock = getString("transaction.shop-no-stock", shopNoStock);
yourShopNoFunds = getString("transaction.your-shop-no-funds", yourShopNoFunds);

View File

@ -123,6 +123,9 @@ public class TransactionListener extends EventListener {
case INSUFFICIENT_FUNDS_PLAYER -> {
player.sendMiniMessage(shop.getType().getShopTypeConfig().playerNoFunds, placeholders);
}
case INSUFFICIENT_ITEMS_PLAYER -> {
player.sendMiniMessage(shop.getType().getShopTypeConfig().playerNoItems, placeholders);
}
case INVENTORY_FULL_SHOP -> {
Player shopOwner = Bukkit.getPlayer(shop.getOwnerUUID());
if (shopOwner != null && notifyOwner(shop)) {

View File

@ -252,7 +252,7 @@ public class PlayerShop {
int playerItems = InventoryUtils.countItems(player.getInventory(), itemStack);
if (playerItems < itemStack.getAmount())
return TransactionError.INSUFFICIENT_FUNDS_PLAYER;
return TransactionError.INSUFFICIENT_ITEMS_PLAYER;
boolean hasFunds = EconomyUtils.hasSufficientFunds(this, price);
if (!hasFunds)

View File

@ -4,6 +4,7 @@ public enum TransactionError {
CANCELLED,
INSUFFICIENT_FUNDS_SHOP,
INSUFFICIENT_FUNDS_PLAYER,
INSUFFICIENT_ITEMS_PLAYER,
INVENTORY_FULL_SHOP,
INVENTORY_FULL_PLAYER,
PLAYER_OFFLINE,