diff --git a/api/src/main/java/de/epiceric/shopchest/api/event/ShopPreCreateEvent.java b/api/src/main/java/de/epiceric/shopchest/api/event/ShopPreCreateEvent.java index 5b0f311..7da8743 100644 --- a/api/src/main/java/de/epiceric/shopchest/api/event/ShopPreCreateEvent.java +++ b/api/src/main/java/de/epiceric/shopchest/api/event/ShopPreCreateEvent.java @@ -9,7 +9,11 @@ import org.bukkit.event.HandlerList; /** * Called when a player enters the command to create a shop + *
+ * The player may have to select an item first, but may also close the + * creative inventory to cancel shop creation. * + * @see ShopSelectItemEvent * @since 1.13 */ public class ShopPreCreateEvent extends Event implements Cancellable { @@ -50,6 +54,16 @@ public class ShopPreCreateEvent extends Event implements Cancellable { return product; } + /** + * Gets whether the item has already been selected + * + * @return whether the item has been selected + * @since 1.13 + */ + public boolean hasProduct() { + return getProduct() != null; + } + /** * Gets the price for which players will be able to buy from the shop * diff --git a/api/src/main/java/de/epiceric/shopchest/api/event/ShopSelectItemEvent.java b/api/src/main/java/de/epiceric/shopchest/api/event/ShopSelectItemEvent.java new file mode 100644 index 0000000..c7a4691 --- /dev/null +++ b/api/src/main/java/de/epiceric/shopchest/api/event/ShopSelectItemEvent.java @@ -0,0 +1,107 @@ +package de.epiceric.shopchest.api.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import de.epiceric.shopchest.api.shop.ShopProduct; + +/** + * Called when a player has selected an item + * + * @since 1.13 + */ +public class ShopSelectItemEvent extends Event implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + + private Player player; + private ShopProduct product; + private double buyPrice; + private double sellPrice; + private boolean admin; + private boolean cancelled; + + public ShopSelectItemEvent(Player player) { + this.player = player; + } + + /** + * Gets the player who is involved in this event + * + * @return the player + * @since 1.13 + */ + public Player getPlayer() { + return player; + } + + /** + * Gets the item the player has selected + * + * @return the item + * @since 1.13 + */ + public ShopProduct getProduct() { + return product; + } + + /** + * Sets the item + * + * @param product the item + * @since 1.13 + */ + public void setProduct(ShopProduct product) { + this.product = product; + } + + /** + * Gets the price for which players will be able to buy from the shop + * + * @return the buy price + * @since 1.13 + */ + public double getBuyPrice() { + return buyPrice; + } + + /** + * Gets the price for which players will be able to sell to the shop + * + * @return the sell price + * @since 1.13 + */ + public double getSellPrice() { + return sellPrice; + } + + /** + * Gets whether the shop will be an admin shop + * + * @return whether the shop will be an admin shop + * @since 1.13 + */ + public boolean isAdminShop() { + return admin; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + cancelled = cancel; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } +}