2021-02-07 03:37:25 +01:00
|
|
|
package net.knarcraft.stargate.event;
|
|
|
|
|
2021-02-22 17:01:47 +01:00
|
|
|
import net.knarcraft.stargate.portal.Portal;
|
2021-02-07 03:37:25 +01:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.HandlerList;
|
2021-02-12 00:26:47 +01:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2021-02-07 03:37:25 +01:00
|
|
|
|
|
|
|
/**
|
2021-02-12 00:26:47 +01:00
|
|
|
* This event represents an event where a star gate is destroyed or attempted to be destroyed
|
2021-02-07 03:37:25 +01:00
|
|
|
*/
|
2021-02-19 12:06:23 +01:00
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public class StargateDestroyEvent extends StargatePlayerEvent {
|
2021-02-07 03:37:25 +01:00
|
|
|
|
2021-02-20 13:57:04 +01:00
|
|
|
private static final HandlerList handlers = new HandlerList();
|
2021-02-07 03:37:25 +01:00
|
|
|
private boolean deny;
|
|
|
|
private String denyReason;
|
|
|
|
private int cost;
|
|
|
|
|
2021-02-12 00:26:47 +01:00
|
|
|
/**
|
|
|
|
* Instantiates a new Stargate Destroy Event
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
|
|
|
* @param portal <p>The portal destroyed</p>
|
|
|
|
* @param player <p>The player destroying the portal</p>
|
|
|
|
* @param deny <p>Whether the event should be denied (cancelled)</p>
|
2021-02-12 00:26:47 +01:00
|
|
|
* @param denyMsg <p>The message to display if the event is denied</p>
|
2021-02-20 13:57:04 +01:00
|
|
|
* @param cost <p>The cost of destroying the portal</p>
|
2021-02-12 00:26:47 +01:00
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public StargateDestroyEvent(Portal portal, Player player, boolean deny, String denyMsg, int cost) {
|
2021-02-19 12:06:23 +01:00
|
|
|
super("StargateDestroyEvent", portal, player);
|
2021-02-07 03:37:25 +01:00
|
|
|
this.deny = deny;
|
|
|
|
this.denyReason = denyMsg;
|
|
|
|
this.cost = cost;
|
|
|
|
}
|
|
|
|
|
2021-02-20 13:57:04 +01:00
|
|
|
/**
|
|
|
|
* Gets a handler-list containing all event handlers
|
|
|
|
*
|
|
|
|
* @return <p>A handler-list with all event handlers</p>
|
|
|
|
*/
|
|
|
|
public static HandlerList getHandlerList() {
|
|
|
|
return handlers;
|
|
|
|
}
|
|
|
|
|
2021-02-12 00:26:47 +01:00
|
|
|
/**
|
|
|
|
* Gets whether this event should be denied
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
2021-02-12 00:26:47 +01:00
|
|
|
* @return <p>Whether this event should be denied</p>
|
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public boolean getDeny() {
|
|
|
|
return deny;
|
|
|
|
}
|
|
|
|
|
2021-02-12 00:26:47 +01:00
|
|
|
/**
|
|
|
|
* Sets whether this event should be denied
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
2021-02-12 00:26:47 +01:00
|
|
|
* @param deny <p>Whether this event should be denied</p>
|
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public void setDeny(boolean deny) {
|
|
|
|
this.deny = deny;
|
|
|
|
}
|
|
|
|
|
2021-02-12 00:26:47 +01:00
|
|
|
/**
|
|
|
|
* Gets the reason the event was denied
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
2021-02-12 00:26:47 +01:00
|
|
|
* @return <p>The reason the event was denied</p>
|
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public String getDenyReason() {
|
|
|
|
return denyReason;
|
|
|
|
}
|
|
|
|
|
2021-02-12 00:26:47 +01:00
|
|
|
/**
|
|
|
|
* Sets the reason the event was denied
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
2021-02-12 00:26:47 +01:00
|
|
|
* @param denyReason <p>The reason the event was denied</p>
|
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public void setDenyReason(String denyReason) {
|
|
|
|
this.denyReason = denyReason;
|
|
|
|
}
|
|
|
|
|
2021-02-12 00:26:47 +01:00
|
|
|
/**
|
|
|
|
* Gets the cost of destroying the portal
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
2021-02-12 00:26:47 +01:00
|
|
|
* @return <p>The cost of destroying the portal</p>
|
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public int getCost() {
|
|
|
|
return cost;
|
|
|
|
}
|
|
|
|
|
2021-02-12 00:26:47 +01:00
|
|
|
/**
|
|
|
|
* Sets the cost of destroying the portal
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
2021-02-12 00:26:47 +01:00
|
|
|
* @param cost <p>The cost of destroying the portal</p>
|
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public void setCost(int cost) {
|
|
|
|
this.cost = cost;
|
|
|
|
}
|
|
|
|
|
2021-02-19 12:06:23 +01:00
|
|
|
@NotNull
|
|
|
|
@Override
|
|
|
|
public HandlerList getHandlers() {
|
|
|
|
return handlers;
|
|
|
|
}
|
|
|
|
|
2021-02-07 03:37:25 +01:00
|
|
|
}
|