mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-27 02:49:19 +00:00
38 lines
2.0 KiB
Diff
38 lines
2.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Bjarne Koll <lynxplay101@gmail.com>
|
|
Date: Sun, 19 Feb 2023 16:14:28 +0100
|
|
Subject: [PATCH] KTP: Optimize spigot event bus
|
|
|
|
Original license: GPL v3
|
|
Original project: https://github.com/lynxplay/ktp
|
|
|
|
This patch contains a lot of small optimizations to the spigot event bus
|
|
to improve its speed as much as possible, allowing for a large amount of
|
|
events to be published by the server without impacting the overall
|
|
performance too much.
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
|
index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..760535e1d6335cf07b6222525610a11318d2596f 100644
|
|
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
|
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
|
@@ -36,11 +36,17 @@ class PaperEventManager {
|
|
|
|
// SimplePluginManager
|
|
public void callEvent(@NotNull Event event) {
|
|
- if (event.isAsynchronous() && this.server.isPrimaryThread()) {
|
|
+ // KTP start - Optimise spigot event bus
|
|
+ if (event.asynchronous() != net.kyori.adventure.util.TriState.NOT_SET) {
|
|
+ final boolean onPrimaryThread = this.server.isPrimaryThread();
|
|
+ final boolean isAsync = event.isAsynchronous();
|
|
+ if (isAsync && onPrimaryThread) {
|
|
throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
|
|
- } else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
|
|
+ } else if (!isAsync && !onPrimaryThread && !this.server.isStopping()) {
|
|
throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
|
|
}
|
|
+ // KTP stop - Optimise spigot event bus
|
|
+ }
|
|
|
|
HandlerList handlers = event.getHandlers();
|
|
RegisteredListener[] listeners = handlers.getRegisteredListeners();
|