Added a way to display all info on a shop
This commit is contained in:
parent
d23b8e0f1d
commit
cda2a0b216
|
|
@ -45,7 +45,7 @@ public class TransactionListener extends EventListener {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
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;
|
return;
|
||||||
|
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
|
|
@ -79,6 +79,11 @@ public class TransactionListener extends EventListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
|
giveInfo(playerShop, player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ShopUtil.canManageShop(player, playerShop)) {
|
if (ShopUtil.canManageShop(player, playerShop)) {
|
||||||
if (player.isSneaking())
|
if (player.isSneaking())
|
||||||
return;
|
return;
|
||||||
|
|
@ -94,6 +99,31 @@ public class TransactionListener extends EventListener {
|
||||||
executeTransaction(player, playerShop);
|
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) {
|
private void executeTransaction(Player player, PlayerShop shop) {
|
||||||
if (shop == null || shop.getItemStack() == null)
|
if (shop == null || shop.getItemStack() == null)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user