Skip to content

Commit

Permalink
Refactor variables and handle empty accessor data
Browse files Browse the repository at this point in the history
The variable name in the loop has been changed from 'string' to 'accessorUUID' in PlayerInteract.java for better clarity. Alongside this renaming, the code in ChestShopSign.java has been updated to return an empty HashSet when no accessor data exists to avoid any potential errors or misinterpretations.
  • Loading branch information
Feli499 committed Dec 29, 2023
1 parent 255ddc3 commit 2e84c34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Expand Up @@ -150,10 +150,10 @@ private static void showShopInfo(Player player, Sign sign) {
player.sendMessage(Messages.prefix(Messages.SHOP_OWNER_INFO));
Collection<String> accessors = ChestShopSign.getAccessors(sign);
StringBuilder accessorNames = new StringBuilder();
for (String string : accessors) {
for (String accessorUUID : accessors) {
if (!accessorNames.isEmpty())
accessorNames.append(", ");
accessorNames.append(NameManager.getFullNameFor(UUID.fromString(string)));
accessorNames.append(NameManager.getFullNameFor(UUID.fromString(accessorUUID)));
}

player.sendMessage(" " + Messages.SHOP_ACCESSORS.replace("%accessor_list", accessorNames.toString()));
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/Acrobot/ChestShop/Signs/ChestShopSign.java
Expand Up @@ -163,6 +163,9 @@ public static Collection<String> getAccessors(Sign sign) {
return new HashSet<>();

String data = persistentDataContainer.get(ACCESSORS_NAMESPACED_KEY, PersistentDataType.STRING);
if (data.isEmpty())
return new HashSet<>();

String[] split = data.split(";");

return new HashSet<>(Arrays.asList(split));
Expand Down

0 comments on commit 2e84c34

Please sign in to comment.