9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2026-01-04 15:41:40 +00:00

Apply Purpur Paper patch

This commit is contained in:
Dreeam
2025-04-07 00:48:09 -04:00
parent ab479860ef
commit 9eca4c0c74
43 changed files with 176 additions and 209 deletions

View File

@@ -0,0 +1,82 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kevin Raneri <kevin.raneri@gmail.com>
Date: Wed, 10 Nov 2021 00:37:03 -0500
Subject: [PATCH] Pufferfish: Optimize mob spawning
Original license: GPL v3
Original project: https://github.com/pufferfish-gg/Pufferfish
Co-authored-by: booky10 <boooky10@gmail.com>
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
This patch aims to reduce the main-thread impact of mob spawning by
offloading as much work as possible to other threads. It is possible for
inconsistencies to come up, but when they happen they never interfere
with the server's operation (they don't produce errors), and side
effects are limited to more or less mobs being spawned in any particular
tick.
It is possible to disable this optimization if it is not required or if
it interferes with any plugins. On servers with thousands of entities,
this can result in performance gains of up to 15%, which is significant
and, in my opinion, worth the low risk of minor mob-spawning-related
inconsistencies.
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java b/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
index ece6db7b9a0dfd535141c0c756947c4898140503..82738ad42853e328532d854e3369e6a475ad729d 100644
--- a/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
+++ b/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
@@ -11,7 +11,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
public static final int ITERATOR_FLAG_SEE_ADDITIONS = 1 << 0;
private final Reference2IntLinkedOpenHashMap<E> indexMap;
- private int firstInvalidIndex = -1;
+ private volatile int firstInvalidIndex = -1; // Leaf - Async mob spawning - volatile
/* list impl */
private E[] listElements;
@@ -19,7 +19,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
private final double maxFragFactor;
- private int iteratorCount;
+ private final java.util.concurrent.atomic.AtomicInteger iteratorCount = new java.util.concurrent.atomic.AtomicInteger(); // Pufferfish - async mob spawning
public IteratorSafeOrderedReferenceSet() {
this(Object.class);
@@ -99,7 +99,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
}
public int createRawIterator() {
- ++this.iteratorCount;
+ this.iteratorCount.incrementAndGet(); // Pufferfish - async mob spawning
if (this.indexMap.isEmpty()) {
return Integer.MAX_VALUE;
} else {
@@ -120,7 +120,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
}
public void finishRawIterator() {
- if (--this.iteratorCount == 0) {
+ if (this.iteratorCount.decrementAndGet() == 0) { // Pufferfish - async mob spawning
if (this.getFragFactor() >= this.maxFragFactor) {
this.defrag();
}
@@ -137,7 +137,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
throw new IllegalStateException();
}
this.listElements[index] = null;
- if (this.iteratorCount == 0 && this.getFragFactor() >= this.maxFragFactor) {
+ if (this.iteratorCount.get() == 0 && this.getFragFactor() >= this.maxFragFactor) { // Pufferfish - async mob spawning
this.defrag();
}
//this.check();
@@ -235,7 +235,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
}
public IteratorSafeOrderedReferenceSet.Iterator<E> iterator(final int flags) {
- ++this.iteratorCount;
+ this.iteratorCount.incrementAndGet(); // Pufferfish - async mob spawning
return new BaseIterator<>(this, true, (flags & ITERATOR_FLAG_SEE_ADDITIONS) != 0 ? Integer.MAX_VALUE : this.listSize);
}

File diff suppressed because it is too large Load Diff

View File

@@ -31,10 +31,10 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 63dd549a4560febb44d5b5dd7aed29a1f962403a..0a84d8cbdcd3513a83487a22ba81dc9e0535fc1b 100644
index 3c237f2002e6463efe6bd8ffa2235ce6a6a3e5ec..542c695fe4a0a092233cb478e1ed9c4548409091 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1158,6 +1158,13 @@ public final class CraftServer implements Server {
@@ -1175,6 +1175,13 @@ public final class CraftServer implements Server {
plugin.getPluginMeta().getDisplayName(),
"This plugin is not properly shutting down its async tasks when it is being shut down. This task may throw errors during the final shutdown logs and might not complete before process dies."
));

View File

@@ -13,7 +13,7 @@ As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 0a84d8cbdcd3513a83487a22ba81dc9e0535fc1b..45296a3d27ecd70375ea17c1375d05c70f10f9d2 100644
index 542c695fe4a0a092233cb478e1ed9c4548409091..b3a40db1eb9874392723c5f74546781879ff6c10 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -282,6 +282,7 @@ public final class CraftServer implements Server {
@@ -24,7 +24,7 @@ index 0a84d8cbdcd3513a83487a22ba81dc9e0535fc1b..45296a3d27ecd70375ea17c1375d05c7
private YamlConfiguration configuration;
private YamlConfiguration commandsConfiguration;
private final Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
@@ -1486,6 +1487,7 @@ public final class CraftServer implements Server {
@@ -1503,6 +1504,7 @@ public final class CraftServer implements Server {
this.getLogger().log(Level.SEVERE, null, ex);
}
@@ -32,7 +32,7 @@ index 0a84d8cbdcd3513a83487a22ba81dc9e0535fc1b..45296a3d27ecd70375ea17c1375d05c7
this.worlds.remove(world.getName().toLowerCase(Locale.ROOT));
this.console.removeLevel(handle);
return true;
@@ -1504,12 +1506,7 @@ public final class CraftServer implements Server {
@@ -1521,12 +1523,7 @@ public final class CraftServer implements Server {
@Override
public World getWorld(UUID uid) {
@@ -46,7 +46,7 @@ index 0a84d8cbdcd3513a83487a22ba81dc9e0535fc1b..45296a3d27ecd70375ea17c1375d05c7
}
@Override
@@ -1525,6 +1522,7 @@ public final class CraftServer implements Server {
@@ -1542,6 +1539,7 @@ public final class CraftServer implements Server {
System.out.println("World " + world.getName() + " is a duplicate of another world and has been prevented from loading. Please delete the uid.dat file from " + world.getName() + "'s world directory if you want to be able to load the duplicate world.");
return;
}

View File

@@ -7,10 +7,10 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://galemc.org
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 45296a3d27ecd70375ea17c1375d05c70f10f9d2..e10e540e5a24552167ab066146cbd0eaead6dc9e 100644
index b3a40db1eb9874392723c5f74546781879ff6c10..9a92d8e7593de84458a22d72819bfbb3ff1bad9a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2994,6 +2994,23 @@ public final class CraftServer implements Server {
@@ -3077,6 +3077,23 @@ public final class CraftServer implements Server {
};
}

View File

@@ -58,10 +58,10 @@ index 12b327eea95e0de9e9c39b7d039badee8ec46508..6178f0212214a2a075cea60c758dca79
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index e10e540e5a24552167ab066146cbd0eaead6dc9e..aa7bc955f53cea93d9409653ad1263c3c0a0888d 100644
index 9a92d8e7593de84458a22d72819bfbb3ff1bad9a..b34138df70d548756b9fbf876b205bf2434cc6b2 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2994,7 +2994,26 @@ public final class CraftServer implements Server {
@@ -3077,7 +3077,26 @@ public final class CraftServer implements Server {
};
}

View File

@@ -23,13 +23,13 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index aa7bc955f53cea93d9409653ad1263c3c0a0888d..704b5fd8c10cdc5363f59fbd878d9453926d91c3 100644
index b34138df70d548756b9fbf876b205bf2434cc6b2..a1966546aaf211afae09c2c270439c4f94621419 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -3231,4 +3231,21 @@ public final class CraftServer implements Server {
public void allowPausing(final Plugin plugin, final boolean value) {
this.console.addPluginAllowingSleep(plugin.getName(), value);
@@ -3328,4 +3328,21 @@ public final class CraftServer implements Server {
return getServer().lagging;
}
// Purpur end - Lagging threshold
+
+ // Gale start - YAPFA - last tick time - API
+ @Override

View File

@@ -7,13 +7,13 @@ Original license: MIT
Original project: https://github.com/KeYiMC/KeYi
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index e1f26ff10f83ea28b09dfba5b02caea182a8f445..d81979c51c81ba08cfb3a401b3f7fde84f492065 100644
index a5cf4e4b9cc35bd81b530bc3eac31b0af3d72b7c..1e79f854abcf62f221a56657997ad1c3745ef8f1 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -3593,4 +3593,31 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void setSimplifyContainerDesyncCheck(final boolean simplifyContainerDesyncCheck) {
this.simplifyContainerDesyncCheck = simplifyContainerDesyncCheck;
@@ -3694,4 +3694,31 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundPlayerCombatKillPacket(getEntityId(), io.papermc.paper.adventure.PaperAdventure.asVanilla(message)));
}
// Purpur end - Death screen API
+
+ // Leaf start - KeYi - Player Skull API
+ @Override

View File

@@ -9,10 +9,10 @@ Original project: https://github.com/Cryptite/Slice
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index d81979c51c81ba08cfb3a401b3f7fde84f492065..905cea7470f7bb8dee27bbfc4d267d46c28fe21b 100644
index 1e79f854abcf62f221a56657997ad1c3745ef8f1..834d845986d1baa7cf1c4275e39aaef8efa2db8e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1361,6 +1361,25 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -1366,6 +1366,25 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Paper end - Teleportation API
}

View File

@@ -88,7 +88,7 @@ index c03608fec96b51e1867f43d8f42e5aefb1520e46..56268cf8d184e0b6cd46de8c2e893ad3
+ // Leaf end - SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 5aa8eab78e99408b0beb64d7ed07ff1bc61541db..0809ed41274be3dd18eb89aa96c442bc3995f1b7 100644
index 83a23a82335eac087d36fd27ca6c6417960b881f..5a707acb7cda4097f822e3dcb17bdf26ca5c9f59 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -80,7 +80,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -107,4 +107,4 @@ index 5aa8eab78e99408b0beb64d7ed07ff1bc61541db..0809ed41274be3dd18eb89aa96c442bc
+ this.taskScheduler = new io.papermc.paper.threadedregions.EntityScheduler(this.entity.getServer(), this); // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run
}
public static <T extends Entity> CraftEntity getEntity(CraftServer server, T entity) {
// Purpur start - Fire Immunity API

View File

@@ -16,7 +16,7 @@ This seems stupid, but it does seem that it improves the performance a bit, and
We also create a "canSee" method tailored for "ChunkMap#updatePlayer()", a method without the equals check (the "updatePlayer()" already checks if the entity is the same entity) because the CraftPlayer's `equals()` check is a *bit* expensive compared to only checking the object's identity, and because the identity has already been check, we don't need to check it twice.
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 905cea7470f7bb8dee27bbfc4d267d46c28fe21b..ff0ef4e148c85aff18094a139705de5034d99e20 100644
index 834d845986d1baa7cf1c4275e39aaef8efa2db8e..b05b651dbb14602bd58073e64b7d10d55be0d645 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -212,7 +212,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -28,7 +28,7 @@ index 905cea7470f7bb8dee27bbfc4d267d46c28fe21b..ff0ef4e148c85aff18094a139705de50
private final Set<UUID> unlistedEntities = new HashSet<>(); // Paper - Add Listing API for Player
private static final WeakHashMap<Plugin, WeakReference<Plugin>> pluginWeakReferences = new WeakHashMap<>();
private int hash = 0;
@@ -2266,9 +2266,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -2273,9 +2273,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public boolean canSee(org.bukkit.entity.Entity entity) {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Including 5s in getTPS()
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 704b5fd8c10cdc5363f59fbd878d9453926d91c3..540c84579ef57ec73bc5250ff889139ddcdf296b 100644
index a1966546aaf211afae09c2c270439c4f94621419..5e80332c995177ba360ab829ca9b3cfc642fe32b 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2987,6 +2987,8 @@ public final class CraftServer implements Server {
@@ -3070,6 +3070,8 @@ public final class CraftServer implements Server {
@Override
public double[] getTPS() {

View File

@@ -14,7 +14,7 @@ Co-authored-by: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
index c855f1f6f70000b03594ce50553147d9821b796b..91f680bb9905319d9ce2b3fe2746bdb8e968aba9 100644
index 400e632208d133a3f49fc7f14bceb48a1026769b..8c4e5b0c81d90a0eeee4ab9e5882b1372a628954 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
@@ -196,7 +196,14 @@ public class CraftChunk implements Chunk {
@@ -34,10 +34,10 @@ index c855f1f6f70000b03594ce50553147d9821b796b..91f680bb9905319d9ce2b3fe2746bdb8
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 540c84579ef57ec73bc5250ff889139ddcdf296b..1c3382da80fa3e08b130d48c135c4100580b70f6 100644
index 5e80332c995177ba360ab829ca9b3cfc642fe32b..84752038245c15e60cc5d8280b8cc37259ca3e3e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1354,7 +1354,11 @@ public final class CraftServer implements Server {
@@ -1371,7 +1371,11 @@ public final class CraftServer implements Server {
registryAccess = levelDataAndDimensions.dimensions().dimensionsRegistryAccess();
} else {
LevelSettings levelSettings;

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Replace world map with optimized collection
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 1c3382da80fa3e08b130d48c135c4100580b70f6..ffdea8befa77ec655b1df929715fcbdc60d6a966 100644
index 84752038245c15e60cc5d8280b8cc37259ca3e3e..ce866cecc1012f91577ee4dd90957d905c7134d6 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -281,7 +281,7 @@ public final class CraftServer implements Server {

View File

@@ -41,10 +41,10 @@ index db031298c2090eb36032de4b52335c62186e4cfb..84905d7802f8a5c3f68e15f1b17ef082
}
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 083cc48abea81560b34c30653e766d650a2d3850..7d22c1ee7fa98fc2d04d353fe19387ca3334f52a 100644
index f32316b0357f1cb0501a052361a0221f8e9d1438..ebb07b9b9f6bef9195978c8ecdd5f4ef3ee198bc 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1741,6 +1741,26 @@ public class CraftEventFactory {
@@ -1751,6 +1751,26 @@ public class CraftEventFactory {
}
public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags, @Nullable Entity entity, boolean checkSetResult) {

View File

@@ -8,10 +8,10 @@ replacing ArrayList with Fastutil ObjectArrayList
brings about 40% performance improvement in benchmark.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index ffdea8befa77ec655b1df929715fcbdc60d6a966..028a30ae3c9dd411e70b1bc8ac42067c06d0335f 100644
index ce866cecc1012f91577ee4dd90957d905c7134d6..4310e92720fce2d792c610156be610c281c3ab2b 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -954,7 +954,7 @@ public final class CraftServer implements Server {
@@ -968,7 +968,7 @@ public final class CraftServer implements Server {
@Override
public List<World> getWorlds() {

View File

@@ -9,7 +9,7 @@ Added some asynchronous structure locate methods in World,
requires async-locator to be enabled in Leaf config, or else it will fall back to sync methods.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index a76797c08cb5912d0525fa21217d45b61b110259..2538a0de7fd6b1026fff51e5d066c5b0811b7cda 100644
index a4a0b07c9e3e716d77bc6e11dca096e142a5190e..6bcece7ceb5be047371faf7ab85b3688ed3e045b 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2272,6 +2272,45 @@ public class CraftWorld extends CraftRegionAccessor implements World {

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] PlayerInventoryOverflowEvent
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
index f850e6cea92edc87ed54cf54488b5ebb606913ed..b5af3cc6865408ffef40f4868970cff947834afc 100644
index 19180c08f41db939c1a9f0caeb62e5beb1117f69..59ab5bd3582cdae351d579719244c4ad28878a00 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
@@ -340,6 +340,15 @@ public class CraftInventory implements Inventory {

View File

@@ -263,7 +263,7 @@ index 196fddeab452e7bc89ef6758635e1d07074e7416..55a2ffa0fff6ef66b9bd5069300c09e9
} else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
// Leaf start - Multithreaded tracker
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 9e09f14033818fcf9df161941e316c16d913705b..8d68b49ff0b1c4c829d97cd8ebe81be79ee856f6 100644
index 6bcece7ceb5be047371faf7ab85b3688ed3e045b..96faa72abe918e7ab3f1dec44072a5fee27b6476 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -456,7 +456,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -609,10 +609,10 @@ index 321280d7c9c3c828cbf2eb19d2fd196a1f84d4c3..cd8f771e08cee5d00c53a8e70f0fe37c
}
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 5a1b37a408ebede6367ca90ad5d13c29b7b1a6b3..7042d684bc345925f1755fec2b463b487db71cc5 100644
index ebb07b9b9f6bef9195978c8ecdd5f4ef3ee198bc..3848011363056d700110564c6af8e4c3bd54ac6c 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -809,6 +809,28 @@ public class CraftEventFactory {
@@ -818,6 +818,28 @@ public class CraftEventFactory {
}
public static BlockPos sourceBlockOverride = null; // SPIGOT-7068: Add source block override, not the most elegant way but better than passing down a BlockPos up to five methods deep.
@@ -641,7 +641,7 @@ index 5a1b37a408ebede6367ca90ad5d13c29b7b1a6b3..7042d684bc345925f1755fec2b463b48
public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState state, int flags) {
return handleBlockSpreadEvent(world, source, target, state, flags, false);
@@ -824,7 +846,10 @@ public class CraftEventFactory {
@@ -833,7 +855,10 @@ public class CraftEventFactory {
CraftBlockState snapshot = CraftBlockStates.getBlockState(world, target);
snapshot.setData(state);

View File

@@ -31,7 +31,7 @@ vain. Throttling spawn attempts in suspected spawnproof chunks improves
performance without noticeably advantaging or disadvantaging the mob farm.
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
index 9511f978f6c7da506f67928f5a5a92ecf28e5930..6c298304f842612d0e063b578f274eed04b32960 100644
index 65f6839fe75340a4b58894ad50c6eda7b59128c0..f7610c709bd6f9e30ec7b1295d58dfbe98fc8661 100644
--- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
@@ -182,6 +182,17 @@ public class WorldConfiguration extends ConfigurationPart {

View File

@@ -0,0 +1,50 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: hayanesuru <mc@jvavav.com>
Date: Fri, 28 Mar 2025 21:19:19 +0800
Subject: [PATCH] Async playerdata saving
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
index 1456f2d1a92c8315177fb03d0c7ec943d5f5b097..e70692272aae39ea01fb6860ec4cb703ea531781 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
@@ -199,7 +199,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
}
private CompoundTag getData() {
- return this.storage.load(this.profile.getName(), this.profile.getId().toString()).orElse(null);
+ return this.storage.load(this.profile.getName(), this.profile.getId().toString(), this.profile.getId()).orElse(null); // Leaf - Async playerdata saving
}
private CompoundTag getBukkitData() {
@@ -744,6 +744,17 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
* @param compoundTag
*/
private void save(CompoundTag compoundTag) {
+ // Leaf start - Async playerdata saving
+ synchronized (server.console.playerDataStorage) {
+ while (server.console.playerDataStorage.savingQueue.contains(getUniqueId())) {
+ try {
+ Thread.sleep(1L);
+ } catch (InterruptedException ignored) {
+ }
+ }
+ server.console.playerDataStorage.savingQueue.add(getUniqueId());
+ }
+ // Leaf end - Async playerdata saving
File playerDir = server.console.playerDataStorage.getPlayerDir();
try {
File tempFile = File.createTempFile(this.getUniqueId()+"-", ".dat", playerDir);
@@ -753,6 +764,12 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
net.minecraft.Util.safeReplaceFile(playerDataFile.toPath(), tempFile.toPath(), playerDataFileOld.toPath());
} catch (java.io.IOException e) {
e.printStackTrace();
+ // Leaf start - Async playerdata saving
+ } finally {
+ synchronized (server.console.playerDataStorage) {
+ server.console.playerDataStorage.savingQueue.remove(getUniqueId());
+ }
+ // Leaf end - Async playerdata saving
}
}
// Purpur end - OfflinePlayer API