diff --git a/README.md b/README.md index c3a8b5a..31d8988 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,18 @@ In summary, a plugin must be careful of: - One thread reading data while it is being updated by another thread. - Code is to be executed on the chunk's thread, not simply the main thread. +If your plugin already has support for Folia there is a 99% chance it will work with ShreddedPaper without any changes +If you have a sanity check similar to the following +```java + try { + Class.forName("io.papermc.paper.threadedregions.RegionizedServer"); + return true; + } catch (ClassNotFoundException e) { + return false; + } +``` +You should either remove it (because its really not needed) OR add a check for the class `io.multipaper.shreddedpaper.ShreddedPaper` + [See here for a more detailed tutorial](DEVELOPING_A_MULTITHREAD_PLUGIN.md) ### Using the ShreddedPaper API as a dependency diff --git a/patches/api/0002-Add-RegionizedServerInitEvent-for-Folia-support.patch b/patches/api/0002-Add-RegionizedServerInitEvent-for-Folia-support.patch new file mode 100644 index 0000000..68393cb --- /dev/null +++ b/patches/api/0002-Add-RegionizedServerInitEvent-for-Folia-support.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: ProdPreva1l +Date: Wed, 5 Jun 2024 20:44:50 +1000 +Subject: [PATCH] Add RegionizedServerInitEvent for Folia support + + +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 +index 0000000000000000000000000000000000000000..d991df9523676ab7ba90f45ecae3ea9dac5b55d6 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedServerInitEvent.java +@@ -0,0 +1,24 @@ ++package io.papermc.paper.threadedregions; ++ ++import org.bukkit.event.Event; ++import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; ++import org.jetbrains.annotations.NotNull; ++ ++public class RegionizedServerInitEvent extends Event { ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @ApiStatus.Internal ++ public RegionizedServerInitEvent() { ++ super(); ++ } ++ ++ @Override ++ public @NotNull HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ public static @NotNull HandlerList getHandlerList() { ++ return HANDLER_LIST; ++ } ++} +\ No newline at end of file diff --git a/patches/server/0032-Fix-compat-for-Folia-plugins-that-check-for-Folia.patch b/patches/server/0032-Fix-compat-for-Folia-plugins-that-check-for-Folia.patch new file mode 100644 index 0000000..b1467b1 --- /dev/null +++ b/patches/server/0032-Fix-compat-for-Folia-plugins-that-check-for-Folia.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: ProdPreva1l +Date: Wed, 5 Jun 2024 20:27:53 +1000 +Subject: [PATCH] Fix compat for Folia plugins that check for Folia + + +diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java b/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java +new file mode 100644 +index 0000000000000000000000000000000000000000..69db3090c24ab058549cdd8e78ca1beb7be5e7a8 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java +@@ -0,0 +1,7 @@ ++package io.papermc.paper.threadedregions; ++ ++@SuppressWarnings("unused") ++public class RegionizedServer { ++ /* We have nothing here because this is just to fix compat ++ for Folia plugins that have hard coded checks for Folia */ ++} +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index b6d5954ae9fbbcc52d9bd0bfb7b46d78f907b436..ee5eb2967ffd0b5aac88cffc7921b5a8fbade64f 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -16,6 +16,7 @@ import com.mojang.datafixers.DataFixer; + import com.mojang.logging.LogUtils; + import io.multipaper.shreddedpaper.ShreddedPaper; + import io.multipaper.shreddedpaper.threading.ShreddedPaperPlayerTicker; ++import io.papermc.paper.threadedregions.RegionizedServerInitEvent; + import io.papermc.paper.util.TickThread; + import it.unimi.dsi.fastutil.longs.LongIterator; + import it.unimi.dsi.fastutil.objects.ObjectArrayList; +@@ -1160,6 +1161,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop