Folia/patches/api/0004-Add-RegionisedServerInitEvent.patch

43 lines
1.6 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Tue, 7 Mar 2023 12:58:48 -0800
Subject: [PATCH] Add RegionisedServerInitEvent
This event allows plugins to perform synchronous operations before
any region will tick. Plugins will not have to worry about the
possibility of a region ticking in parallel while listening
to the event.
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionisedServerInitEvent.java b/src/main/java/io/papermc/paper/threadedregions/RegionisedServerInitEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..8ffadb7c54087b79cdf7ebe11367b9d5884536e6
--- /dev/null
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionisedServerInitEvent.java
@@ -0,0 +1,26 @@
+package io.papermc.paper.threadedregions;
+
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.server.ServerEvent;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * This event is called after the server is initialised but <b>before</b> the server begins ticking regions in parallel.
+ * Plugins may use this as a hook to run post initialisation logic without worrying about the possibility that
+ * regions are ticking in parallel.
+ */
+public class RegionisedServerInitEvent extends ServerEvent {
+
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}