mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-20 09:57:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: eb11845f8 Fix creating worlds with "invalid" names (Fixes #5331) e4d8a6279 Implement Keyed on World bcb63dab7 [CI-SKIP] [Auto] Rebuild Patches 48342b06c Allow signs that are inside of the spawn protection to be right clicked to use their run_command tag c229f90c1 Add Block#isValidTool 20e709c1d Add recipe to cook events 2dcf8bff4 legacy formatting will be the death of me f597fea0d legacy formatting is worse than walking around in wet socks 7f72c4675 Use implementation-provided legacy serializer for events 27a8d99ec Adventure 4.7.0 e65bd35a1 Respect teams in legacy chat name if configured (#5321) b31089a92 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5325) a52b30814 Fix title swapping fadeIn and stay 54ec85949 Prevent grindstones from overstacking items d7795080c Fix NPE for AIR in meta operations in ItemStack 2e70796c7 [CI-SKIP] Improve documentation of PreCreatureSpawnEvent (#5244) 7bb92e750 [CI-SKIP] Add JavaDoc links to Tag class pointing to custom Paper tags (#5285) 28cd686bf fix per-world difficulty command (#5306) be7cde2c7 [CI-SKIP] Always check PATH for JDK (#5315)
77 lines
3.2 KiB
Diff
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 86f534c871a3c9b9ca71b20daa7780dfdab9e76d..d454b6c61c1a7d0ae9d6c2979cb865531acf405f 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
|
@@ -68,7 +68,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;
|
|
@@ -928,22 +928,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 ca15efea5da7be1717a211b9b3556c755788561a..400e26c96f00e9f8895a45e70f22552ec17f2436 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -1435,7 +1435,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
|