Added stock check for shift left clicking a sign
This commit is contained in:
parent
5c228e134a
commit
76c68f6bfa
|
|
@ -37,9 +37,11 @@ public class MessageConfig extends AbstractConfiguration {
|
|||
NO_PERMISSION_FOR_SHOP_TYPE = config.getString("permissions-messages.shop-type", NO_PERMISSION_FOR_SHOP_TYPE);
|
||||
}
|
||||
|
||||
public static String SHOP_INFO = "This shop <action> <amount> <item> for <price>.";
|
||||
public static String SHOP_INFO = "<yellow>This shop <action> <gold><amount></gold> <item> for <gold><price></gold>.</yellow>";
|
||||
public static String SHOP_STOCK_INFO = "<yellow>This <type> shop has <gold><stock></gold> stock.</yellow>";
|
||||
private static void otherMessages() {
|
||||
SHOP_INFO = config.getString("messages.shop-info", SHOP_INFO);
|
||||
SHOP_STOCK_INFO = config.getString("messages.shop-stock-info", SHOP_STOCK_INFO);
|
||||
}
|
||||
|
||||
public static String CHANGE_PRICE_PROMPT = "What should the price be? Type cancel to cancel this action.";
|
||||
|
|
|
|||
|
|
@ -85,7 +85,10 @@ public class TransactionListener extends EventListener {
|
|||
}
|
||||
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
giveInfo(playerShop, player);
|
||||
if (event.getPlayer().isSneaking() && player.hasPermission("playershop.shop.check-stock"))
|
||||
giveStockInfo(playerShop, player);
|
||||
else
|
||||
giveInfo(playerShop, player);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -104,9 +107,37 @@ public class TransactionListener extends EventListener {
|
|||
executeTransaction(player, playerShop);
|
||||
}
|
||||
|
||||
private void giveInfo(PlayerShop playerShop, Player player) {
|
||||
if (player.isSneaking())
|
||||
private void giveStockInfo(PlayerShop playerShop, Player player) {
|
||||
if (!playerShop.isInitialized())
|
||||
return;
|
||||
|
||||
TagResolver.Single type;
|
||||
TagResolver.Single stock;
|
||||
switch (playerShop.getType()) {
|
||||
case SELL -> {
|
||||
type = Placeholder.unparsed("type", "Sell");
|
||||
stock = Placeholder.parsed("stock", "" + (playerShop.getRemainingStock() / playerShop.getAmount()));
|
||||
}
|
||||
case BUY -> {
|
||||
type = Placeholder.unparsed("type", "Buy");
|
||||
stock = Placeholder.parsed("stock", "" + (playerShop.getBalance() / playerShop.getPrice()));
|
||||
}
|
||||
case GAMBLE -> {
|
||||
type = Placeholder.unparsed("type", "Gamble");
|
||||
stock = Placeholder.parsed("stock", "" + (playerShop.getRemainingStock() / playerShop.getAmount()));
|
||||
}
|
||||
default -> {
|
||||
type = Placeholder.unparsed("type", "UNKNOWN");
|
||||
stock = Placeholder.parsed("stock", "UNKNOWN");
|
||||
}
|
||||
}
|
||||
|
||||
TagResolver placeholders = TagResolver.resolver(type, stock);
|
||||
|
||||
player.sendMiniMessage(MessageConfig.SHOP_STOCK_INFO, placeholders);
|
||||
}
|
||||
|
||||
private void giveInfo(PlayerShop playerShop, Player player) {
|
||||
if (!playerShop.isInitialized())
|
||||
return;
|
||||
|
||||
|
|
@ -117,6 +148,7 @@ public class TransactionListener extends EventListener {
|
|||
case GAMBLE -> action = Placeholder.unparsed("action", "gambles");
|
||||
default -> action = Placeholder.unparsed("action", "UNKNOWN");
|
||||
}
|
||||
|
||||
TagResolver placeholders = TagResolver.resolver(action,
|
||||
Placeholder.parsed("amount", "" + playerShop.getAmount()),
|
||||
Placeholder.component("item", ShopUtil.itemNameComponent(playerShop.getItemStack())),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user