Ensure player UUID is always set

This commit is contained in:
RaphiMC 2024-12-02 01:47:43 +01:00
parent 883ac408d1
commit b4c90a1119
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
2 changed files with 4 additions and 3 deletions

View File

@ -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()) {

View File

@ -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