Added a way to display all info on a shop
This commit is contained in:
parent
89acf0c10e
commit
581d03d79b
|
|
@ -43,7 +43,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();
|
||||
|
|
@ -76,6 +76,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;
|
||||
|
|
@ -91,6 +96,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 <action> <amount> <item_name> (<material>) for <price>";
|
||||
|
||||
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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user