Rename ShopPlayer#ownsShop to ShopPlayer#isVendor

This commit is contained in:
Eric 2022-08-20 22:16:49 +02:00
parent cec3e1ccdf
commit 52d3833961
3 changed files with 8 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -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
}

View File

@ -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;