From 255ddc3963f3e3cabc84f92f2b4f05b9a187866b Mon Sep 17 00:00:00 2001 From: Maik E Date: Fri, 29 Dec 2023 19:23:43 +0100 Subject: [PATCH] Add show owner information feature This update introduces a new feature that displays additional information about the shop owner when they interact with their shop. Included in this update is also the display of a list of accessors to aid user interaction. To support this new feature, relevant messages have been added to the Messages.java file. --- .../ChestShop/Configuration/Messages.java | 4 ++++ .../Listeners/Player/PlayerInteract.java | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/com/Acrobot/ChestShop/Configuration/Messages.java b/src/main/java/com/Acrobot/ChestShop/Configuration/Messages.java index 803d3f227..ee9e0930b 100644 --- a/src/main/java/com/Acrobot/ChestShop/Configuration/Messages.java +++ b/src/main/java/com/Acrobot/ChestShop/Configuration/Messages.java @@ -11,6 +11,7 @@ public class Messages { public static String PREFIX = ChatColor.GREEN + "[Shop] " + ChatColor.RESET; public static String ITEM_INFO = ChatColor.GREEN + "Item Information: " + ChatColor.RESET; public static String SHOP_INFO = ChatColor.GREEN + "Shop Information: " + ChatColor.RESET; + public static String SHOP_OWNER_INFO = ChatColor.GREEN + "Shop-Owner Information: " + ChatColor.RESET; @PrecededBySpace public static String ACCESS_DENIED = "You don't have permission to do that!"; @@ -95,6 +96,9 @@ public class Messages { public static final String ACCESSOR_REMOVED = "Accessor removed."; public static final String ACCESSOR_NOT_ADDED = "Player isn't a accessor."; + @PrecededBySpace + public static String SHOP_ACCESSORS = "Accessors: %accessor_list"; + public static String prefix(String message) { return PREFIX + message; } diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java index 02f46684a..25b4762ef 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java @@ -10,6 +10,7 @@ import static org.bukkit.event.block.Action.LEFT_CLICK_BLOCK; import static org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK; +import java.util.Collection; import java.util.UUID; import org.bukkit.Bukkit; @@ -45,6 +46,7 @@ import com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType; import com.Acrobot.ChestShop.Plugins.ChestShop; import com.Acrobot.ChestShop.Signs.ChestShopSign; +import com.Acrobot.ChestShop.UUIDs.NameManager; import com.Acrobot.ChestShop.Utils.uBlock; /** @@ -143,6 +145,20 @@ private static void showShopInfo(Player player, Sign sign) { if (Properties.SHOW_SHOP_INFORMATION_ON_SHIFT_CLICK) { if (!ChestShopSign.isAdminShop(sign)) { + + if (ChestShopSign.isOwner(player, sign) || Permission.has(player, Permission.MOD)) { + player.sendMessage(Messages.prefix(Messages.SHOP_OWNER_INFO)); + Collection accessors = ChestShopSign.getAccessors(sign); + StringBuilder accessorNames = new StringBuilder(); + for (String string : accessors) { + if (!accessorNames.isEmpty()) + accessorNames.append(", "); + accessorNames.append(NameManager.getFullNameFor(UUID.fromString(string))); + } + + player.sendMessage(" " + Messages.SHOP_ACCESSORS.replace("%accessor_list", accessorNames.toString())); + } + Container chest = uBlock.findConnectedChest(sign, true); if (chest != null) { // do not allow shulker boxes inside of shulker boxes