mirror of
https://github.com/BX-Team/DivineMC.git
synced 2026-01-04 15:31:43 +00:00
update upstream
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Bjarne Koll <lynxplay101@gmail.com>
|
||||
Date: Thu, 9 Dec 2021 01:53:30 +0100
|
||||
Subject: [PATCH] Optimize Spigot event bus
|
||||
|
||||
Original code by lynxplay, licensed under GNU General Public License v3.0
|
||||
You can find the original code on https://github.com/lynxplay/ktp
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/RegisteredListener.java b/src/main/java/org/bukkit/plugin/RegisteredListener.java
|
||||
index 3b3d9642a8d63798dc28f2f8df77f0466451cbff..8d3605f25e97a375971705c737bc7bacbac045cd 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/RegisteredListener.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/RegisteredListener.java
|
||||
@@ -62,8 +62,10 @@ public class RegisteredListener {
|
||||
* @throws EventException If an event handler throws an exception.
|
||||
*/
|
||||
public void callEvent(@NotNull final Event event) throws EventException {
|
||||
- if (event instanceof Cancellable) {
|
||||
- if (((Cancellable) event).isCancelled() && isIgnoringCancelled()) {
|
||||
+ // KTP start - optimize spigot event bus
|
||||
+ if (isIgnoringCancelled()) {
|
||||
+ if (event instanceof Cancellable cancellable && cancellable.isCancelled()) {
|
||||
+ // KTP end - optimize spigot event bus
|
||||
return;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
index c077e7c883613fcb6e559b4e4776e794caa3b363..ba869354adc59db2fc547c481c1ed4d5d0af23b7 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
@@ -656,11 +656,15 @@ public final class SimplePluginManager implements PluginManager {
|
||||
@Override
|
||||
public void callEvent(@NotNull Event event) {
|
||||
// Paper - replace callEvent by merging to below method
|
||||
- if (event.isAsynchronous() && server.isPrimaryThread()) {
|
||||
+ // KTP start - optimize spigot event bus
|
||||
+ final boolean isAsync = event.isAsynchronous();
|
||||
+ final boolean isPrimary = server.isPrimaryThread(); // Cache to prevent multiple thread object comparisons.
|
||||
+ if (isAsync && isPrimary) {
|
||||
throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
|
||||
- } else if (!event.isAsynchronous() && !server.isPrimaryThread() && !server.isStopping() ) {
|
||||
+ } else if (!isAsync && !isPrimary && !server.isStopping() ) {
|
||||
throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
|
||||
}
|
||||
+ // KTP end - optimize spigot event bus
|
||||
|
||||
HandlerList handlers = event.getHandlers();
|
||||
RegisteredListener[] listeners = handlers.getRegisteredListeners();
|
||||
Reference in New Issue
Block a user