3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 07:10:10 +01:00

[Bleeding] Handle players disconnecting during respawn. Fixes BUKKIT-4327

Prior to this commit, a player disconnected during a respawn event would
remain in memory. This causes a ghosting issue of players in the slot
count and player list, as well as a reference leak.

This commit avoids re-adding the player to the player list (and world) if
they are disconnected. This ensures that the remainder of the respawn
logic is completed as well as ensuring a duplicate player is not left on
the server.

This commit also saves the player's file at the end of the method if they
have been disconnected to ensure that their next login is accurate to the
respawn event's actions. A player that was revived and disconnected will
reconnect as revived.
Dieser Commit ist enthalten in:
turt2live 2014-02-01 20:46:23 -07:00 committet von Wesley Wolfe
Ursprung d7d81fa68f
Commit c59ba98ae6

Datei anzeigen

@ -498,10 +498,14 @@ public abstract class PlayerList {
entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(chunkcoordinates1.x, chunkcoordinates1.y, chunkcoordinates1.z)); entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(chunkcoordinates1.x, chunkcoordinates1.y, chunkcoordinates1.z));
entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel)); entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel));
this.b(entityplayer1, worldserver); this.b(entityplayer1, worldserver);
// CraftBukkit start
// Don't re-add player to player list if disconnected
if (!entityplayer.playerConnection.isDisconnected()) {
worldserver.getPlayerChunkMap().addPlayer(entityplayer1); worldserver.getPlayerChunkMap().addPlayer(entityplayer1);
worldserver.addEntity(entityplayer1); worldserver.addEntity(entityplayer1);
this.players.add(entityplayer1); this.players.add(entityplayer1);
// CraftBukkit start - Added from changeDimension }
// Added from changeDimension
this.updateClient(entityplayer1); // Update health, etc... this.updateClient(entityplayer1); // Update health, etc...
entityplayer1.updateAbilities(); entityplayer1.updateAbilities();
Iterator iterator = entityplayer1.getEffects().iterator(); Iterator iterator = entityplayer1.getEffects().iterator();
@ -515,11 +519,17 @@ public abstract class PlayerList {
// CraftBukkit end // CraftBukkit end
entityplayer1.setHealth(entityplayer1.getHealth()); entityplayer1.setHealth(entityplayer1.getHealth());
// CraftBukkit start - Don't fire on respawn // CraftBukkit start
// Don't fire on respawn
if (fromWorld != location.getWorld()) { if (fromWorld != location.getWorld()) {
PlayerChangedWorldEvent event = new PlayerChangedWorldEvent((Player) entityplayer1.getBukkitEntity(), fromWorld); PlayerChangedWorldEvent event = new PlayerChangedWorldEvent((Player) entityplayer1.getBukkitEntity(), fromWorld);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
} }
// Save player file again if they were disconnected
if (entityplayer.playerConnection.isDisconnected()) {
this.b(entityplayer1);
}
// CraftBukkit end // CraftBukkit end
return entityplayer1; return entityplayer1;