mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2025-02-21 14:22:12 +01:00
Invert inheritance of RegionEvent and CancellabelRegionEvent/NotifyRegionEvent
This commit is contained in:
parent
d9c3573225
commit
58a1afccf3
@ -1,53 +0,0 @@
|
||||
package me.wiefferink.areashop.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class CancellableEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private String reason;
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the event from happening
|
||||
* @param reason The reason of cancelling, used for display to the user, should end with a dot
|
||||
*/
|
||||
public void cancel(String reason) {
|
||||
this.cancelled = true;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Let the event continue, possible overwriting a cancel() call from another plugin
|
||||
*/
|
||||
public void allow() {
|
||||
this.cancelled = false;
|
||||
this.reason = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the event has been cancelled
|
||||
* @return true if the event has been cancelled, otherwise false
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reason why this event is cancelled
|
||||
* @return null if there is no reason or the event is not cancelled, otherwise a string
|
||||
*/
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
}
|
@ -1,17 +1,45 @@
|
||||
package me.wiefferink.areashop.events;
|
||||
|
||||
public class CancellableRegionEvent<T> extends CancellableEvent {
|
||||
protected T region;
|
||||
public class CancellableRegionEvent<T> extends RegionEvent<T> {
|
||||
|
||||
private boolean cancelled;
|
||||
private String reason;
|
||||
|
||||
public CancellableRegionEvent(T region) {
|
||||
this.region = region;
|
||||
super(region);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the region of this event
|
||||
* @return The region the event is about
|
||||
* Cancel the event from happening
|
||||
* @param reason The reason of cancelling, used for display to the user, should end with a dot
|
||||
*/
|
||||
public T getRegion() {
|
||||
return region;
|
||||
public void cancel(String reason) {
|
||||
this.cancelled = true;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Let the event continue, possible overwriting a cancel() call from another plugin
|
||||
*/
|
||||
public void allow() {
|
||||
this.cancelled = false;
|
||||
this.reason = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the event has been cancelled
|
||||
* @return true if the event has been cancelled, otherwise false
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reason why this event is cancelled
|
||||
* @return null if there is no reason or the event is not cancelled, otherwise a string
|
||||
*/
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,7 @@
|
||||
package me.wiefferink.areashop.events;
|
||||
|
||||
public class NotifyRegionEvent<T> extends NotifyEvent {
|
||||
protected T region;
|
||||
|
||||
public class NotifyRegionEvent<T> extends RegionEvent<T> {
|
||||
public NotifyRegionEvent(T region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the region of this event
|
||||
* @return The region the event is about
|
||||
*/
|
||||
public T getRegion() {
|
||||
return region;
|
||||
super(region);
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,14 @@ package me.wiefferink.areashop.events;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class NotifyEvent extends Event {
|
||||
|
||||
public class RegionEvent<T> extends Event {
|
||||
protected T region;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public RegionEvent(T region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
@ -15,4 +19,12 @@ public class NotifyEvent extends Event {
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the region of this event
|
||||
* @return The region the event is about
|
||||
*/
|
||||
public T getRegion() {
|
||||
return region;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user