mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FEATURE] Упрощение добавления своего HWIDProvider
This commit is contained in:
parent
6cc18ec1b8
commit
9fb3d44d6a
1 changed files with 10 additions and 6 deletions
|
@ -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> 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 {
|
||||
|
|
Loading…
Reference in a new issue