mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
fix enderman issue (why)
This commit is contained in:
@@ -1,39 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
||||||
Date: Mon, 26 May 2025 02:02:57 +0300
|
|
||||||
Subject: [PATCH] Optimization for HandlerList and Event#callEvent
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java
|
|
||||||
index 7fd1f4b59584d840759e6c100743d646cb98348e..99c73966b63c74bc8c675de4073e601f09ae0eec 100644
|
|
||||||
--- a/src/main/java/org/bukkit/event/Event.java
|
|
||||||
+++ b/src/main/java/org/bukkit/event/Event.java
|
|
||||||
@@ -43,6 +43,7 @@ public abstract class Event {
|
|
||||||
* @return {@code false} if event was cancelled, if cancellable. otherwise {@code true}.
|
|
||||||
*/
|
|
||||||
public boolean callEvent() {
|
|
||||||
+ if (!getHandlers().hasRegisteredListeners()) return true; // DivineMC - Optimization for HandlerList and Event#callEvent
|
|
||||||
Bukkit.getPluginManager().callEvent(this);
|
|
||||||
if (this instanceof Cancellable) {
|
|
||||||
return !((Cancellable) this).isCancelled();
|
|
||||||
diff --git a/src/main/java/org/bukkit/event/HandlerList.java b/src/main/java/org/bukkit/event/HandlerList.java
|
|
||||||
index ef9d9f3ddaf25aa990715139e1916672f76c35e5..3f61b6daca72f1949d35c3adade5a7fec96fc3d9 100644
|
|
||||||
--- a/src/main/java/org/bukkit/event/HandlerList.java
|
|
||||||
+++ b/src/main/java/org/bukkit/event/HandlerList.java
|
|
||||||
@@ -244,4 +244,16 @@ public class HandlerList {
|
|
||||||
return (ArrayList<HandlerList>) allLists.clone();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ // DivineMC start - Optimization for HandlerList and Event#callEvent
|
|
||||||
+ /**
|
|
||||||
+ * Checks if this HandlerList has any registered listeners.
|
|
||||||
+ *
|
|
||||||
+ * @return true if there are registered listeners, false otherwise
|
|
||||||
+ * @apiNote if length is less than 0 or null, it has no listeners
|
|
||||||
+ */
|
|
||||||
+ public boolean hasRegisteredListeners() {
|
|
||||||
+ return this.handlers != null && this.handlers.length > 0;
|
|
||||||
+ }
|
|
||||||
+ // DivineMC end - Optimization for HandlerList and Event#callEvent
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user