From ca54d9316d01040823815462f65f810c91143c04 Mon Sep 17 00:00:00 2001 From: PandaNinjas Date: Thu, 9 Feb 2023 19:33:00 -0800 Subject: Google code style but with 4 spaces instead of 2 --- .../nosession/tweaks/initial/InitialTweaker.java | 6 +++--- src/main/java/gq/malwarefight/nosession/utils/Utils.java | 8 ++++++-- src/main/java/gq/malwarefight/tokenapp/Main.java | 15 ++++++++------- 3 files changed, 17 insertions(+), 12 deletions(-) (limited to 'src/main/java/gq/malwarefight') diff --git a/src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java b/src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java index 21b2646..aae8bb6 100644 --- a/src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java +++ b/src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java @@ -49,14 +49,14 @@ public class InitialTweaker implements ITweaker { } } if (isRelaunch) { - String finalUuid = uuid; - if (finalUuid == null) { + String finalUUID = uuid; + if (finalUUID == null) { return; // if we don't have a uuid, quit } Runtime.getRuntime().addShutdownHook( new Thread(() -> { try { - Socket socket = Utils.getProperSocket(UUID.fromString(finalUuid)); + Socket socket = Utils.getProperSocket(UUID.fromString(Utils.normalizeUUID(finalUUID))); socket.getOutputStream().write("fullquit\n".getBytes(StandardCharsets.UTF_8)); socket.close(); } catch (Exception e) { diff --git a/src/main/java/gq/malwarefight/nosession/utils/Utils.java b/src/main/java/gq/malwarefight/nosession/utils/Utils.java index 7d3c4dd..b34c0aa 100644 --- a/src/main/java/gq/malwarefight/nosession/utils/Utils.java +++ b/src/main/java/gq/malwarefight/nosession/utils/Utils.java @@ -91,6 +91,12 @@ public class Utils { } } + public static String normalizeUUID(String uuid) { + return uuid.replaceFirst( + "(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", "$1-$2-$3-$4-$5" + ); + } + public static void setStaticValue(Class cls, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException { Field f = cls.getDeclaredField(fieldName); f.setAccessible(true); @@ -169,8 +175,6 @@ public class Utils { public static void setToken(String token) throws IOException, InvocationTargetException, NoSuchMethodException, IllegalAccessException, URISyntaxException { Properties p = getJavaProperties(); - String cp = getClasspath(p); - System.out.println(cp); ProcessBuilder processBuilder = new ProcessBuilder( getJavaExe(p), "-cp", getClasspath(p), Main.class.getName() ); diff --git a/src/main/java/gq/malwarefight/tokenapp/Main.java b/src/main/java/gq/malwarefight/tokenapp/Main.java index ecea1f3..96b9cb3 100644 --- a/src/main/java/gq/malwarefight/tokenapp/Main.java +++ b/src/main/java/gq/malwarefight/tokenapp/Main.java @@ -14,6 +14,7 @@ import java.net.*; import java.util.UUID; public class Main { + public static final int BASE_PORT = 47777; public static YggdrasilMinecraftSessionService sessionService = null; public static YggdrasilAuthenticationService authenticationService = null; @@ -21,18 +22,17 @@ public class Main { public static void setup() throws IOException { String token = Utils.readString(System.in, '\n'); - System.out.println(token); - YggdrasilAuthenticationService yas = new YggdrasilAuthenticationService(Proxy.NO_PROXY, token); + YggdrasilAuthenticationService yas = new YggdrasilAuthenticationService(Proxy.NO_PROXY, + token); authenticationService = yas; sessionService = (YggdrasilMinecraftSessionService) yas.createMinecraftSessionService(); - HttpsURLConnection httpsURLConnection = (HttpsURLConnection) (new URL("https://api.minecraftservices.com/minecraft/profile").openConnection()); + HttpsURLConnection httpsURLConnection = (HttpsURLConnection) (new URL( + "https://api.minecraftservices.com/minecraft/profile").openConnection()); httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token); String response = Utils.readString(httpsURLConnection.getInputStream(), null); JsonObject jsonObject = new JsonParser().parse(response).getAsJsonObject(); UUID id = UUID.fromString( - jsonObject.get("id").getAsString().replaceFirst( - "(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", "$1-$2-$3-$4-$5" - ) + Utils.normalizeUUID(jsonObject.get("id").getAsString()) ); String name = jsonObject.get("name").getAsString(); gameProfile = new GameProfile(id, name); @@ -52,7 +52,8 @@ public class Main { //noinspection resource sock = new ServerSocket(i, 50, InetAddress.getLoopbackAddress()); break; - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } if (sock == null) { System.err.println("Could not bind to any valid port"); -- cgit