Fixed NullPointerException when minecraftArguments=null
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
package org.jackhuang.hellominecraft.launcher.core.install.forge;
|
||||
|
||||
import org.jackhuang.hellominecraft.launcher.core.install.InstallProfile;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
@@ -32,6 +31,7 @@ import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -79,10 +79,8 @@ public class ForgeInstaller extends Task {
|
||||
File file = new File(gameDir, "libraries/" + forge.getDownloadInfo().path);
|
||||
if (file.getParentFile().mkdirs())
|
||||
HMCLog.warn("Failed to make library directory " + file.getParent());
|
||||
try (FileOutputStream fos = new FileOutputStream(file); BufferedOutputStream bos = new BufferedOutputStream(fos)) {
|
||||
int c;
|
||||
while ((c = is.read()) != -1)
|
||||
bos.write((byte) c);
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
IOUtils.copyStream(is, fos);
|
||||
}
|
||||
mp.version().refreshVersions();
|
||||
}
|
||||
|
||||
@@ -45,8 +45,12 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
protected void makeSelf(List<String> res) throws GameException {
|
||||
StringBuilder library = new StringBuilder("");
|
||||
for (MinecraftLibrary l : version.libraries)
|
||||
if (l.allow() && !l.isRequiredToUnzip())
|
||||
library.append(l.getFilePath(gameDir).getAbsolutePath()).append(File.pathSeparator);
|
||||
if (l.allow() && !l.isRequiredToUnzip()) {
|
||||
File f = l.getFilePath(gameDir);
|
||||
if (f == null)
|
||||
continue;
|
||||
library.append(f.getAbsolutePath()).append(File.pathSeparator);
|
||||
}
|
||||
File f = version.getJar(service.baseDirectory());
|
||||
if (!f.exists())
|
||||
throw new GameException("Minecraft jar does not exists");
|
||||
@@ -55,6 +59,8 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
res.add(library.toString().substring(0, library.length() - File.pathSeparator.length()));
|
||||
res.add(version.mainClass);
|
||||
|
||||
if (version.minecraftArguments == null)
|
||||
throw new GameException(new NullPointerException("Minecraft Arguments can not be null."));
|
||||
String[] splitted = StrUtils.tokenize(version.minecraftArguments);
|
||||
|
||||
String game_assets = assetProvider.apply(version, !options.isNotCheckGame());
|
||||
|
||||
@@ -105,7 +105,10 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
||||
|
||||
@Override
|
||||
public File getFilePath(File gameDir) {
|
||||
return new File(gameDir, "libraries/" + getDownloadInfo().path);
|
||||
LibraryDownloadInfo info = getDownloadInfo();
|
||||
if (info == null)
|
||||
return null;
|
||||
return new File(gameDir, "libraries/" + info.path);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user