-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: DenaryDev <[email protected]> | ||
Date: Mon, 6 Jun 2022 00:15:47 +0500 | ||
Subject: [PATCH] Skip event if no listeners | ||
|
||
Ported from JettPack | ||
|
||
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java | ||
index bab8bb3a52cdeef5f7052d4e3f404c42f37d117d..f1eba4a691437e8f3cdc342cbcfea4c93a26f94f 100644 | ||
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java | ||
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java | ||
@@ -650,6 +650,12 @@ public final class SimplePluginManager implements PluginManager { | ||
*/ | ||
@Override | ||
public void callEvent(@NotNull Event event) { | ||
+ // Sapphire start | ||
+ HandlerList handlers = event.getHandlers(); | ||
+ RegisteredListener[] listeners = handlers.getRegisteredListeners(); | ||
+ if (listeners.length == 0) return; | ||
+ // Sapphire end | ||
+ | ||
// Paper - replace callEvent by merging to below method | ||
if (event.isAsynchronous() && server.isPrimaryThread()) { | ||
throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously."); | ||
@@ -657,8 +663,8 @@ public final class SimplePluginManager implements PluginManager { | ||
throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously."); | ||
} | ||
|
||
- HandlerList handlers = event.getHandlers(); | ||
- RegisteredListener[] listeners = handlers.getRegisteredListeners(); | ||
+ // HandlerList handlers = event.getHandlers(); // Sapphire | ||
+ // RegisteredListener[] listeners = handlers.getRegisteredListeners(); // Sapphire | ||
|
||
for (RegisteredListener registration : listeners) { | ||
if (!registration.getPlugin().isEnabled()) { |