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 player

Thg player creating the stargate

* @param portal

The created portal

* @param lines

The lines of the sign creating the star gate

* @param deny

Whether to deny the creation of the new gate

* @param denyReason

The reason stargate creation was denied

* @param cost

The 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 index

The line number to get

* @return

The text on the given line

* @throws IndexOutOfBoundsException

If 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 * * @return

Whether the stargate creation should be denied

*/ public boolean getDeny() { return deny; } /** * Sets whether the stargate creation should be denied * * @param deny

Whether the stargate creation should be denied

*/ public void setDeny(boolean deny) { this.deny = deny; } /** * Gets the reason the stargate creation was denied * * @return

The reason the stargate creation was denied

*/ public String getDenyReason() { return denyReason; } /** * Sets the reason the stargate creation was denied * * @param denyReason

The new reason why the stargate creation was denied

*/ public void setDenyReason(String denyReason) { this.denyReason = denyReason; } /** * Gets the cost of creating the stargate * * @return

The cost of creating the stargate

*/ public int getCost() { return cost; } /** * Sets the cost of creating the stargate * * @param cost

The new cost of creating the stargate

*/ public void setCost(int cost) { this.cost = cost; } /** * Gets a handler-list containing all event handlers * * @return

A handler-list with all event handlers

*/ public static HandlerList getHandlerList() { return handlers; } @NotNull @Override public HandlerList getHandlers() { return handlers; } }