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);
|
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() {
|
private static void otherMessages() {
|
||||||
SHOP_INFO = config.getString("messages.shop-info", SHOP_INFO);
|
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.";
|
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) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,9 +107,37 @@ public class TransactionListener extends EventListener {
|
||||||
executeTransaction(player, playerShop);
|
executeTransaction(player, playerShop);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void giveInfo(PlayerShop playerShop, Player player) {
|
private void giveStockInfo(PlayerShop playerShop, Player player) {
|
||||||
if (player.isSneaking())
|
if (!playerShop.isInitialized())
|
||||||
return;
|
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())
|
if (!playerShop.isInitialized())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -117,6 +148,7 @@ public class TransactionListener extends EventListener {
|
||||||
case GAMBLE -> action = Placeholder.unparsed("action", "gambles");
|
case GAMBLE -> action = Placeholder.unparsed("action", "gambles");
|
||||||
default -> action = Placeholder.unparsed("action", "UNKNOWN");
|
default -> action = Placeholder.unparsed("action", "UNKNOWN");
|
||||||
}
|
}
|
||||||
|
|
||||||
TagResolver placeholders = TagResolver.resolver(action,
|
TagResolver placeholders = TagResolver.resolver(action,
|
||||||
Placeholder.parsed("amount", "" + playerShop.getAmount()),
|
Placeholder.parsed("amount", "" + playerShop.getAmount()),
|
||||||
Placeholder.component("item", ShopUtil.itemNameComponent(playerShop.getItemStack())),
|
Placeholder.component("item", ShopUtil.itemNameComponent(playerShop.getItemStack())),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user