Files
Purpur/patches/server/0154-Spread-out-and-optimise-player-list-ticks.patch
jmp c7b279fe1b Updated Upstream (Paper & Tuinity)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
05af2837c [CI-SKIP] Improved the annotation test output
586966949 abstract custom set tags, add entity tags
c7667378e Added PlayerLoomPatternSelectEvent
00972e80d Reimplement GS4QueryEvent
544c5c278 Re-add coral block tags (#4987)
7d56c8deb Added PlayerLecternPageChangeEvent
c7cdf255b Add BlockFailedDispenseEvent
c8a8d6fbe Added world settings for mobs picking up loot
91eda5bd3 Added ServerResourcesReloadedEvent
be81b4f5c Add a Enchantable MaterialTag
975d18703 Add doors to material tags
d075e748e colorful itemdump
f3ba3dee0 Added WorldGameRuleChangeEvent
086d20118 Guardian beam workaround
b63c890ec Support spawning item stacks
d7d74c552 added height config for bamboo
7878e3bc2 Use setAmount for Recipe Amount
50e70697b Add EntityLoadCrossbowEvent
f344e092c Add Anti-Xray bypass permission
9fd31e675 fix for nerfed slime mobs splitting
4a7962cd1 Zombie API - breaking doors
5650a41f5 Fix interact event not being called in adventure
2c9ed4335 Add PlayerFlowerPotManipulateEvent
1f32290b6 [Auto] Updated Upstream (CraftBukkit)
d87694a20 Redact Velocity forwarding secret properly (#4980)
24a0b0206 [Auto] Updated Upstream (CraftBukkit)
7681042ef [Auto] Updated Upstream (Bukkit/CraftBukkit)
7dea3dba6 [Auto] Updated Upstream (CraftBukkit)
4b3792920 JavaDoc fixes
f13b4727e Allow disabling mob spawner spawn egg transformation
525b50737 Cache burn durations
2c37d1077 Optimized tick ready check
b4000b01a Add API to get the Material of Boats and Minecarts
f1317386d Fix sign lazy initialisation
9f61759d9 Updated Upstream (CraftBukkit/Spigot) (#4972)
aaff430b6 [CI-SKIP] Use GitHub Actions for build status
9f4055d99 Fix harming potion dupe
7bfb781ff Additional Block Material API's
0eaffd008 Micro Optimize DataBits

Tuinity Changes:
9e5cabb6e Port starlight changes
2021-01-04 15:21:27 -08:00

77 lines
3.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: James Lyne <jim+github@not-null.co.uk>
Date: Mon, 7 Dec 2020 17:52:36 +0000
Subject: [PATCH] Spread out and optimise player list ticks
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 7b385eb43e4cf565d500d0250f3c5e4dbebae986..f055fd0aff86d04677d0bd256c9e7c12f94bfbcc 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -71,7 +71,7 @@ public abstract class PlayerList {
private int viewDistance;
private EnumGamemode u;
private boolean v;
- private int w;
+ private int w; private int getTick() { return this.w; } private int setTick(int i) { return this.w = i; } // Purpur - OBFHELPER
// CraftBukkit start
private CraftServer cserver;
@@ -919,22 +919,23 @@ public abstract class PlayerList {
}
public void tick() {
- if (++this.w > 600) {
- // CraftBukkit start
- for (int i = 0; i < this.players.size(); ++i) {
- final EntityPlayer target = (EntityPlayer) this.players.get(i);
-
- target.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, Iterables.filter(this.players, new Predicate<EntityPlayer>() {
- @Override
- public boolean apply(EntityPlayer input) {
- return target.getBukkitEntity().canSee(input.getBukkitEntity());
- }
- })));
+ // Purpur start
+ int tick = getTick();
+ if (tick < this.players.size()) {
+ final org.bukkit.craftbukkit.entity.CraftPlayer target = this.players.get(tick).getBukkitEntity();
+ final java.util.List<EntityPlayer> list = new java.util.ArrayList<>();
+ for (EntityPlayer entityplayer : this.players) {
+ if (target.canSee(entityplayer.getUniqueID())) {
+ list.add(entityplayer);
+ }
}
- // CraftBukkit end
- this.w = 0;
+ target.getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, list));
}
-
+ if (++tick > 600) {
+ tick = 0;
+ }
+ setTick(tick);
+ // Purpur end
}
public void sendAll(Packet<?> packet) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index e781ae267d4c546261a1dcdfc24d9924eb5044fd..4f42bc21839086b2a40a35910a08d9b11c7649f9 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1382,7 +1382,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public boolean canSee(Player player) {
- return !hiddenPlayers.containsKey(player.getUniqueId());
+ // Purpur start
+ return canSee(player.getUniqueId());
+ }
+
+ public boolean canSee(UUID uuid) {
+ return !hiddenPlayers.containsKey(uuid);
+ // Purpur end
}
@Override