Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign xuid for users to chat messages #2100

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
import com.nukkitx.protocol.bedrock.packet.TextPacket;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator;
Expand All @@ -40,7 +41,19 @@ public void translate(ServerChatPacket packet, GeyserSession session) {
TextPacket textPacket = new TextPacket();
textPacket.setPlatformChatId("");
textPacket.setSourceName("");
textPacket.setXuid(session.getAuthData().getXboxUUID());

// This attempts to find the XUID of the player so users can be muted/blocked
String xuid = "";
if (packet.getSenderUuid().getMostSignificantBits() != 0l || packet.getSenderUuid().getLeastSignificantBits() != 0l) {
GeyserSession playerSession = GeyserConnector.getInstance().getPlayerByUuid(packet.getSenderUuid());

if (playerSession != null) {
xuid = playerSession.getAuthData().getXboxUUID();
}
}

textPacket.setXuid(xuid);

switch (packet.getType()) {
case CHAT:
textPacket.setType(TextPacket.Type.CHAT);
Expand Down