Folia/patches/api/0004-Add-RegionizedServerInitEvent.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
2023-03-25 00:22:47 +01:00
Subject: [PATCH] Add RegionizedServerInitEvent
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.
2023-03-25 00:22:47 +01:00
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionizedServerInitEvent.java b/src/main/java/io/papermc/paper/threadedregions/RegionizedServerInitEvent.java
new file mode 100644
2023-03-25 00:22:47 +01:00
index 0000000000000000000000000000000000000000..c7be944c5638cb6650624bd622b2ad9d52c5c31d
--- /dev/null
2023-03-25 00:22:47 +01:00
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedServerInitEvent.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.
+ */
2023-03-25 00:22:47 +01:00
+public class RegionizedServerInitEvent extends ServerEvent {
+
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}