From 9fb3d44d6a2a64efdc0d6079e841922dc068c5db Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 25 Aug 2019 12:10:31 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=A3=D0=BF=D1=80=D0=BE=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=B2=D0=BE=D0=B5=D0=B3=D0=BE?= =?UTF-8?q?=20HWIDProvider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launcher/client/FunctionalBridge.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/FunctionalBridge.java b/Launcher/src/main/java/pro/gravit/launcher/client/FunctionalBridge.java index 57f5ca52..a2736acb 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/FunctionalBridge.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/FunctionalBridge.java @@ -24,7 +24,7 @@ public class FunctionalBridge { @LauncherAPI public static ScheduledExecutorService threadPool = Executors.newScheduledThreadPool(0); @LauncherAPI - public static OshiHWIDProvider hwidProvider = new OshiHWIDProvider(); + public static OshiHWIDProvider hwidProvider; @LauncherAPI public static AtomicReference hwid = new AtomicReference<>(); @LauncherAPI @@ -51,14 +51,18 @@ public static void startTask(Runnable task) { @LauncherAPI public static HWID getHWID() { HWID hhwid = hwid.get(); - if (hhwid == null) hwid.set(hwidProvider.getHWID()); + if (hhwid == null) { + if(hwidProvider == null) hwidProvider = new OshiHWIDProvider(); + hwid.set(hwidProvider.getHWID()); + } return hhwid; } @LauncherAPI - public static int getTotalMemory() { - if (cachedMemorySize > 0) return (int) cachedMemorySize; - return (int) (cachedMemorySize = hwidProvider.getTotalMemory() >> 20); + public static long getTotalMemory() { + if (cachedMemorySize > 0) return cachedMemorySize; + if(hwidProvider == null) hwidProvider = new OshiHWIDProvider(); + return (cachedMemorySize = hwidProvider.getTotalMemory() >> 20); } @LauncherAPI @@ -67,7 +71,7 @@ public static int getClientJVMBits() { } @LauncherAPI - public static int getJVMTotalMemory() { + public static long getJVMTotalMemory() { if (getClientJVMBits() == 32) { return Math.min(getTotalMemory(), 1536); } else {