mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-27 10:59:16 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@6bb9dc6b Normalize and trim spaces in Player#performCommand (#12892) PaperMC/Paper@840dd9e1 Fix dialog preconditions (#12895) PaperMC/Paper@9ccc51df Fix legacy pearls forgetting owner on disconnect (#12884) PaperMC/Paper@57c13137 Allow to change despawnInPeaceful (#12880) PaperMC/Paper@a5763618 Add WorldDifficultyChangeEvent (#12471) PaperMC/Paper@dbc367ba Keep non-container slots synced when in container view (#12881)
83 lines
4.9 KiB
Diff
83 lines
4.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: peaches94 <peachescu94@gmail.com>
|
|
Date: Sat, 2 Jul 2022 00:35:56 -0500
|
|
Subject: [PATCH] Multithreaded Tracker
|
|
|
|
Original license: GPL v3
|
|
Original project: https://github.com/Bloom-host/Petal
|
|
|
|
Original license: GPL v3
|
|
Original project: https://github.com/TECHNOVE/Airplane-Experimental
|
|
|
|
Co-authored-by: Paul Sauve <paul@technove.co>
|
|
Co-authored-by: Kevin Raneri <kevin.raneri@gmail.com>
|
|
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
|
Co-authored-by: hayanesuru <hayanesuru@outlook.jp>
|
|
|
|
This patch refactored from original multithreaded tracker (Petal version),
|
|
and is derived from the Airplane fork by Paul Sauve, the tree is like:
|
|
Airplane -> Pufferfish(?) -> Petal -> Leaf
|
|
|
|
The core logic has beed reworked compared to the old one, can handle larger
|
|
scale situation better now.
|
|
Current impl includes many improvements and fixes we made, such as
|
|
plugin compat issues with some NPC plugins using real entity type,
|
|
e.g. Citizens.
|
|
|
|
However we still recommend to use those packet based NPC plugins,
|
|
e.g. ZNPC Plus, Adyeshach, Fancy NPC, etc.
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
index cf1a1eb731083ba56cdb9ad857255b1a55e31717..93b53a2ef33701eb25e78a11235eb7598d88e97d 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -764,7 +764,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
ChunkMap.TrackedEntity entityTracker = world.getChunkSource().chunkMap.entityMap.get(this.getEntityId());
|
|
|
|
if (entityTracker != null) {
|
|
- for (ServerPlayerConnection connection : entityTracker.seenBy) {
|
|
+ for (ServerPlayerConnection connection : entityTracker.seenBy()) { // Leaf - Multithreaded tracker
|
|
players.add(connection.getPlayer().getBukkitEntity());
|
|
}
|
|
}
|
|
@@ -1095,7 +1095,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
return;
|
|
}
|
|
|
|
- for (final ServerPlayerConnection connection : entityTracker.seenBy) {
|
|
+ for (final ServerPlayerConnection connection : entityTracker.seenBy()) { // Leaf - Multithreaded tracker
|
|
this.getHandle().resendPossiblyDesyncedEntityData(connection.getPlayer());
|
|
}
|
|
}
|
|
@@ -1242,7 +1242,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
}
|
|
|
|
Set<org.bukkit.entity.Player> set = new java.util.HashSet<>(tracker.seenBy.size());
|
|
- for (net.minecraft.server.network.ServerPlayerConnection connection : tracker.seenBy) {
|
|
+ for (net.minecraft.server.network.ServerPlayerConnection connection : tracker.seenBy()) { // Leaf - Multithreaded tracker
|
|
set.add(connection.getPlayer().getBukkitEntity().getPlayer());
|
|
}
|
|
return set;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index 980bca611f6095b962f4ae0216458fa5d01c6f68..8da048dd1ad9684ea588a2d67cc8c41fc346099b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -219,7 +219,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa
|
|
private long lastPlayed = 0;
|
|
private boolean hasPlayedBefore = false;
|
|
private final ConversationTracker conversationTracker = new ConversationTracker();
|
|
- private final Map<UUID, Set<WeakReference<Plugin>>> invertedVisibilityEntities = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(); // SparklyPaper - optimize canSee checks
|
|
+ private final Map<UUID, Set<WeakReference<Plugin>>> invertedVisibilityEntities = org.dreeam.leaf.config.modules.async.MultithreadedTracker.enabled ? it.unimi.dsi.fastutil.objects.Object2ObjectMaps.synchronize(new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>()) : new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(); // SparklyPaper - optimize canSee checks // Leaf - Multithreaded tracker
|
|
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;
|
|
@@ -2834,7 +2834,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa
|
|
Iterator<AttributeInstance> iterator = collection.iterator();
|
|
while (iterator.hasNext()) {
|
|
AttributeInstance genericInstance = iterator.next();
|
|
- if (genericInstance.getAttribute() == Attributes.MAX_HEALTH) {
|
|
+ if (genericInstance != null && genericInstance.getAttribute() == Attributes.MAX_HEALTH) { // Leaf - Multithreaded tracker
|
|
iterator.remove();
|
|
break;
|
|
}
|