From d7f901c7453254ee42dde1e2fd89f68f5dff52aa Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Sun, 28 Apr 2019 15:04:16 +0300 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=9C=D0=BE=D0=B8=20=D0=BE=D1=88=D0=B8?= =?UTF-8?q?=D0=B1=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 26 ++++++++++--------- .../launcher/client/FunctionalBridge.java | 8 +++--- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 93efae79..5709d4f5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -732,19 +732,20 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { newConfig.components.put("authLimiter", authLimiterComponent); // Set server address + String address; if (testEnv) { - newConfig.setLegacyAddress("localhost"); + address = "localhost"; newConfig.setProjectName("test"); } else { - System.out.println("LaunchServer legacy address(default: localhost): "); - newConfig.setLegacyAddress(commandHandler.readLine()); + System.out.println("LaunchServer address(default: localhost): "); + address = commandHandler.readLine(); System.out.println("LaunchServer projectName: "); newConfig.setProjectName(commandHandler.readLine()); } - if(newConfig.legacyAddress == null) + if(address == null) { - LogHelper.error("Legacy address null. Using localhost"); - newConfig.legacyAddress = "localhost"; + LogHelper.error("Address null. Using localhost"); + address = "localhost"; } if(newConfig.projectName == null) { @@ -752,10 +753,11 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException { newConfig.projectName = "MineCraft"; } - newConfig.netty.address = "ws://" + newConfig.legacyAddress + ":9274/api"; - newConfig.netty.downloadURL = "http://" + newConfig.legacyAddress + ":9274/%dirname%/"; - newConfig.netty.launcherURL = "http://" + newConfig.legacyAddress + ":9274/internal/Launcher.jar"; - newConfig.netty.launcherEXEURL = "http://" + newConfig.legacyAddress + ":9274/internal/Launcher.exe"; + newConfig.legacyAddress = address; + newConfig.netty.address = "ws://" + address + ":9274/api"; + newConfig.netty.downloadURL = "http://" + address + ":9274/%dirname%/"; + newConfig.netty.launcherURL = "http://" + address + ":9274/internal/Launcher.jar"; + newConfig.netty.launcherEXEURL = "http://" + address + ":9274/internal/Launcher.exe"; newConfig.netty.sendExceptionEnabled = true; // Write LaunchServer config @@ -840,14 +842,14 @@ public void syncUpdatesDir(Collection dirs) throws IOException { LogHelper.info("Syncing updates dir"); Map> newUpdatesDirMap = new HashMap<>(16); try (DirectoryStream dirStream = Files.newDirectoryStream(updatesDir)) { - for (Path updateDir : dirStream) { + for (final Path updateDir : dirStream) { if (Files.isHidden(updateDir)) continue; // Skip hidden // Resolve name and verify is dir String name = IOHelper.getFileName(updateDir); if (!IOHelper.isDir(updateDir)) { - if (!updateDir.toString().endsWith(".jar") && !updateDir.toString().endsWith(".exe") && !updateDir.toString().endsWith(".hash")) LogHelper.warning("Not update dir: '%s'", name); + if (!IOHelper.isFile(updateDir) && Arrays.asList(".jar", ".exe", ".hash").stream().noneMatch(e -> updateDir.toString().endsWith(e))) LogHelper.warning("Not update dir: '%s'", name); continue; } diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java index a530b0d7..57f7334c 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java @@ -56,9 +56,9 @@ public static HWID getHWID() { } @LauncherAPI - public static long getTotalMemory() { - if (cachedMemorySize > 0) return cachedMemorySize; - return cachedMemorySize = hwidProvider.getTotalMemory() >> 20; + public static int getTotalMemory() { + if (cachedMemorySize > 0) return (int)cachedMemorySize; + return (int)(cachedMemorySize = hwidProvider.getTotalMemory() >> 20); } @LauncherAPI @@ -67,7 +67,7 @@ public static int getClientJVMBits() { } @LauncherAPI - public static long getJVMTotalMemory() { + public static int getJVMTotalMemory() { if (getClientJVMBits() == 32) { return Math.min(getTotalMemory(), 1536); } else {