diff --git a/api/src/main/java/de/epiceric/shopchest/api/ShopChest.java b/api/src/main/java/de/epiceric/shopchest/api/ShopChest.java index 270535d..7e75829 100644 --- a/api/src/main/java/de/epiceric/shopchest/api/ShopChest.java +++ b/api/src/main/java/de/epiceric/shopchest/api/ShopChest.java @@ -1,8 +1,10 @@ package de.epiceric.shopchest.api; -import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import de.epiceric.shopchest.api.player.ShopPlayer; + /** * The plugin's main entry point * @@ -18,13 +20,11 @@ public abstract class ShopChest extends JavaPlugin { public abstract ShopManager getShopManager(); /** - * Gets the amount of shops the given player is allowed to have - *

- * If the player has no shop limit {@link Integer#MAX_VALUE} is returned. + * Gets the wrapped {@link ShopPlayer} for the given player * * @param player the player - * @return the shop limit + * @return the wrapped player */ - public abstract int getShopLimit(OfflinePlayer player); + public abstract ShopPlayer wrapPlayer(Player player); } \ No newline at end of file diff --git a/api/src/main/java/de/epiceric/shopchest/api/flag/Flag.java b/api/src/main/java/de/epiceric/shopchest/api/flag/Flag.java new file mode 100644 index 0000000..2dd2b12 --- /dev/null +++ b/api/src/main/java/de/epiceric/shopchest/api/flag/Flag.java @@ -0,0 +1,9 @@ +package de.epiceric.shopchest.api.flag; + +/** + * Represents a flag a player can have + * + * @since 1.13 + */ +public interface Flag { +} \ No newline at end of file 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 new file mode 100644 index 0000000..ba95728 --- /dev/null +++ b/api/src/main/java/de/epiceric/shopchest/api/player/ShopPlayer.java @@ -0,0 +1,69 @@ +package de.epiceric.shopchest.api.player; + +import java.util.Collection; + +import org.bukkit.entity.Player; + +import de.epiceric.shopchest.api.ShopManager; +import de.epiceric.shopchest.api.flag.Flag; +import de.epiceric.shopchest.api.shop.Shop; + +/** + * A wrapper for a {@link Player} with additional functions + * + * @since 1.13 + */ +public interface ShopPlayer { + + /** + * Gets the wrapped Bukkit player + * + * @return the wrapped player + * @since 1.13 + */ + Player getPlayer(); + + /** + * Gets this player's flag + * + * @return the flag or {@code null} if the player does not have one + * @since 1.13 + */ + Flag getFlag(); + + /** + * Sets this player's flag + * + * @param flag the flag + * @since 1.13 + */ + void setFlag(Flag flag); + + /** + * Gets whether this player has a flag + * + * @return whether this player has a flag + * @since 1.13 + */ + boolean hasFlag(); + + /** + * Gets the amount of shops the given player is allowed to have + *

+ * If the player has no shop limit {@link Integer#MAX_VALUE} is returned. + * + * @return the shop limit + * @since 1.13 + */ + int getShopLimit(); + + /** + * Gets the shops this player owns + * + * @return a collection of shops + * @since 1.13 + * @see ShopManager#getShops(org.bukkit.OfflinePlayer) + */ + Collection getShops(); + +} \ No newline at end of file diff --git a/api/src/main/java/de/epiceric/shopchest/api/shop/Shop.java b/api/src/main/java/de/epiceric/shopchest/api/shop/Shop.java index 19d6abc..9e40e6e 100644 --- a/api/src/main/java/de/epiceric/shopchest/api/shop/Shop.java +++ b/api/src/main/java/de/epiceric/shopchest/api/shop/Shop.java @@ -26,9 +26,9 @@ public interface Shop { int getId(); /** - * Gets the player who created this shop + * Gets the player who owns this shop * - * @return the vendor + * @return the vendor or {@code null} if this shop is an admin shop * @since 1.13 */ OfflinePlayer getVendor(); @@ -84,15 +84,9 @@ public interface Shop { * @return whether this shop is an admin shop * @since 1.13 */ - boolean isAdminShop(); - - /** - * Sets whether this shop is an admin shop - * - * @param adminShop whether this shop should be an admin shop - * @since 1.13 - */ - void setAdminShop(boolean adminShop); + default boolean isAdminShop() { + return getVendor() == null; + } /** * Gets the price for which a player can buy the product from this shop