From 52d3833961103a1580f5b2eff929623a7f060012 Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 20 Aug 2022 22:16:49 +0200 Subject: [PATCH] Rename ShopPlayer#ownsShop to ShopPlayer#isVendor --- .../java/de/epiceric/shopchest/api/player/ShopPlayer.java | 8 +++++--- .../shopchest/listener/ChestInteractListener.java | 2 +- .../shopchest/listener/internal/ShopInteractListener.java | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/de/epiceric/shopchest/api/player/ShopPlayer.java b/api/src/main/java/de/epiceric/shopchest/api/player/ShopPlayer.java index f635bb3..6054c4d 100644 --- a/api/src/main/java/de/epiceric/shopchest/api/player/ShopPlayer.java +++ b/api/src/main/java/de/epiceric/shopchest/api/player/ShopPlayer.java @@ -117,9 +117,11 @@ public interface ShopPlayer { * * @param shop the shop * @return whether this player is the vendor + * @since 1.13 */ - default boolean ownsShop(Shop shop) { - return shop != null && !shop.isAdminShop() - && shop.getVendor().get().getUniqueId().equals(getBukkitPlayer().getUniqueId()); + default boolean isVendor(Shop shop) { + return shop != null && shop.getVendor() + .map(vendor -> vendor.getUniqueId().equals(getBukkitPlayer().getUniqueId())) + .orElse(false); } } \ No newline at end of file diff --git a/core/src/main/java/de/epiceric/shopchest/listener/ChestInteractListener.java b/core/src/main/java/de/epiceric/shopchest/listener/ChestInteractListener.java index 0f7dce8..1379383 100644 --- a/core/src/main/java/de/epiceric/shopchest/listener/ChestInteractListener.java +++ b/core/src/main/java/de/epiceric/shopchest/listener/ChestInteractListener.java @@ -41,7 +41,7 @@ public class ChestInteractListener implements Listener { } private void handleShopUse(Shop shop, ShopPlayer player, Type type, Cancellable e) { - if (player.ownsShop(shop)) { + if (player.isVendor(shop)) { return; // vendors cannot use their own shops } diff --git a/core/src/main/java/de/epiceric/shopchest/listener/internal/ShopInteractListener.java b/core/src/main/java/de/epiceric/shopchest/listener/internal/ShopInteractListener.java index 452a89b..0433360 100644 --- a/core/src/main/java/de/epiceric/shopchest/listener/internal/ShopInteractListener.java +++ b/core/src/main/java/de/epiceric/shopchest/listener/internal/ShopInteractListener.java @@ -60,7 +60,7 @@ public class ShopInteractListener implements Listener { return; } - if (!player.ownsShop(shop) && !player.hasPermission("shopchest.edit.other")) { + if (!player.isVendor(shop) && !player.hasPermission("shopchest.edit.other")) { player.sendMessage("§cYou don't have permission to edit this shop."); // TODO: i18n e.setCancelled(true); return; @@ -78,7 +78,7 @@ public class ShopInteractListener implements Listener { return; } - if (!player.ownsShop(shop) && !player.hasPermission("shopchest.remove.other")) { + if (!player.isVendor(shop) && !player.hasPermission("shopchest.remove.other")) { player.sendMessage("§cYou don't have permission to remove this shop."); // TODO: i18n e.setCancelled(true); return;