From 8423586d7c854baa3324dfae994cda717edeb945 Mon Sep 17 00:00:00 2001 From: voruti <45130096+voruti@users.noreply.github.com> Date: Fri, 1 Dec 2023 21:58:21 +0100 Subject: [PATCH] Fix building UUID --- src/main/java/one/oktw/Util.java | 13 +++++++++++++ .../bungee/ServerHandshakeNetworkHandlerMixin.java | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 src/main/java/one/oktw/Util.java diff --git a/src/main/java/one/oktw/Util.java b/src/main/java/one/oktw/Util.java new file mode 100644 index 0000000..3fcbea1 --- /dev/null +++ b/src/main/java/one/oktw/Util.java @@ -0,0 +1,13 @@ +package one.oktw; + +import java.util.UUID; + +public final class Util { + private Util() { + } + + + public static UUID fromString(final String input) { + return UUID.fromString(input.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5")); + } +} diff --git a/src/main/java/one/oktw/mixin/bungee/ServerHandshakeNetworkHandlerMixin.java b/src/main/java/one/oktw/mixin/bungee/ServerHandshakeNetworkHandlerMixin.java index f87d345..c84b1fe 100644 --- a/src/main/java/one/oktw/mixin/bungee/ServerHandshakeNetworkHandlerMixin.java +++ b/src/main/java/one/oktw/mixin/bungee/ServerHandshakeNetworkHandlerMixin.java @@ -2,7 +2,6 @@ import com.google.gson.Gson; import com.mojang.authlib.properties.Property; -import com.mojang.util.UUIDTypeAdapter; import net.minecraft.network.ClientConnection; import net.minecraft.network.NetworkState; import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket; @@ -11,6 +10,7 @@ import net.minecraft.text.LiteralTextContent; import net.minecraft.text.MutableText; import net.minecraft.text.Text; +import one.oktw.Util; import one.oktw.interfaces.BungeeClientConnection; import one.oktw.mixin.ClientConnectionAccessor; import org.spongepowered.asm.mixin.Final; @@ -47,7 +47,7 @@ private void onProcessHandshakeStart(HandshakeC2SPacket packet, CallbackInfo ci) // extract forwarded profile information and save them: - ((BungeeClientConnection) connection).setSpoofedUUID(UUIDTypeAdapter.fromString(split[2])); + ((BungeeClientConnection) connection).setSpoofedUUID(Util.fromString(split[2])); if (split.length == 4) { ((BungeeClientConnection) connection).setSpoofedProfile(gson.fromJson(split[3], Property[].class));