mirror of
https://github.com/PaperMC/Folia.git
synced 2025-04-19 02:29:21 +08:00
72 lines
3.3 KiB
Diff
72 lines
3.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Thu, 20 Mar 2025 11:01:42 -0700
|
|
Subject: [PATCH] fixup! Region Threading Base
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index ae7ee8c67a71b0bc319d8079094b1806fc3e305a..1a1d44c2aa89d8c7f9ec431b5b04d4c6e93a9d55 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -3120,7 +3120,7 @@ public final class CraftServer implements Server {
|
|
@Override
|
|
public double[] getTPS() {
|
|
// Folia start - region threading
|
|
- ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool.SchedulableTick task = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentTickingTask();
|
|
+ io.papermc.paper.threadedregions.ScheduledTaskThreadPool.SchedulableTick task = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentTickingTask();
|
|
if (task == null) {
|
|
// might be on the shutdown thread, try retrieving the current region
|
|
if (io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion() != null) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index ac878520dc4aaa0e6a1ce8de0982d60a8397bc15..512ef437119041b33b62ef4675bdd1b27fd9a403 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -224,6 +224,47 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
private boolean simplifyContainerDesyncCheck = GlobalConfiguration.get().unsupportedSettings.simplifyRemoteItemMatching;
|
|
private long lastSaveTime; // Paper - getLastPlayed replacement API
|
|
|
|
+ // Folia start - region threading
|
|
+ private final ca.spottedleaf.concurrentutil.collection.MultiThreadedQueue<Runnable> packetQueue = new ca.spottedleaf.concurrentutil.collection.MultiThreadedQueue<>();
|
|
+ // used only to notify tasks for packets
|
|
+ private volatile io.papermc.paper.threadedregions.RegionizedWorldData lastRegion;
|
|
+
|
|
+ public void stopAcceptingPackets() {
|
|
+ this.packetQueue.preventAdds();
|
|
+ }
|
|
+
|
|
+ public void updateRegion(final io.papermc.paper.threadedregions.RegionizedWorldData region) {
|
|
+ this.lastRegion = region;
|
|
+ if (region != null && this.hasPackets()) {
|
|
+ region.regionData.setHasPackets();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public boolean hasPackets() {
|
|
+ return !this.packetQueue.isEmpty();
|
|
+ }
|
|
+
|
|
+ public boolean executeOnePacket() {
|
|
+ final Runnable run = this.packetQueue.poll();
|
|
+ if (run != null) {
|
|
+ run.run();
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ public void addPacket(final Runnable runnable) {
|
|
+ if (!this.packetQueue.add(runnable)) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ final io.papermc.paper.threadedregions.RegionizedWorldData region = this.lastRegion;
|
|
+ if (region != null) {
|
|
+ region.regionData.setHasPackets();
|
|
+ }
|
|
+ }
|
|
+ // Folia end - region threading
|
|
+
|
|
public CraftPlayer(CraftServer server, ServerPlayer entity) {
|
|
super(server, entity);
|
|
|