mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
BedrockEmoteTranslator: ensure sending player is valid for all other sessions (#1194)
This commit is contained in:
parent
8b7165a564
commit
aaa3d7238d
1 changed files with 6 additions and 3 deletions
|
@ -26,7 +26,7 @@
|
||||||
package org.geysermc.connector.network.translators.bedrock.entity.player;
|
package org.geysermc.connector.network.translators.bedrock.entity.player;
|
||||||
|
|
||||||
import com.nukkitx.protocol.bedrock.packet.EmotePacket;
|
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.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
import org.geysermc.connector.network.translators.Translator;
|
import org.geysermc.connector.network.translators.Translator;
|
||||||
|
@ -37,9 +37,12 @@ public class BedrockEmoteTranslator extends PacketTranslator<EmotePacket> {
|
||||||
@Override
|
@Override
|
||||||
public void translate(EmotePacket packet, GeyserSession session) {
|
public void translate(EmotePacket packet, GeyserSession session) {
|
||||||
long javaId = session.getPlayerEntity().getEntityId();
|
long javaId = session.getPlayerEntity().getEntityId();
|
||||||
for (GeyserSession otherSession : GeyserConnector.getInstance().getPlayers()) {
|
for (GeyserSession otherSession : session.getConnector().getPlayers()) {
|
||||||
if (otherSession != session) {
|
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);
|
otherSession.sendUpstreamPacket(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue