diff --git a/.vscode/snippets/java.json b/.vscode/snippets/java.json index bfa2d71f..763c78ea 100644 --- a/.vscode/snippets/java.json +++ b/.vscode/snippets/java.json @@ -2,7 +2,7 @@ "LogManager_Log": { "prefix": "logmanager", "body": [ - "LogManager.${1|debug,warn,logStackTrace,info,error|}(${2:\"Test\"});" + "LogManager.${1|debug,debugObject,warn,logStackTrace,info,error|}(${2:\"Test\"});" ], "description": "Log a debug message to the ATLauncher console" } diff --git a/src/main/java/com/atlauncher/LogManager.java b/src/main/java/com/atlauncher/LogManager.java index eb202997..bb3f7685 100644 --- a/src/main/java/com/atlauncher/LogManager.java +++ b/src/main/java/com/atlauncher/LogManager.java @@ -53,6 +53,10 @@ public final class LogManager { debug(message, false); } + public static void debugObject(Object object) { + debug(Gsons.DEFAULT.toJson(object), false); + } + public static void debug(String message, boolean force) { if (showDebug || force) { queue.offer(new LogEvent(LogType.DEBUG, message)); diff --git a/src/main/java/com/atlauncher/workers/NewInstanceInstaller.java b/src/main/java/com/atlauncher/workers/NewInstanceInstaller.java index b1408b52..39e58689 100644 --- a/src/main/java/com/atlauncher/workers/NewInstanceInstaller.java +++ b/src/main/java/com/atlauncher/workers/NewInstanceInstaller.java @@ -627,17 +627,18 @@ public class NewInstanceInstaller extends InstanceInstaller { } private List getDownloadableLibraries() { - return this.getLibraries().stream().map(library -> { - if (library instanceof ForgeLibrary && ((ForgeLibrary) library).isUsingPackXz()) { - return new ForgeXzDownloadable(library.downloads.artifact.url, - new File(App.settings.getGameLibrariesDir(), library.downloads.artifact.path), - library.downloads.artifact.sha1, library.downloads.artifact.size, this, null); - } + return this.getLibraries().stream() + .filter(library -> library.shouldInstall() && library.downloads.artifact != null).map(library -> { + if (library instanceof ForgeLibrary && ((ForgeLibrary) library).isUsingPackXz()) { + return new ForgeXzDownloadable(library.downloads.artifact.url, + new File(App.settings.getGameLibrariesDir(), library.downloads.artifact.path), + library.downloads.artifact.sha1, library.downloads.artifact.size, this, null); + } - return new Downloadable(library.downloads.artifact.url, - new File(App.settings.getGameLibrariesDir(), library.downloads.artifact.path), - library.downloads.artifact.sha1, library.downloads.artifact.size, this, false); - }).collect(Collectors.toList()); + return new Downloadable(library.downloads.artifact.url, + new File(App.settings.getGameLibrariesDir(), library.downloads.artifact.path), + library.downloads.artifact.sha1, library.downloads.artifact.size, this, false); + }).collect(Collectors.toList()); } private List getDownloadableNativeLibraries() { @@ -654,29 +655,31 @@ public class NewInstanceInstaller extends InstanceInstaller { fireTask(Language.INSTANCE.localize("instance.organisinglibraries")); fireSubProgressUnknown(); - this.getLibraries().stream().forEach(library -> { - File libraryFile = new File(App.settings.getGameLibrariesDir(), library.downloads.artifact.path); + this.getLibraries().stream().filter(library -> library.shouldInstall() && library.downloads.artifact != null) + .forEach(library -> { + File libraryFile = new File(App.settings.getGameLibrariesDir(), library.downloads.artifact.path); - if (isServer) { - File serverFile = new File(getLibrariesDirectory(), library.downloads.artifact.path); + if (isServer) { + File serverFile = new File(getLibrariesDirectory(), library.downloads.artifact.path); - serverFile.getParentFile().mkdirs(); + serverFile.getParentFile().mkdirs(); - Utils.copyFile(libraryFile, serverFile, true); - } else if (library.hasNativeForOS()) { - File nativeFile = new File(App.settings.getGameLibrariesDir(), library.getNativeDownloadForOS().path); + Utils.copyFile(libraryFile, serverFile, true); + } else if (library.hasNativeForOS()) { + File nativeFile = new File(App.settings.getGameLibrariesDir(), + library.getNativeDownloadForOS().path); - ZipUtil.unpack(nativeFile, this.getNativesDirectory(), new NameMapper() { - public String map(String name) { - if (library.extract != null && library.extract.shouldExclude(name)) { - return null; - } + ZipUtil.unpack(nativeFile, this.getNativesDirectory(), new NameMapper() { + public String map(String name) { + if (library.extract != null && library.extract.shouldExclude(name)) { + return null; + } - return name; + return name; + } + }); } }); - } - }); hideSubProgressBar(); }