[FIX] Мои ошибки.

This commit is contained in:
zaxar163 2019-04-28 15:04:16 +03:00
parent 1d0554c250
commit d7f901c745
No known key found for this signature in database
GPG key ID: E3B309DD3852DE06
2 changed files with 18 additions and 16 deletions

View file

@ -732,19 +732,20 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException {
newConfig.components.put("authLimiter", authLimiterComponent); newConfig.components.put("authLimiter", authLimiterComponent);
// Set server address // Set server address
String address;
if (testEnv) { if (testEnv) {
newConfig.setLegacyAddress("localhost"); address = "localhost";
newConfig.setProjectName("test"); newConfig.setProjectName("test");
} else { } else {
System.out.println("LaunchServer legacy address(default: localhost): "); System.out.println("LaunchServer address(default: localhost): ");
newConfig.setLegacyAddress(commandHandler.readLine()); address = commandHandler.readLine();
System.out.println("LaunchServer projectName: "); System.out.println("LaunchServer projectName: ");
newConfig.setProjectName(commandHandler.readLine()); newConfig.setProjectName(commandHandler.readLine());
} }
if(newConfig.legacyAddress == null) if(address == null)
{ {
LogHelper.error("Legacy address null. Using localhost"); LogHelper.error("Address null. Using localhost");
newConfig.legacyAddress = "localhost"; address = "localhost";
} }
if(newConfig.projectName == null) if(newConfig.projectName == null)
{ {
@ -752,10 +753,11 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException {
newConfig.projectName = "MineCraft"; newConfig.projectName = "MineCraft";
} }
newConfig.netty.address = "ws://" + newConfig.legacyAddress + ":9274/api"; newConfig.legacyAddress = address;
newConfig.netty.downloadURL = "http://" + newConfig.legacyAddress + ":9274/%dirname%/"; newConfig.netty.address = "ws://" + address + ":9274/api";
newConfig.netty.launcherURL = "http://" + newConfig.legacyAddress + ":9274/internal/Launcher.jar"; newConfig.netty.downloadURL = "http://" + address + ":9274/%dirname%/";
newConfig.netty.launcherEXEURL = "http://" + newConfig.legacyAddress + ":9274/internal/Launcher.exe"; newConfig.netty.launcherURL = "http://" + address + ":9274/internal/Launcher.jar";
newConfig.netty.launcherEXEURL = "http://" + address + ":9274/internal/Launcher.exe";
newConfig.netty.sendExceptionEnabled = true; newConfig.netty.sendExceptionEnabled = true;
// Write LaunchServer config // Write LaunchServer config
@ -840,14 +842,14 @@ public void syncUpdatesDir(Collection<String> dirs) throws IOException {
LogHelper.info("Syncing updates dir"); LogHelper.info("Syncing updates dir");
Map<String, SignedObjectHolder<HashedDir>> newUpdatesDirMap = new HashMap<>(16); Map<String, SignedObjectHolder<HashedDir>> newUpdatesDirMap = new HashMap<>(16);
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(updatesDir)) { try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(updatesDir)) {
for (Path updateDir : dirStream) { for (final Path updateDir : dirStream) {
if (Files.isHidden(updateDir)) if (Files.isHidden(updateDir))
continue; // Skip hidden continue; // Skip hidden
// Resolve name and verify is dir // Resolve name and verify is dir
String name = IOHelper.getFileName(updateDir); String name = IOHelper.getFileName(updateDir);
if (!IOHelper.isDir(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; continue;
} }

View file

@ -56,9 +56,9 @@ public static HWID getHWID() {
} }
@LauncherAPI @LauncherAPI
public static long getTotalMemory() { public static int getTotalMemory() {
if (cachedMemorySize > 0) return cachedMemorySize; if (cachedMemorySize > 0) return (int)cachedMemorySize;
return cachedMemorySize = hwidProvider.getTotalMemory() >> 20; return (int)(cachedMemorySize = hwidProvider.getTotalMemory() >> 20);
} }
@LauncherAPI @LauncherAPI
@ -67,7 +67,7 @@ public static int getClientJVMBits() {
} }
@LauncherAPI @LauncherAPI
public static long getJVMTotalMemory() { public static int getJVMTotalMemory() {
if (getClientJVMBits() == 32) { if (getClientJVMBits() == 32) {
return Math.min(getTotalMemory(), 1536); return Math.min(getTotalMemory(), 1536);
} else { } else {