From e17c348850620b9c3d54b47f2e5bfaf68de74794 Mon Sep 17 00:00:00 2001 From: winterflyt <36+winterflyt@noreply.skidsolutions.xyz> Date: Mon, 30 Nov 2026 05:45:55 +0200 Subject: [PATCH] Upload files to "src/openonyx/connection" --- src/openonyx/connection/MicrosoftAccount.java | 126 +++++++++ src/openonyx/connection/OfflineAccount.java | 85 ++++++ src/openonyx/connection/ProfileSkinCache.java | 55 ++++ .../connection/ProfileSkinCacheCallback.java | 20 ++ src/openonyx/connection/ProxySettings.java | 266 ++++++++++++++++++ 5 files changed, 552 insertions(+) create mode 100644 src/openonyx/connection/MicrosoftAccount.java create mode 100644 src/openonyx/connection/OfflineAccount.java create mode 100644 src/openonyx/connection/ProfileSkinCache.java create mode 100644 src/openonyx/connection/ProfileSkinCacheCallback.java create mode 100644 src/openonyx/connection/ProxySettings.java diff --git a/src/openonyx/connection/MicrosoftAccount.java b/src/openonyx/connection/MicrosoftAccount.java new file mode 100644 index 0000000..74d5b83 --- /dev/null +++ b/src/openonyx/connection/MicrosoftAccount.java @@ -0,0 +1,126 @@ +package openonyx.connection; + +import com.google.gson.JsonObject; +import com.mojang.util.UUIDTypeAdapter; +import net.minecraft.util.Session; +import openonyx.connection.internal.AuthException; +import openonyx.connection.internal.XboxLiveAuth; +import openonyx.connection.internal.XboxLiveAuthData2; +import openonyx.connection.internal.XboxLiveAuthMode; + +public class MicrosoftAccount extends Account { + private long l; + private String I; + private String d; + private String f; + private XboxLiveAuthMode xboxLiveAuthMode = XboxLiveAuthMode.LEGACY; + private static final long e = 60000L; + + public static MicrosoftAccount L(String string) throws AuthException { + String string1 = string; + + try { + return L(string1, XboxLiveAuthMode.LEGACY); + } catch (AuthException authException1) { + if (!XboxLiveAuthMode.AZURE.L()) { + throw authException1; + } + + try { + return L(string1, XboxLiveAuthMode.AZURE); + } catch (AuthException authException) { + throw new AuthException( + new StringBuilder() + .insert(0, "No client id accepted this token. Live: ") + .append(authException1.getMessage()) + .append(" | Azure: ") + .append(authException.getMessage()) + .toString() + ); + } + } + } + + @Override + protected void d(JsonObject jsonObject) { + jsonObject.addProperty("refreshToken", this.I); + jsonObject.addProperty("flavour", this.xboxLiveAuthMode.i()); + if (this.d != null) { + jsonObject.addProperty("accessToken", this.d); + jsonObject.addProperty("expiresAt", this.l); + if (this.f != null) { + jsonObject.addProperty("xuid", this.f); + } + } + } + + @Override + public void L() throws AuthException { + this.L(XboxLiveAuth.d(this.I, this.xboxLiveAuthMode)); + } + + @Override + public Session L() throws AuthException { + if (this.d == null || System.currentTimeMillis() > this.l - 60000L) { + this.L(); + } + + return new Session(this.i, UUIDTypeAdapter.fromUUID(this.uuid), this.d, "mojang"); + } + + @Override + public String d() { + return this.d; + } + + public static MicrosoftAccount L(XboxLiveAuthData2 xboxLiveAuthData2) { + MicrosoftAccount microsoftAccount = new MicrosoftAccount(xboxLiveAuthData2.name()); + microsoftAccount.L(xboxLiveAuthData2); + return microsoftAccount; + } + + @Override + public String L() { + return this.I; + } + + public static MicrosoftAccount L(String string, XboxLiveAuthMode xboxLiveAuthMode) throws AuthException { + return L(XboxLiveAuth.d(string, xboxLiveAuthModex)); + } + + public XboxLiveAuthMode getXboxLiveAuthMode() { + return this.xboxLiveAuthMode; + } + + @Override + protected void L(JsonObject jsonObject) { + this.I = L(jsonObject, "refreshToken"); + this.xboxLiveAuthMode = XboxLiveAuthMode.L(L(jsonObject, "flavour")); + this.d = L(jsonObject, "accessToken"); + this.l = L(jsonObject, "expiresAt", 0L); + this.f = L(jsonObject, "xuid"); + } + + @Override + public long d() { + return this.l; + } + + private void L(XboxLiveAuthData2 xboxLiveAuthData2) { + this.i = xboxLiveAuthData2.name(); + this.uuid = xboxLiveAuthData2.uuid(); + this.xboxLiveAuthMode = xboxLiveAuthData2.flavour(); + this.I = xboxLiveAuthData2.refreshToken(); + this.d = xboxLiveAuthData2.accessToken(); + this.l = xboxLiveAuthData2.expiresAt(); + this.f = xboxLiveAuthData2.xuid(); + } + + public String i() { + return this.I; + } + + public MicrosoftAccount(String string) { + super(AccountType.MICROSOFT, string); + } +} diff --git a/src/openonyx/connection/OfflineAccount.java b/src/openonyx/connection/OfflineAccount.java new file mode 100644 index 0000000..bf6818c --- /dev/null +++ b/src/openonyx/connection/OfflineAccount.java @@ -0,0 +1,85 @@ +package openonyx.connection; + +import com.google.gson.JsonObject; +import com.mojang.util.UUIDTypeAdapter; +import java.nio.charset.StandardCharsets; +import java.util.UUID; +import net.minecraft.util.Session; +import openonyx.connection.internal.AuthException; +import openonyx.connection.internal.AuthHttpClient; +import openonyx.connection.internal.AuthHttpClientData; +import openonyx.connection.internal.XboxLiveAuth; + +public class OfflineAccount extends Account { + private static final String f = "https://api.mojang.com/users/profiles/minecraft/"; + private boolean H; + private static final String e = "-"; + + public void L(boolean bl) { + this.H = bl; + } + + @Override + public Session L() throws AuthException { + if (this.uuid == null) { + this.L(); + } + + return new Session(this.i, UUIDTypeAdapter.fromUUID(this.uuid), "-", "legacy"); + } + + @Override + protected void L(JsonObject jsonObject) { + this.H = L(jsonObject, "premiumUuid", false); + } + + @Override + public void L() throws AuthException { + OfflineAccount offlineAccount1 = this; + if (!offlineAccount1.H) { + offlineAccount1.uuid = L(offlineAccount1.i); + } else { + String string2 = new StringBuilder() + .insert(0, "https://api.mojang.com/users/profiles/minecraft/") + .append(AuthHttpClient.L(offlineAccount1.i)) + .toString(); + String[] strings = new String[0]; + boolean bl = true; + AuthHttpClientData authHttpClientData; + if (!(authHttpClientData = AuthHttpClient.L(string2, strings)).L()) { + offlineAccount1.uuid = L(offlineAccount1.i); + } else { + JsonObject jsonObject = authHttpClientData.L(); + String string1 = AuthHttpClient.L(jsonObject, "id"); + String string = AuthHttpClient.L(jsonObject, "name"); + if (string1 == null) { + offlineAccount1.uuid = L(offlineAccount1.i); + } else { + if (string != null) { + offlineAccount1.i = string; + } + + offlineAccount1.uuid = XboxLiveAuth.L(string1); + } + } + } + } + + public boolean L() { + return this.H; + } + + public static UUID L(String string) { + return UUID.nameUUIDFromBytes(new StringBuilder().insert(0, "OfflinePlayer:").append(string).toString().getBytes(StandardCharsets.UTF_8)); + } + + public OfflineAccount(String string) { + super(AccountType.OFFLINE, string); + this.uuid = L(string); + } + + @Override + protected void d(JsonObject jsonObject) { + jsonObject.addProperty("premiumUuid", this.H); + } +} diff --git a/src/openonyx/connection/ProfileSkinCache.java b/src/openonyx/connection/ProfileSkinCache.java new file mode 100644 index 0000000..c2b14c4 --- /dev/null +++ b/src/openonyx/connection/ProfileSkinCache.java @@ -0,0 +1,55 @@ +package openonyx.connection; + +import com.mojang.authlib.GameProfile; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import net.minecraft.client.resources.DefaultPlayerSkin; +import net.minecraft.util.ResourceLocation; +import openonyx.core.MinecraftAccess; +import openonyx.utilities.AsyncExecutor; + +public final class ProfileSkinCache implements MinecraftAccess { + private static final Map BOOLEAN_MAP = new ConcurrentHashMap<>(); + private static final Map RESOURCE_LOCATION_MAP = new ConcurrentHashMap<>(); + + public static void L(UUID uUID) { + if (uUID != null) { + RESOURCE_LOCATION_MAP.remove(uUID); + BOOLEAN_MAP.remove(uUID); + } + } + + public static ResourceLocation L(UUID uUID, String string) { + UUID uUID1 = uUID; + if (uUID1 == null) { + return DefaultPlayerSkin.getDefaultSkinLegacy(); + } + + ResourceLocation resourceLocation; + if ((resourceLocation = RESOURCE_LOCATION_MAP.get(uUID1)) != null) { + return resourceLocation; + } + + L(uUID1, string); + return DefaultPlayerSkin.getDefaultSkin(uUID1); + } + + private ProfileSkinCache() { + } + + private static void L(UUID uUID, String string) { + if (BOOLEAN_MAP.putIfAbsent(uUID, Boolean.TRUE) == null) { + AsyncExecutor.L(() -> { + GameProfile gameProfile = new GameProfile(uUID, string); + + try { + mc.getSessionService().fillProfileProperties(gameProfile, false); + } catch (RuntimeException runtimeException) { + } + + mc.addScheduledTask(() -> mc.getSkinManager().loadProfileTextures(gameProfile, new ProfileSkinCacheCallback(uUID), false)); + }); + } + } +} diff --git a/src/openonyx/connection/ProfileSkinCacheCallback.java b/src/openonyx/connection/ProfileSkinCacheCallback.java new file mode 100644 index 0000000..d46ba5c --- /dev/null +++ b/src/openonyx/connection/ProfileSkinCacheCallback.java @@ -0,0 +1,20 @@ +package openonyx.connection; + +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; +import java.util.UUID; +import net.minecraft.client.resources.SkinManager.SkinAvailableCallback; +import net.minecraft.util.ResourceLocation; + +class ProfileSkinCacheCallback implements SkinAvailableCallback { + @Override + public void skinAvailable(Type type, ResourceLocation resourceLocation, MinecraftProfileTexture minecraftProfileTexture) { + if (type == Type.SKIN) { + ProfileSkinCache.RESOURCE_LOCATION_MAP.put(this.uuid, resourceLocation); + } + } + + ProfileSkinCacheCallback(UUID uUID) { + this.uuid = uUID; + } +} diff --git a/src/openonyx/connection/ProxySettings.java b/src/openonyx/connection/ProxySettings.java new file mode 100644 index 0000000..af8ba67 --- /dev/null +++ b/src/openonyx/connection/ProxySettings.java @@ -0,0 +1,266 @@ +package openonyx.connection; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.UnknownHostException; +import java.net.Proxy.Type; +import openonyx.core.OnyxClient; +import openonyx.network.LocalProxyServer; +import org.apache.logging.log4j.Logger; + +public final class ProxySettings { + private final Object i; + private volatile ProxySettingsData2 proxySettingsData2 = ProxySettingsData2.L(); + private LocalProxyServer localProxyServer; + private volatile String e; + + public ProxySettings() { + this.i = new Object(); + } + + private static String d(String string) { + return string == null ? "" : string.trim(); + } + + private Proxy i() { + ProxySettings proxySettings1 = this; + + try { + return proxySettings1.L(); + } catch (RuntimeException runtimeException) { + proxySettings1.e = runtimeException.getMessage(); + OnyxClient.LOGGER.warn("Falling back to a direct connection", runtimeException); + return Proxy.NO_PROXY; + } + } + + public String i() { + return this.proxySettingsData2.password(); + } + + public String D() { + return this.proxySettingsData2.username(); + } + + public Proxy D() { + return this.i(); + } + + public Proxy d() { + return this.proxySettingsData2.useForAuth() ? this.i() : Proxy.NO_PROXY; + } + + // $VF: Could not create synchronized statement, marking monitor enters and exits + // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!) + public void L(ProxySettingsMode proxySettingsMode, boolean bl, boolean bl1, String string, String string1, String string2) { + string = d(string); + string1 = d(string1); + String string3 = string2 == null ? "" : string2; + ProxySettingsData2 proxySettingsData21 = new ProxySettingsData2; + if (bl) { + proxySettingsData21./* $VF: Unable to resugar constructor */(proxySettingsMode, true, bl1, string, string1, string3, L(string)); + } else { + proxySettingsData21./* $VF: Unable to resugar constructor */(proxySettingsMode, false, bl1, string, string1, string3, null); + } + + ProxySettingsData2 proxySettingsData2x = proxySettingsData21; + Object object = this.i; + synchronized (this.i) { + Object object1; + label30: { + this.proxySettingsData2 = proxySettingsData2x; + this.e = null; + if (this.localProxyServer != null) { + if (proxySettingsData2x.enabled()) { + this.localProxyServer + .L(proxySettingsData2x.protocol(), proxySettingsData2x.L(), proxySettingsData2x.username(), proxySettingsData2x.password()); + object1 = object; + break label30; + } + + this.L(); + } + + object1 = object; + } + + // $VF: monitorexit + } + } + + private static ProxySettingsData L(String string) { + String string1 = string; + int ix; + if ((ix = string1.lastIndexOf(58)) > 0 && ix != string1.length() - 1) { + String string2; + if ((string2 = string1.substring(0, ix).trim()).startsWith("[") && string2.endsWith("]")) { + string2 = string2.substring(1, string2.length() - 1); + } + + if (string2.isBlank()) { + throw new IllegalArgumentException("Enter a proxy host"); + } + + try { + j = Integer.parseInt(string1.substring(ix + 1)); + } catch (NumberFormatException numberFormatException) { + throw new IllegalArgumentException("Enter a valid proxy port"); + } + + if (j >= 1 && j <= 65535) { + try { + return new ProxySettingsData(string2, j, new InetSocketAddress(InetAddress.getByName(string2), j)); + } catch (UnknownHostException unknownHostException) { + throw new IllegalArgumentException("Could not resolve the proxy host"); + } + } else { + throw new IllegalArgumentException("Enter a valid proxy port"); + } + } else { + throw new IllegalArgumentException("Enter proxy address as host:port"); + } + } + + public boolean d() { + return this.proxySettingsData2.enabled(); + } + + public Proxy L() { + ProxySettings proxySettings1 = this; + ProxySettingsData2 proxySettingsData2x = proxySettings1.proxySettingsData2; + if (!proxySettings1.proxySettingsData2.enabled()) { + return Proxy.NO_PROXY; + } + + proxySettings1.e = null; + + try { + return new Proxy(Type.HTTP, proxySettings1.L(proxySettingsData2x).L()); + } catch (IOException iOException) { + throw new IllegalStateException("Could not start the local proxy bridge", iOException); + } + } + + public ProxySettingsMode L() { + return this.proxySettingsData2.protocol(); + } + + public String d() { + return this.e; + } + + public InetSocketAddress L() { + return this.proxySettingsData2.L(); + } + + public void L(JsonObject jsonObject) { + ProxySettingsMode proxySettingsMode = ProxySettingsMode.L(L(jsonObject.get("protocol"))); + boolean bl = L(jsonObject.get("enabled")); + + try { + this.L(proxySettingsMode, bl, L(jsonObject.get("auth")), L(jsonObject.get("address")), L(jsonObject.get("username")), L(jsonObject.get("password"))); + } catch (IllegalArgumentException illegalArgumentException) { + this.proxySettingsData2 = ProxySettingsData2.L(); + } + } + + private static boolean L(JsonElement jsonElement) { + return jsonElement != null && jsonElement.isJsonPrimitive() && jsonElement.getAsJsonPrimitive().isBoolean() && jsonElement.getAsBoolean(); + } + + public JsonObject L() { + ProxySettings proxySettings1 = this; + ProxySettingsData2 proxySettingsData2x = proxySettings1.proxySettingsData2; + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("protocol", proxySettingsData2x.protocol().i); + jsonObject.addProperty("enabled", proxySettingsData2x.enabled()); + jsonObject.addProperty("auth", proxySettingsData2x.useForAuth()); + jsonObject.addProperty("address", proxySettingsData2x.address()); + jsonObject.addProperty("username", proxySettingsData2x.username()); + jsonObject.addProperty("password", proxySettingsData2x.password()); + return jsonObject; + } + + public String L() { + return this.proxySettingsData2.address(); + } + + public boolean L() { + return this.proxySettingsData2.useForAuth(); + } + + public static String decrypt(String string) { + String string1 = string; + int m = (--3 ^ 5) << 4 ^ 1 << 1; + int n = 96 ^ 1 << 1; + String string2; + int p = (string2 = string1).length(); + char[] d = new char[p]; + boolean bl = true; + int j; + int o = j = p - 1; + char[] c = d; + byte b = 88; + int k = o; + int ix = m; + + while (k >= 0) { + n = j; + int l = string2.charAt(j); + j--; + c[n] = (char)(l ^ ix); + if (j < 0) { + break; + } + + l = j--; + c[l] = (char)(string2.charAt(l) ^ b); + k = j; + } + + return new String(c); + } + + private static String L(JsonElement jsonElement) { + return jsonElement != null && jsonElement.isJsonPrimitive() && jsonElement.getAsJsonPrimitive().isString() ? jsonElement.getAsString() : ""; + } + + private void L() { + if (this.localProxyServer != null) { + this.localProxyServer.close(); + } + + this.localProxyServer = null; + } + + private LocalProxyServer L(ProxySettingsData2 proxySettingsData2) throws IOException { + synchronized (this.i) { + if (this.localProxyServer != null) { + this.localProxyServer.L(proxySettingsData2x.protocol(), proxySettingsData2x.L(), proxySettingsData2x.username(), proxySettingsData2x.password()); + return this.localProxyServer; + } else { + this.localProxyServer = new LocalProxyServer( + proxySettingsData2x.protocol(), proxySettingsData2x.L(), proxySettingsData2x.username(), proxySettingsData2x.password(), string -> { + this.e = string; + Logger loggerx = OnyxClient.LOGGER; + Object[] objectsx = new Object[1]; + boolean blx = true; + objectsx[0] = string; + loggerx.warn("Proxy tunnel failed: {}", objectsx); + } + ); + Logger logger = OnyxClient.LOGGER; + Object[] objects = new Object[2]; + boolean bl = true; + objects[0] = proxySettingsData2x.protocol().L(); + objects[1] = this.localProxyServer.L(); + logger.info("Started local proxy bridge for {} at {}", objects); + return this.localProxyServer; + } + } + } +}