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;