From b4c90a1119d0d58ff893ca9dbbf7674c1c190d87 Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Mon, 2 Dec 2024 01:47:43 +0100 Subject: [PATCH] Ensure player UUID is always set --- .../viaproxy/proxy/packethandler/LoginPacketHandler.java | 3 ++- .../raphimc/viaproxy/saves/impl/accounts/OfflineAccount.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/LoginPacketHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/LoginPacketHandler.java index f6bf332..43fbb7c 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/LoginPacketHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/LoginPacketHandler.java @@ -30,6 +30,7 @@ import net.raphimc.netminecraft.packet.impl.login.C2SLoginKeyPacket; import net.raphimc.netminecraft.packet.impl.login.S2CLoginGameProfilePacket; import net.raphimc.netminecraft.packet.impl.login.S2CLoginHelloPacket; import net.raphimc.vialegacy.api.LegacyProtocolVersion; +import net.raphimc.vialegacy.api.util.UuidUtil; import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ProtocolMetadataStorage; import net.raphimc.viaproxy.ViaProxy; import net.raphimc.viaproxy.plugins.events.ClientLoggedInEvent; @@ -84,7 +85,7 @@ public class LoginPacketHandler extends PacketHandler { if (loginHelloPacket.uuid != null) { proxyConnection.setGameProfile(new GameProfile(loginHelloPacket.uuid, loginHelloPacket.name)); } else { - proxyConnection.setGameProfile(new GameProfile(null, loginHelloPacket.name)); + proxyConnection.setGameProfile(new GameProfile(UuidUtil.createOfflinePlayerUuid(loginHelloPacket.name), loginHelloPacket.name)); } if (ViaProxy.getConfig().isProxyOnlineMode() && !ViaProxy.EVENT_MANAGER.call(new ShouldVerifyOnlineModeEvent(this.proxyConnection)).isCancelled()) { diff --git a/src/main/java/net/raphimc/viaproxy/saves/impl/accounts/OfflineAccount.java b/src/main/java/net/raphimc/viaproxy/saves/impl/accounts/OfflineAccount.java index 4475e85..1df1fe9 100644 --- a/src/main/java/net/raphimc/viaproxy/saves/impl/accounts/OfflineAccount.java +++ b/src/main/java/net/raphimc/viaproxy/saves/impl/accounts/OfflineAccount.java @@ -18,8 +18,8 @@ package net.raphimc.viaproxy.saves.impl.accounts; import com.google.gson.JsonObject; +import net.raphimc.vialegacy.api.util.UuidUtil; -import java.nio.charset.StandardCharsets; import java.util.UUID; public class OfflineAccount extends Account { @@ -34,7 +34,7 @@ public class OfflineAccount extends Account { public OfflineAccount(final String name) { this.name = name; - this.uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)); + this.uuid = UuidUtil.createOfflinePlayerUuid(name); } @Override