From 2b7b45b7d357ccf4e0615e84aeabbe7ad1e1f23e Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 19 Apr 2013 15:13:30 +0200 Subject: [PATCH] Working some one the MCore event classes. I will lie and say that all events are cancellable. In situations where we dont want them to be cancellable we can simply not care about that boolean. --- .../event/MCoreAfterPlayerRespawnEvent.java | 1 + .../event/MCoreAfterPlayerTeleportEvent.java | 1 + .../mcore/event/MCoreCancellableEvent.java | 15 --------------- .../massivecraft/mcore/event/MCoreEvent.java | 19 +++++++++++++++++-- .../mcore/event/MCorePlayerLeaveEvent.java | 1 + 5 files changed, 20 insertions(+), 17 deletions(-) delete mode 100644 src/com/massivecraft/mcore/event/MCoreCancellableEvent.java diff --git a/src/com/massivecraft/mcore/event/MCoreAfterPlayerRespawnEvent.java b/src/com/massivecraft/mcore/event/MCoreAfterPlayerRespawnEvent.java index 685a3f0a..8a48437e 100644 --- a/src/com/massivecraft/mcore/event/MCoreAfterPlayerRespawnEvent.java +++ b/src/com/massivecraft/mcore/event/MCoreAfterPlayerRespawnEvent.java @@ -12,6 +12,7 @@ public class MCoreAfterPlayerRespawnEvent extends Event implements Runnable // -------------------------------------------- // // REQUIRED EVENT CODE // -------------------------------------------- // + private static final HandlerList handlers = new HandlerList(); @Override public HandlerList getHandlers() { return handlers; } public static HandlerList getHandlerList() { return handlers; } diff --git a/src/com/massivecraft/mcore/event/MCoreAfterPlayerTeleportEvent.java b/src/com/massivecraft/mcore/event/MCoreAfterPlayerTeleportEvent.java index ee3a5f58..c37f2771 100644 --- a/src/com/massivecraft/mcore/event/MCoreAfterPlayerTeleportEvent.java +++ b/src/com/massivecraft/mcore/event/MCoreAfterPlayerTeleportEvent.java @@ -14,6 +14,7 @@ public class MCoreAfterPlayerTeleportEvent extends Event implements Runnable // -------------------------------------------- // // REQUIRED EVENT CODE // -------------------------------------------- // + private static final HandlerList handlers = new HandlerList(); @Override public HandlerList getHandlers() { return handlers; } public static HandlerList getHandlerList() { return handlers; } diff --git a/src/com/massivecraft/mcore/event/MCoreCancellableEvent.java b/src/com/massivecraft/mcore/event/MCoreCancellableEvent.java deleted file mode 100644 index 9e56c2c6..00000000 --- a/src/com/massivecraft/mcore/event/MCoreCancellableEvent.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.massivecraft.mcore.event; - -import org.bukkit.event.Cancellable; - -public abstract class MCoreCancellableEvent extends MCoreEvent implements Cancellable -{ - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private boolean cancelled = false; - @Override public boolean isCancelled() { return this.cancelled; } - @Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; } - -} diff --git a/src/com/massivecraft/mcore/event/MCoreEvent.java b/src/com/massivecraft/mcore/event/MCoreEvent.java index 0409b39e..e5815d85 100644 --- a/src/com/massivecraft/mcore/event/MCoreEvent.java +++ b/src/com/massivecraft/mcore/event/MCoreEvent.java @@ -1,12 +1,27 @@ package com.massivecraft.mcore.event; +import java.util.LinkedHashMap; +import java.util.Map; + import org.bukkit.Bukkit; +import org.bukkit.event.Cancellable; import org.bukkit.event.Event; -public abstract class MCoreEvent extends Event implements Runnable +public abstract class MCoreEvent extends Event implements Runnable, Cancellable { // -------------------------------------------- // - // RUN + // FIELDS + // -------------------------------------------- // + + private final Map customData = new LinkedHashMap(); + public Map getCustomData() { return this.customData; } + + private boolean cancelled = false; + @Override public boolean isCancelled() { return this.cancelled; } + @Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; } + + // -------------------------------------------- // + // OVERRIDE: RUNNABLE // -------------------------------------------- // @Override diff --git a/src/com/massivecraft/mcore/event/MCorePlayerLeaveEvent.java b/src/com/massivecraft/mcore/event/MCorePlayerLeaveEvent.java index a7b1d6b5..4e962fe8 100644 --- a/src/com/massivecraft/mcore/event/MCorePlayerLeaveEvent.java +++ b/src/com/massivecraft/mcore/event/MCorePlayerLeaveEvent.java @@ -23,6 +23,7 @@ public class MCorePlayerLeaveEvent extends Event implements Runnable // -------------------------------------------- // // REQUIRED EVENT CODE // -------------------------------------------- // + private static final HandlerList handlers = new HandlerList(); @Override public HandlerList getHandlers() { return handlers; } public static HandlerList getHandlerList() { return handlers; }