diff --git a/src/main/java/com/alttd/playershops/listener/TransactionListener.java b/src/main/java/com/alttd/playershops/listener/TransactionListener.java index 23f766b..8a72a94 100644 --- a/src/main/java/com/alttd/playershops/listener/TransactionListener.java +++ b/src/main/java/com/alttd/playershops/listener/TransactionListener.java @@ -45,7 +45,7 @@ public class TransactionListener extends EventListener { return; Player player = event.getPlayer(); - if (!(event.getAction() == Action.RIGHT_CLICK_BLOCK)) + if (!(event.getAction() == Action.RIGHT_CLICK_BLOCK) && !(event.getAction() == Action.LEFT_CLICK_BLOCK)) return; Block block = event.getClickedBlock(); @@ -79,6 +79,11 @@ public class TransactionListener extends EventListener { return; } + if (event.getAction() == Action.LEFT_CLICK_BLOCK) { + giveInfo(playerShop, player); + return; + } + if (ShopUtil.canManageShop(player, playerShop)) { if (player.isSneaking()) return; @@ -94,6 +99,31 @@ public class TransactionListener extends EventListener { executeTransaction(player, playerShop); } + private void giveInfo(PlayerShop playerShop, Player player) { + if (player.isSneaking()) + return; + if (!playerShop.isInitialized()) + return; + + String message = "This shop () for "; + + TagResolver.Single action; + switch (playerShop.getType()) { + case SELL -> action = Placeholder.unparsed("action", "sells"); + case BUY -> action = Placeholder.unparsed("action", "buys"); + 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", playerShop.getItemStack().displayName()), + Placeholder.parsed("material", Util.capitalize(playerShop.getItemStack().getType().name())), + Placeholder.parsed("price", "" + playerShop.getPrice()) + ); + + player.sendMiniMessage(message, placeholders); + } + private void executeTransaction(Player player, PlayerShop shop) { if (shop == null || shop.getItemStack() == null) return;