package net.knarcraft.stargate.event; import net.knarcraft.stargate.portal.Portal; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; /** * This event should be called whenever a stargate is created * *
This event can be used to deny or change the cost of a stargate creation.
*/ @SuppressWarnings("unused") public class StargateCreateEvent extends StargatePlayerEvent { private static final HandlerList handlers = new HandlerList(); private final String[] lines; private boolean deny; private String denyReason; private int cost; /** * Instantiates a new stargate creation event * * @param playerThg player creating the stargate
* @param portalThe created portal
* @param linesThe lines of the sign creating the star gate
* @param denyWhether to deny the creation of the new gate
* @param denyReasonThe reason stargate creation was denied
* @param costThe cost of creating the new star gate
*/ public StargateCreateEvent(Player player, Portal portal, String[] lines, boolean deny, String denyReason, int cost) { super(portal, player); this.lines = lines; this.deny = deny; this.denyReason = denyReason; this.cost = cost; } /** * Gets a given line from the sign creating the star gate * * @param indexThe line number to get
* @returnThe text on the given line
* @throws IndexOutOfBoundsExceptionIf given a line index less than zero or above three
*/ public String getLine(int index) throws IndexOutOfBoundsException { return lines[index]; } /** * Gets whether the stargate creation should be denied * * @returnWhether the stargate creation should be denied
*/ public boolean getDeny() { return deny; } /** * Sets whether the stargate creation should be denied * * @param denyWhether the stargate creation should be denied
*/ public void setDeny(boolean deny) { this.deny = deny; } /** * Gets the reason the stargate creation was denied * * @returnThe reason the stargate creation was denied
*/ public String getDenyReason() { return denyReason; } /** * Sets the reason the stargate creation was denied * * @param denyReasonThe new reason why the stargate creation was denied
*/ public void setDenyReason(String denyReason) { this.denyReason = denyReason; } /** * Gets the cost of creating the stargate * * @returnThe cost of creating the stargate
*/ public int getCost() { return cost; } /** * Sets the cost of creating the stargate * * @param costThe new cost of creating the stargate
*/ public void setCost(int cost) { this.cost = cost; } /** * Gets a handler-list containing all event handlers * * @returnA handler-list with all event handlers
*/ public static HandlerList getHandlerList() { return handlers; } @NotNull @Override public HandlerList getHandlers() { return handlers; } }