Skip to content

Commit

Permalink
Enhance sign manipulation by using ChestShopMetaData
Browse files Browse the repository at this point in the history
The PlayerInteract class has been updated to use ChestShopMetaData instead of direct sign line manipulation. This has not only improved code efficiency and readability, but also reduced the possibility of errors. Besides, accessors management has been added in Sign class to better manage access control.
  • Loading branch information
Feli499 committed Dec 31, 2023
1 parent 6979486 commit 350a3be
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/main/java/com/Acrobot/ChestShop/Signs/ChestShopSign.java
Expand Up @@ -45,6 +45,7 @@ public static void createAdminChestShop(Sign sign, int quantity, double sellPric
}

public static boolean isAdminShop(Sign sign) {
return getChestShopMetaData(sign).isOwner(NameManager.getAdminShopUUID());
}

public static boolean canAccess(OfflinePlayer player, Sign sign) {
Expand All @@ -62,21 +63,34 @@ public static boolean canAccess(OfflinePlayer player, Sign sign) {
}

public static boolean isOwner(OfflinePlayer player, Sign sign) {
return getChestShopMetaData(sign).isOwner(player.getUniqueId());
}

public static UUID getOwner(Sign sign) {
ChestShopMetaData chestShopMetaData = getChestShopMetaData(sign);
return chestShopMetaData.getOwner();
}

public static boolean isAccessor(OfflinePlayer player, Sign sign) {
}

public static void addAccessor(UUID player, Sign sign) {
ChestShopMetaData chestShopMetaData = getChestShopMetaData(sign);
chestShopMetaData.addAccessor(player);
saveChestShopMetaData(sign, chestShopMetaData);
}

public static boolean isAccessor(OfflinePlayer player, Sign sign) {
return isAccessor(player.getUniqueId(), sign);
}

public static boolean isAccessor(UUID player, Sign sign) {
ChestShopMetaData chestShopMetaData = getChestShopMetaData(sign);
return chestShopMetaData.isAccessor(player);
}

public static void removeAccessor(UUID player, Sign sign) {
public static void removeAccessor(UUID accessor, Sign sign) {
ChestShopMetaData chestShopMetaData = getChestShopMetaData(sign);
chestShopMetaData.removeAccessor(accessor);
saveChestShopMetaData(sign, chestShopMetaData);
}

private static void updateLegacyChestShop(Sign sign) {
Expand Down

0 comments on commit 350a3be

Please sign in to comment.