From 208e503d267fb308577ae3ac951e6446ab832740 Mon Sep 17 00:00:00 2001 From: Rothes <449181985@qq.com> Date: Thu, 19 Mar 2026 10:13:21 +0800 Subject: [PATCH 1/2] Fix vanish api sync error --- .../0009-Fix-vanish-api-sync-error.patch | 18 +++++++++ .../0008-Fix-vanish-api-sync-error.patch | 38 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 folia-server/minecraft-patches/features/0009-Fix-vanish-api-sync-error.patch create mode 100644 folia-server/paper-patches/features/0008-Fix-vanish-api-sync-error.patch diff --git a/folia-server/minecraft-patches/features/0009-Fix-vanish-api-sync-error.patch b/folia-server/minecraft-patches/features/0009-Fix-vanish-api-sync-error.patch new file mode 100644 index 0000000000..e8df4d7e9f --- /dev/null +++ b/folia-server/minecraft-patches/features/0009-Fix-vanish-api-sync-error.patch @@ -0,0 +1,18 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Rothes <449181985@qq.com> +Date: Thu, 19 Mar 2026 10:12:55 +0800 +Subject: [PATCH] Fix vanish api sync error + + +diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java b/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java +index d94c0d15f62b67378669d4ce7252d99b8f743fa5..1574ead80189fbd4e4f6d677992f3ea5671bf844 100644 +--- a/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java ++++ b/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java +@@ -307,6 +307,7 @@ public final class RegionizedPlayerChunkLoader { + TickThread.ensureTickThread("Cannot tick player chunk loader async"); + long currTime = System.nanoTime(); + for (final ServerPlayer player : new java.util.ArrayList<>(this.world.getLocalPlayers())) { // Folia - region threding ++ player.getBukkitEntity().onTick(); // Folia - Fix vanish api sync error + final PlayerChunkLoaderData loader = ((ChunkSystemServerPlayer)player).moonrise$getChunkLoader(); + if (loader == null || loader.removed || loader.world != this.world) { + // not our problem anymore diff --git a/folia-server/paper-patches/features/0008-Fix-vanish-api-sync-error.patch b/folia-server/paper-patches/features/0008-Fix-vanish-api-sync-error.patch new file mode 100644 index 0000000000..7760753c43 --- /dev/null +++ b/folia-server/paper-patches/features/0008-Fix-vanish-api-sync-error.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Rothes <449181985@qq.com> +Date: Thu, 19 Mar 2026 10:12:55 +0800 +Subject: [PATCH] Fix vanish api sync error + + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index 0d26a26d15de61031c6277e1671a3992dbf52f2d..0099c2caff180df81604ea5091afe4bd851a5733 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -248,6 +248,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa + private long lastSaveTime; // Paper - getLastPlayed replacement API + private @Nullable CraftScoreboard scoreboardOverride; + public final net.minecraft.network.PacketProcessor packetProcessor = new net.minecraft.network.PacketProcessor(null); // Folia ++ private final java.util.concurrent.ConcurrentLinkedDeque removedEntities = new java.util.concurrent.ConcurrentLinkedDeque<>(); // Folia - Fix vanish api sync error + + // Folia start - region threading + // used only to notify tasks for packets +@@ -2086,9 +2087,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa + // Paper end + + public void onEntityRemove(Entity entity) { +- this.invertedVisibilityEntities.remove(entity.getUUID()); ++ // Folia start - Fix vanish api sync error ++ if (this.invertedVisibilityEntities.isEmpty()) return; // Nothing hidden ++ this.removedEntities.add(entity.getUUID()); + } + ++ public void onTick() { ++ for (int i = 0; i < this.removedEntities.size(); i++) { ++ this.invertedVisibilityEntities.remove(this.removedEntities.removeFirst()); ++ } ++ } ++ // Folia end - Fix vanish api sync error ++ + @Override + public boolean canSee(Player player) { + return this.canSee((org.bukkit.entity.Entity) player); From ff2e08d7a5f8b2488ce6034d9b22cf49b07249db Mon Sep 17 00:00:00 2001 From: Rothes <449181985@qq.com> Date: Sat, 25 Apr 2026 23:18:12 +0800 Subject: [PATCH 2/2] Improve drain loop --- .../features/0008-Fix-vanish-api-sync-error.patch | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/folia-server/paper-patches/features/0008-Fix-vanish-api-sync-error.patch b/folia-server/paper-patches/features/0008-Fix-vanish-api-sync-error.patch index 7760753c43..214e2a32a9 100644 --- a/folia-server/paper-patches/features/0008-Fix-vanish-api-sync-error.patch +++ b/folia-server/paper-patches/features/0008-Fix-vanish-api-sync-error.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix vanish api sync error diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 0d26a26d15de61031c6277e1671a3992dbf52f2d..0099c2caff180df81604ea5091afe4bd851a5733 100644 +index 0d26a26d15de61031c6277e1671a3992dbf52f2d..df1618d425fd0906d702c2c3b11cfd3b40d1e1cf 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -248,6 +248,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa @@ -16,7 +16,7 @@ index 0d26a26d15de61031c6277e1671a3992dbf52f2d..0099c2caff180df81604ea5091afe4bd // Folia start - region threading // used only to notify tasks for packets -@@ -2086,9 +2087,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa +@@ -2086,9 +2087,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa // Paper end public void onEntityRemove(Entity entity) { @@ -27,8 +27,9 @@ index 0d26a26d15de61031c6277e1671a3992dbf52f2d..0099c2caff180df81604ea5091afe4bd } + public void onTick() { -+ for (int i = 0; i < this.removedEntities.size(); i++) { -+ this.invertedVisibilityEntities.remove(this.removedEntities.removeFirst()); ++ java.util.UUID item; ++ while ((item = this.removedEntities.poll()) != null) { ++ this.invertedVisibilityEntities.remove(item); + } + } + // Folia end - Fix vanish api sync error