mirror of
https://github.com/PaperMC/Folia.git
synced 2024-11-21 11:55:11 +01:00
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.
This commit is contained in:
parent
f86bc13d22
commit
2ccfc8efc0
42
patches/api/0004-Add-RegionisedServerInitEvent.patch
Normal file
42
patches/api/0004-Add-RegionisedServerInitEvent.patch
Normal file
@ -0,0 +1,42 @@
|
||||
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;
|
||||
+ }
|
||||
+}
|
@ -4193,10 +4193,10 @@ index 0000000000000000000000000000000000000000..3549e5f3359f38b207e189d895954420
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionisedServer.java b/src/main/java/io/papermc/paper/threadedregions/RegionisedServer.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..269c051e20cd07e692c624a873e4ee2b5ae5589a
|
||||
index 0000000000000000000000000000000000000000..99c258c113cd4257e54f795e09d6d8f3aa2f4e33
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionisedServer.java
|
||||
@@ -0,0 +1,366 @@
|
||||
@@ -0,0 +1,370 @@
|
||||
+package io.papermc.paper.threadedregions;
|
||||
+
|
||||
+import ca.spottedleaf.concurrentutil.collection.MultiThreadedQueue;
|
||||
@ -4263,6 +4263,10 @@ index 0000000000000000000000000000000000000000..269c051e20cd07e692c624a873e4ee2b
|
||||
+ }
|
||||
+
|
||||
+ public void init() {
|
||||
+ // call init event _before_ scheduling anything
|
||||
+ new RegionisedServerInitEvent().callEvent();
|
||||
+
|
||||
+ // now we can schedule
|
||||
+ this.tickHandle.setInitialStart(System.nanoTime() + TickRegionScheduler.TIME_BETWEEN_TICKS);
|
||||
+ TickRegions.getScheduler().scheduleRegion(this.tickHandle);
|
||||
+ TickRegions.getScheduler().init();
|
||||
|
Loading…
Reference in New Issue
Block a user