[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);
// 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<String> dirs) throws IOException {
LogHelper.info("Syncing updates dir");
Map<String, SignedObjectHolder<HashedDir>> newUpdatesDirMap = new HashMap<>(16);
try (DirectoryStream<Path> 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;
}

View file

@ -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 {