diff options
Diffstat (limited to 'src/main/java/gq/malwarefight/tokenapp')
-rw-r--r-- | src/main/java/gq/malwarefight/tokenapp/Main.java | 15 |
1 files changed, 8 insertions, 7 deletions
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"); |