Skip to content

Commit

Permalink
BedrockEmoteTranslator: ensure sending player is valid for all other …
Browse files Browse the repository at this point in the history
…sessions (GeyserMC#1194)
  • Loading branch information
Camotoy authored Aug 24, 2020
1 parent 8b7165a commit aaa3d72
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,9 +37,12 @@ public class BedrockEmoteTranslator extends PacketTranslator<EmotePacket> {
@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);
}
}
Expand Down

0 comments on commit aaa3d72

Please sign in to comment.