Add ShopSelectItemEvent

This commit is contained in:
Eric 2019-08-17 14:08:29 +02:00
parent d2af5fb0ad
commit 5ddda4cce5
2 changed files with 121 additions and 0 deletions

View File

@ -9,7 +9,11 @@ import org.bukkit.event.HandlerList;
/**
* Called when a player enters the command to create a shop
* <p>
* 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
*

View File

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