From aaa3d7238defb95b7d1a11f3d181dc4c1e62ccc0 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+DoctorMacc@users.noreply.github.com> Date: Mon, 24 Aug 2020 10:26:37 -0400 Subject: [PATCH] BedrockEmoteTranslator: ensure sending player is valid for all other sessions (#1194) --- .../bedrock/entity/player/BedrockEmoteTranslator.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/entity/player/BedrockEmoteTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/entity/player/BedrockEmoteTranslator.java index e76fece0b..813c5594c 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/entity/player/BedrockEmoteTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/entity/player/BedrockEmoteTranslator.java @@ -26,7 +26,7 @@ package org.geysermc.connector.network.translators.bedrock.entity.player; import com.nukkitx.protocol.bedrock.packet.EmotePacket; -import org.geysermc.connector.GeyserConnector; +import org.geysermc.connector.entity.Entity; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.Translator; @@ -37,9 +37,12 @@ public class BedrockEmoteTranslator extends PacketTranslator { @Override public void translate(EmotePacket packet, GeyserSession session) { long javaId = session.getPlayerEntity().getEntityId(); - for (GeyserSession otherSession : GeyserConnector.getInstance().getPlayers()) { + for (GeyserSession otherSession : session.getConnector().getPlayers()) { if (otherSession != session) { - packet.setRuntimeEntityId(otherSession.getEntityCache().getEntityByJavaId(javaId).getGeyserId()); + if (otherSession.isClosed()) continue; + Entity otherEntity = otherSession.getEntityCache().getEntityByJavaId(javaId); + if (otherEntity == null) continue; + packet.setRuntimeEntityId(otherEntity.getGeyserId()); otherSession.sendUpstreamPacket(packet); } }