Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 03:20:07 +01:00
de04cbced5
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: f29cb801 Separate checkstyle-suppressions file is not required 86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack 9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode() 994a6163 Attempt upgrade of resolver libraries CraftBukkit Changes: b3b43a6ad Add Checkstyle check for unused imports 13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names 3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API 2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor 1dbdbbed4 PR-1238: Remove unnecessary sign ticking 659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper e37e29ce0 Increase outdated build delay c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack 492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode() e11fbb9d7 Upgrade MySQL driver 9f3a0bd2a Attempt upgrade of resolver libraries 60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion Spigot Changes: 06d602e7 Rebuild patches
114 Zeilen
6.1 KiB
Diff
114 Zeilen
6.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sun, 19 Apr 2020 00:05:46 -0400
|
|
Subject: [PATCH] Fix Longstanding Broken behavior of PlayerJoinEvent
|
|
|
|
For years, plugin developers have had to delay many things they do
|
|
inside of the PlayerJoinEvent by 1 tick to make it actually work.
|
|
|
|
This all boiled down to 1 reason why: The event fired before the
|
|
player was fully ready and joined to the world!
|
|
|
|
Additionally, if that player logged out on a vehicle, the event
|
|
fired before the vehicle was even loaded, so that plugins had no
|
|
access to the vehicle during this event either.
|
|
|
|
This change finally fixes this issue, fully preparing the player
|
|
into the world as a fully ready entity, vehicle included.
|
|
|
|
There should be no plugins that break because of this change, but might
|
|
improve consistency with other plugins instead.
|
|
|
|
For example, if 2 plugins listens to this event, and the first one
|
|
teleported the player in the event, then the 2nd plugin actually
|
|
would be getting a valid player!
|
|
|
|
This was very non deterministic. This change will ensure every plugin
|
|
receives a deterministic result, and should no longer require 1 tick
|
|
delays anymore.
|
|
|
|
== AT ==
|
|
public net.minecraft.server.level.ChunkMap addEntity(Lnet/minecraft/world/entity/Entity;)V
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
index 0e3c89b9d75160d0e8947d042a1568da13d62fcf..8d12a6da0f0679fd14c2a498f9645bd04b2d8ed7 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
@@ -1000,6 +1000,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
+ ": " + entity + (this.entityMap.containsKey(entity.getId()) ? " ALREADY CONTAINED (This would have crashed your server)" : ""), new Throwable());
|
|
return;
|
|
}
|
|
+ if (entity instanceof ServerPlayer && ((ServerPlayer) entity).supressTrackerForLogin) return; // Delay adding to tracker until after list packets
|
|
// Paper end
|
|
if (!(entity instanceof EnderDragonPart)) {
|
|
EntityType<?> entitytypes = entity.getType();
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index 352fbab070ccdb683e9a7558292c86cc443c018b..b2e980c1f2e2ec417f75fbd7bdd2188fdb4eba23 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -271,6 +271,7 @@ public class ServerPlayer extends Player {
|
|
public double maxHealthCache;
|
|
public boolean joining = true;
|
|
public boolean sentListPacket = false;
|
|
+ public boolean supressTrackerForLogin = false; // Paper
|
|
public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent
|
|
// CraftBukkit end
|
|
public boolean isRealPlayer; // Paper
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index f644c8b89e96d35fb9f2ac7941dcfcf9e8b66451..3986d49b0e3405248913a685c44b27d091c4152e 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -295,6 +295,12 @@ public abstract class PlayerList {
|
|
this.playersByUUID.put(player.getUUID(), player);
|
|
// this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer))); // CraftBukkit - replaced with loop below
|
|
|
|
+ // Paper start - correctly register player BEFORE PlayerJoinEvent, so the entity is valid and doesn't require tick delay hacks
|
|
+ player.supressTrackerForLogin = true;
|
|
+ worldserver1.addNewPlayer(player);
|
|
+ this.server.getCustomBossEvents().onPlayerConnect(player); // see commented out section below worldserver.addPlayerJoin(entityplayer);
|
|
+ mountSavedVehicle(player, worldserver1, nbttagcompound);
|
|
+ // Paper end
|
|
// CraftBukkit start
|
|
CraftPlayer bukkitPlayer = player.getBukkitEntity();
|
|
|
|
@@ -333,6 +339,8 @@ public abstract class PlayerList {
|
|
player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer1)));
|
|
}
|
|
player.sentListPacket = true;
|
|
+ player.supressTrackerForLogin = false; // Paper
|
|
+ ((ServerLevel)player.level()).getChunkSource().chunkMap.addEntity(player); // Paper - track entity now
|
|
// CraftBukkit end
|
|
|
|
player.getEntityData().refresh(player); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn
|
|
@@ -355,6 +363,11 @@ public abstract class PlayerList {
|
|
playerconnection.send(new ClientboundUpdateMobEffectPacket(player.getId(), mobeffect));
|
|
}
|
|
|
|
+ // Paper start - move vehicle into method so it can be called above - short circuit around that code
|
|
+ onPlayerJoinFinish(player, worldserver1, s1);
|
|
+ }
|
|
+ private void mountSavedVehicle(ServerPlayer player, ServerLevel worldserver1, CompoundTag nbttagcompound) {
|
|
+ // Paper end
|
|
if (nbttagcompound != null && nbttagcompound.contains("RootVehicle", 10)) {
|
|
CompoundTag nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
|
|
// CraftBukkit start
|
|
@@ -403,6 +416,10 @@ public abstract class PlayerList {
|
|
}
|
|
}
|
|
|
|
+ // Paper start
|
|
+ }
|
|
+ public void onPlayerJoinFinish(ServerPlayer player, ServerLevel worldserver1, String s1) {
|
|
+ // Paper end
|
|
player.initInventoryMenu();
|
|
// CraftBukkit - Moved from above, added world
|
|
// Paper start - Add to collideRule team if needed
|
|
@@ -412,6 +429,7 @@ public abstract class PlayerList {
|
|
scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam);
|
|
}
|
|
// Paper end
|
|
+ // CraftBukkit - Moved from above, added world
|
|
PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ());
|
|
}
|
|
|