Add and call RegionizedServerInitEvent from Folia (#13034)

This commit is contained in:
Jason Penilla
2025-08-28 18:09:09 -07:00
committed by GitHub
parent b6168b7ccc
commit 9d1d0ef3f3
2 changed files with 27 additions and 1 deletions
@@ -0,0 +1,25 @@
package io.papermc.paper.threadedregions;
import org.bukkit.event.HandlerList;
import org.bukkit.event.server.ServerEvent;
import org.jspecify.annotations.NullMarked;
/**
* 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.
*/
@NullMarked
public class RegionizedServerInitEvent extends ServerEvent {
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}
@@ -747,7 +747,7 @@
protected void runServer() {
try {
if (!this.initServer()) {
@@ -675,6 +_,35 @@
@@ -675,6 +_,36 @@
this.statusIcon = this.loadStatusIcon().orElse(null);
this.status = this.buildServerStatus();
@@ -755,6 +755,7 @@
+ // Spigot start
+ // Paper start
+ LOGGER.info("Running delayed init tasks");
+ new io.papermc.paper.threadedregions.RegionizedServerInitEvent().callEvent(); // Call Folia init event
+ this.server.getScheduler().mainThreadHeartbeat(); // run all 1 tick delay tasks during init,
+ // this is going to be the first thing the tick process does anyways, so move done and run it after
+ // everything is init before watchdog tick.