diff --git a/API/.idea/workspace.xml b/API/.idea/workspace.xml
index 6fc41610..5ae5a09f 100644
--- a/API/.idea/workspace.xml
+++ b/API/.idea/workspace.xml
@@ -12,18 +12,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -36,18 +28,18 @@
-
-
+
+
-
+
-
+
@@ -55,20 +47,20 @@
-
+
-
+
-
+
@@ -112,90 +104,73 @@
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -224,6 +199,7 @@
@@ -275,8 +251,6 @@
-
-
@@ -289,7 +263,6 @@
-
@@ -301,6 +274,11 @@
+
+
+
+
+
@@ -323,8 +301,6 @@
-
-
@@ -452,6 +428,8 @@
+
+
@@ -499,8 +477,9 @@
+
-
+
@@ -561,7 +540,6 @@
-
@@ -578,34 +556,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -752,13 +702,6 @@
-
-
-
-
-
-
-
@@ -770,9 +713,6 @@
-
-
-
@@ -834,7 +774,7 @@
-
+
@@ -849,6 +789,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -863,10 +824,31 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/API/src/cc/funkemunky/api/event/custom/PacketRecieveEvent.java b/API/src/cc/funkemunky/api/event/custom/PacketRecieveEvent.java
index 3cafca27..df459265 100644
--- a/API/src/cc/funkemunky/api/event/custom/PacketRecieveEvent.java
+++ b/API/src/cc/funkemunky/api/event/custom/PacketRecieveEvent.java
@@ -11,11 +11,14 @@ public class PacketRecieveEvent extends Event implements Cancellable {
private Object packet;
private boolean cancelled;
private String type;
+ private long timeStamp;
public PacketRecieveEvent(Player player, Object packet, String type) {
this.player = player;
this.packet = packet;
this.type = type;
+
+ timeStamp = System.currentTimeMillis();
}
@Override
diff --git a/API/src/cc/funkemunky/api/event/custom/PacketSendEvent.java b/API/src/cc/funkemunky/api/event/custom/PacketSendEvent.java
index 4ee2800b..57b79fa3 100644
--- a/API/src/cc/funkemunky/api/event/custom/PacketSendEvent.java
+++ b/API/src/cc/funkemunky/api/event/custom/PacketSendEvent.java
@@ -13,11 +13,14 @@ public class PacketSendEvent extends Event implements Cancellable {
private Object packet;
private boolean cancelled;
private String type;
+ private long timeStamp;
public PacketSendEvent(Player player, Object packet, String type) {
this.player = player;
this.packet = packet;
this.type = type;
+
+ timeStamp = System.currentTimeMillis();
}
@Override
diff --git a/API/src/cc/funkemunky/api/event/system/EnumPriority.java b/API/src/cc/funkemunky/api/event/system/EnumPriority.java
new file mode 100644
index 00000000..b9c191b1
--- /dev/null
+++ b/API/src/cc/funkemunky/api/event/system/EnumPriority.java
@@ -0,0 +1,14 @@
+package cc.funkemunky.api.event.system;
+
+import lombok.Getter;
+
+public enum EnumPriority {
+ LOWEST(0), LOW(1), NORMAL(2), HIGH(3), HIGHEST(4);
+
+ @Getter
+ private int priority;
+
+ EnumPriority(int priority) {
+ this.priority = priority;
+ }
+}
diff --git a/API/src/cc/funkemunky/api/event/system/EventManager.java b/API/src/cc/funkemunky/api/event/system/EventManager.java
index c6a57710..caf63e95 100755
--- a/API/src/cc/funkemunky/api/event/system/EventManager.java
+++ b/API/src/cc/funkemunky/api/event/system/EventManager.java
@@ -1,6 +1,7 @@
package cc.funkemunky.api.event.system;
import cc.funkemunky.api.Atlas;
+import com.google.common.collect.Lists;
import org.bukkit.block.Block;
import org.bukkit.scheduler.BukkitRunnable;
@@ -18,6 +19,10 @@ public static void register(Listener listener) {
if (method.isAnnotationPresent(EventMethod.class)) {
List methods = registered.getOrDefault(listener, new ArrayList<>());
methods.add(method);
+
+ methods.sort(Comparator.comparingInt(m -> m.getAnnotation(EventMethod.class).priority().getPriority()));
+ Collections.reverse(methods);
+
registered.put(listener, methods);
}
}
@@ -40,7 +45,7 @@ public static void callEvent(Event event) {
Atlas.getInstance().getThreadPool().execute(() -> call(event));
}
- private synchronized static void call(Event event) {
+ private static void call(Event event) {
for (Listener listener : registered.keySet()) {
for (Method method : registered.get(listener)) {
if (method.getParameterTypes()[0] == event.getClass()) {
diff --git a/API/src/cc/funkemunky/api/event/system/EventMethod.java b/API/src/cc/funkemunky/api/event/system/EventMethod.java
index 19d770ba..eda0bae0 100755
--- a/API/src/cc/funkemunky/api/event/system/EventMethod.java
+++ b/API/src/cc/funkemunky/api/event/system/EventMethod.java
@@ -1,5 +1,7 @@
package cc.funkemunky.api.event.system;
+import org.bukkit.event.EventPriority;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -8,5 +10,7 @@
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = {ElementType.METHOD})
public @interface EventMethod {
+
+ EnumPriority priority() default EnumPriority.NORMAL;
}