Skip to content

Commit

Permalink
Add show owner information feature
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Feli499 committed Dec 29, 2023
1 parent b4b55b7 commit 255ddc3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Expand Up @@ -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!";
Expand Down Expand Up @@ -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;
}
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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<String> 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
Expand Down

0 comments on commit 255ddc3

Please sign in to comment.