From 608c467acc5cabcbeef2924b323457d599b4413f Mon Sep 17 00:00:00 2001 From: nerotvlive Date: Fri, 2 Feb 2024 21:34:13 +0100 Subject: [PATCH] Update project to 2024.2.2 --- pom.xml | 2 +- .../impl/MinecraftMSLiveAuthProcess.java | 21 +++++++++++++++++-- .../live/nerotv/zyneon/auth/ZyneonAuth.java | 14 +++++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 35a04a0..cbb14bb 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ live.nerotv ZyneonAuth - 2024.2.1 + 2024.2.2 jar ZyneonAuth diff --git a/src/main/java/app/elizon/authhelper/process/impl/MinecraftMSLiveAuthProcess.java b/src/main/java/app/elizon/authhelper/process/impl/MinecraftMSLiveAuthProcess.java index c11f767..18b48ba 100644 --- a/src/main/java/app/elizon/authhelper/process/impl/MinecraftMSLiveAuthProcess.java +++ b/src/main/java/app/elizon/authhelper/process/impl/MinecraftMSLiveAuthProcess.java @@ -35,10 +35,25 @@ public class MinecraftMSLiveAuthProcess extends ProcessDetails { private final static Integer loginTimeoutInSeconds = 300; + ServerHelper helper; + + public ServerHelper getServer() { + if(helper==null) { + helper = new ServerHelper(); + } + return helper; + } + + public void setServer(ServerHelper helper) { + this.helper = helper; + } + @Override @SuppressWarnings("all") public HashMap login() { - ServerHelper helper = new ServerHelper(); + if(helper==null) { + helper = new ServerHelper(); + } new Thread(() -> { try { @@ -216,7 +231,9 @@ public HashMap relogin(String refreshToken) { String accessToken; - ServerHelper helper = new ServerHelper(); + if(helper!=null) { + helper = new ServerHelper(); + } helper.startServerHeadless(local_port); HttpURLConnection conn = (HttpURLConnection) new URI("https://login.live.com/oauth20_token.srf").toURL().openConnection(); diff --git a/src/main/java/live/nerotv/zyneon/auth/ZyneonAuth.java b/src/main/java/live/nerotv/zyneon/auth/ZyneonAuth.java index b155560..392cd3e 100644 --- a/src/main/java/live/nerotv/zyneon/auth/ZyneonAuth.java +++ b/src/main/java/live/nerotv/zyneon/auth/ZyneonAuth.java @@ -12,13 +12,18 @@ public static HashMap getAuthInfos() { HashMap map = new HashMap<>(); try { //AUTHENTICATE AND RETURN DATA - HashMap authData = new AuthProcess().startAuthProcess(new MinecraftMSLiveAuthProcess()); + MinecraftMSLiveAuthProcess process = new MinecraftMSLiveAuthProcess(); + HashMap authData = new AuthProcess().startAuthProcess(process); //ADDING DATA FROM AUTH DATA TO MAP map.put(AuthInfo.ACCESS_TOKEN,authData.get("minecraft_token")); map.put(AuthInfo.REFRESH_TOKEN,authData.get("ms_refresh_token")); map.put(AuthInfo.USERNAME,authData.get("username")); map.put(AuthInfo.UUID,authData.get("uuid")); + + process.getServer().stopServer(); + process.setServer(null); + System.gc(); } catch (Exception e) { //RETURNING NULL IF ERROR return null; @@ -32,13 +37,18 @@ public static HashMap getAuthInfos(String refreshToken) { HashMap map = new HashMap<>(); try { //AUTHENTICATE AND RETURN DATA - HashMap authData = new AuthProcess().reAuth(new MinecraftMSLiveAuthProcess(), refreshToken); + MinecraftMSLiveAuthProcess process = new MinecraftMSLiveAuthProcess(); + HashMap authData = new AuthProcess().reAuth(process, refreshToken); //ADDING DATA FROM AUTH DATA TO MAP map.put(AuthInfo.ACCESS_TOKEN,authData.get("minecraft_token")); map.put(AuthInfo.REFRESH_TOKEN,authData.get("ms_refresh_token")); map.put(AuthInfo.USERNAME,authData.get("username")); map.put(AuthInfo.UUID,authData.get("uuid")); + + process.getServer().stopServer(); + process.setServer(null); + System.gc(); } catch (Exception e) { //RETURNING NULL IF ERROR return null;