9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00
Files
DivineMC/patches/server/0018-Optimize-Paper-Event-Manager.patch
Artem Ostrasev 774a111315 [ci-skip] New patches and optimisations (#11)
I'll make some changes now, so skipping build

Changelog:

* add CarpetFixes optimizations

* fix optimizations config

* lithium optimizations

* add Carpet Fixes Sheep Optimization

* add Async Pathfinding; add C2ME opts math

* add 2 vmp patches

* New performance patches; update README and wiki README

* update configuration on wiki

* update wiki main page

* Updated Upstream (Purpur)

* fix conflicts

* make "Don't save Fireworks" patch configurable

* Disable memory reserve allocating

* Fix MC-172801

* resolve conflicts

* add bstats to readme

* dd custom list of forks

* update logo link
2024-02-11 15:04:54 +03:00

42 lines
2.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sun, 25 Jun 2023 13:38:03 +0300
Subject: [PATCH] Optimize Paper Event Manager
Original project: lynxplay/ktp
Link: https://github.com/lynxplay/ktp
Modified by NONPLAYT
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..0e3bed7a75f8f4611f9f44a1f78fd70cc06eaa54 100644
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
@@ -36,14 +36,21 @@ class PaperEventManager {
// SimplePluginManager
public void callEvent(@NotNull Event event) {
- if (event.isAsynchronous() && this.server.isPrimaryThread()) {
- throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
- } else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
- throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
- }
-
+ // DivineMC start - Optimize Paper Event Manager
HandlerList handlers = event.getHandlers();
RegisteredListener[] listeners = handlers.getRegisteredListeners();
+ if (listeners.length == 0) return;
+
+ 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 (!isAsync && !onPrimaryThread && !this.server.isStopping()) {
+ throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
+ }
+ }
+ // DivineMC end
for (RegisteredListener registration : listeners) {
if (!registration.getPlugin().isEnabled()) {