Skip to content

Commit

Permalink
Refactor ChestShop MetaData creation methods
Browse files Browse the repository at this point in the history
The 'createShopMetaData', 'createChestShop', and 'createAdminChestShop' methods in 'SignCreate' class have been refactored. The unnecessary 'sign' parameter has been removed from these methods, streamlining the code and fixing potential issues with incorrect sign references.
  • Loading branch information
Feli499 committed Jan 1, 2024
1 parent d048c8a commit 05c2450
Showing 1 changed file with 6 additions and 6 deletions.
Expand Up @@ -69,7 +69,7 @@ public static void onSignChange(SignChangeEvent event) {
event.setLine(i, preEvent.getSignLine(i));
}

ChestShopMetaData chestShopMetaData = createShopMetaData(preEvent.getSign(), event.getPlayer(), event.getLines(), itemStack);
ChestShopMetaData chestShopMetaData = createShopMetaData(event.getPlayer(), event.getLines(), itemStack);

ShopCreatedEvent postEvent = new ShopCreatedEvent(preEvent.getPlayer(), preEvent.getSign(),
uBlock.findConnectedChest(preEvent.getSign()), preEvent.getSignLines(), chestShopMetaData);
Expand All @@ -85,7 +85,7 @@ public static void onSignChange(SignChangeEvent event) {
ChestShopSign.saveChestShopMetaData(sign, chestShopMetaData);
}

public static ChestShopMetaData createShopMetaData(Sign sign, Player creator, String[] signLines, ItemStack itemStack) {
public static ChestShopMetaData createShopMetaData(Player creator, String[] signLines, ItemStack itemStack) {

int quantity = Integer.parseInt(signLines[1].replaceAll("[^0-9]", ""));

Expand All @@ -97,20 +97,20 @@ public static ChestShopMetaData createShopMetaData(Sign sign, Player creator, St
boolean isAdminShop = ChestShopSign.isAdminshopLine(ownerLine);

if (isAdminShop) {
return createAdminChestShop(sign, quantity, sellPrice, buyPrice, itemStack);
return createAdminChestShop(quantity, sellPrice, buyPrice, itemStack);
} else {
return createChestShop(sign, creator.getUniqueId(), quantity, sellPrice, buyPrice, itemStack);
return createChestShop(creator.getUniqueId(), quantity, sellPrice, buyPrice, itemStack);
}

}

private static ChestShopMetaData createChestShop(Sign sign, UUID owner, int quantity, double sellPrice, double buyPrice,
private static ChestShopMetaData createChestShop(UUID owner, int quantity, double sellPrice, double buyPrice,
ItemStack itemStack) {

return new ChestShopMetaData(owner, quantity, sellPrice, buyPrice, itemStack);
}

private static ChestShopMetaData createAdminChestShop(Sign sign, int quantity, double sellPrice, double buyPrice, ItemStack itemStack) {
private static ChestShopMetaData createAdminChestShop(int quantity, double sellPrice, double buyPrice, ItemStack itemStack) {

return new ChestShopMetaData(NameManager.getAdminShopUUID(), quantity, sellPrice, buyPrice, itemStack);
}
Expand Down

0 comments on commit 05c2450

Please sign in to comment.