From 784d7595405da1c60828bf09403a553cd7d6ed5a Mon Sep 17 00:00:00 2001 From: Vankka Date: Thu, 14 Sep 2023 21:21:11 +0300 Subject: [PATCH] Workaround Folia for serverStarted --- .../bukkit/DiscordSRVBukkitBootstrap.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java b/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java index 73e2adab..a8df5ec8 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java @@ -68,6 +68,19 @@ public class DiscordSRVBukkitBootstrap extends BukkitBootstrap implements IBoots @Override public void onEnable() { lifecycleManager.loadAndEnable(() -> this.discordSRV = new BukkitDiscordSRV(this)); + + boolean isFolia = false; + try { + Class.forName("io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler"); + isFolia = true; + } catch (ClassNotFoundException ignored) {} + + if (isFolia) { + discordSRV.invokeServerStarted(); + return; + } + + // Run a task on the main thread 1 tick later, so essentially when the server has finished booting getPlugin().getServer().getScheduler().runTaskLater(getPlugin(), () -> discordSRV.invokeServerStarted(), 1L); }