forked from GeyserMC/Geyser
Fix inconsistencies with players and the player list (#1298)
* Fix inconsistencies with players and the player list This commit makes the player list entry packet control the player cache, fixing inconsistencies that appeared when removing the override on despawning the player. * Update comments
This commit is contained in:
parent
f9c1d3f218
commit
3c1d4aae93
3 changed files with 6 additions and 14 deletions
|
@ -118,7 +118,7 @@ public class PlayerEntity extends LivingEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPlayer(GeyserSession session) {
|
public void sendPlayer(GeyserSession session) {
|
||||||
if(session.getEntityCache().getPlayerEntity(uuid) == null)
|
if (session.getEntityCache().getPlayerEntity(uuid) == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (session.getUpstream().isInitialized() && session.getEntityCache().getEntityByGeyserId(geyserId) == null) {
|
if (session.getUpstream().isInitialized() && session.getEntityCache().getEntityByGeyserId(geyserId) == null) {
|
||||||
|
|
|
@ -76,9 +76,6 @@ public class EntityCache {
|
||||||
if (entity != null && entity.isValid() && (force || entity.despawnEntity(session))) {
|
if (entity != null && entity.isValid() && (force || entity.despawnEntity(session))) {
|
||||||
long geyserId = entityIdTranslations.remove(entity.getEntityId());
|
long geyserId = entityIdTranslations.remove(entity.getEntityId());
|
||||||
entities.remove(geyserId);
|
entities.remove(geyserId);
|
||||||
if (entity.is(PlayerEntity.class)) {
|
|
||||||
playerEntities.remove(entity.as(PlayerEntity.class).getUuid());
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -88,18 +88,13 @@ public class JavaPlayerListEntryTranslator extends PacketTranslator<ServerPlayer
|
||||||
break;
|
break;
|
||||||
case REMOVE_PLAYER:
|
case REMOVE_PLAYER:
|
||||||
PlayerEntity entity = session.getEntityCache().getPlayerEntity(entry.getProfile().getId());
|
PlayerEntity entity = session.getEntityCache().getPlayerEntity(entry.getProfile().getId());
|
||||||
if (entity != null && entity.isValid()) {
|
if (entity != null) {
|
||||||
// remove from tablist but player entity is still there
|
// Just remove the entity's player list status
|
||||||
|
// Don't despawn the entity - the Java server will also take care of that.
|
||||||
entity.setPlayerList(false);
|
entity.setPlayerList(false);
|
||||||
} else {
|
|
||||||
if (entity == null) {
|
|
||||||
// just remove it from caching
|
|
||||||
session.getEntityCache().removePlayerEntity(entry.getProfile().getId());
|
|
||||||
} else {
|
|
||||||
entity.setPlayerList(false);
|
|
||||||
session.getEntityCache().removeEntity(entity, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// As the player entity is no longer present, we can remove the entry
|
||||||
|
session.getEntityCache().removePlayerEntity(entry.getProfile().getId());
|
||||||
if (entity == session.getPlayerEntity()) {
|
if (entity == session.getPlayerEntity()) {
|
||||||
// If removing ourself we use our AuthData UUID
|
// If removing ourself we use our AuthData UUID
|
||||||
translate.getEntries().add(new PlayerListPacket.Entry(session.getAuthData().getUUID()));
|
translate.getEntries().add(new PlayerListPacket.Entry(session.getAuthData().getUUID()));
|
||||||
|
|
Loading…
Reference in a new issue