Skip to content

Commit

Permalink
fixed NPE on no parent
Browse files Browse the repository at this point in the history
  • Loading branch information
BloodWorkXGaming committed May 28, 2018
1 parent 35a6474 commit 25c416f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 58 deletions.
118 changes: 61 additions & 57 deletions src/main/java/atm/bloodworkxgaming/serverstarter/ServerStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,79 +33,83 @@ public class ServerStarter {
}

public static void main(String[] args) {
ConfigFile config = readConfig().normalize();
lockFile = readLockFile();
AnsiConsole.systemInstall();
try {
ConfigFile config = readConfig().normalize();
lockFile = readLockFile();
AnsiConsole.systemInstall();

boolean installOnly = args.length > 0 && args[0].equals("install");
boolean installOnly = args.length > 0 && args[0].equals("install");

LOGGER.info("ConfigFile: " + config, true);
LOGGER.info("LockFile: " + lockFile, true);
LOGGER.info("ConfigFile: " + config, true);
LOGGER.info("LockFile: " + lockFile, true);

if (config == null || lockFile == null) {
LOGGER.error("One file is null: config: " + config + " lock: " + lockFile);
return;
}
if (config == null || lockFile == null) {
LOGGER.error("One file is null: config: " + config + " lock: " + lockFile);
return;
}

LOGGER.info(ansi().fgRed().a("::::::::::::::::::::::::::::::::::::::::::::::::::::"));
LOGGER.info(ansi().fgBrightBlue().a(" Minecraft-Forge Server install/launcher jar"));
LOGGER.info(ansi().fgBrightBlue().a(" (Created by the ").fgGreen().a("\"All The Mods\"").fgBrightBlue().a(" modpack team)"));
LOGGER.info(ansi().fgRed().a("::::::::::::::::::::::::::::::::::::::::::::::::::::"));
LOGGER.info("");
LOGGER.info(" This jar will launch a Minecraft Forge Modded server");
LOGGER.info("");
LOGGER.info(ansi().a(" Github: ").fgBrightBlue().a("https://github.com/AllTheMods/ServerStarter"));
LOGGER.info(ansi().a(" Discord: ").fgBrightBlue().a("http://discord.allthepacks.com"));
LOGGER.info("");
LOGGER.info(ansi().a("You are playing ").fgGreen().a(config.modpack.name));
LOGGER.info("Starting to install/launch the server, lean back!");
LOGGER.info(ansi().fgRed().a("::::::::::::::::::::::::::::::::::::::::::::::::::::"));
LOGGER.info("");


if (!InternetChecker.checkConnection() && config.launch.checkOffline) {
LOGGER.error("Problems with the Internet connection, shutting down.");
return;
}
LOGGER.info(ansi().fgRed().a("::::::::::::::::::::::::::::::::::::::::::::::::::::"));
LOGGER.info(ansi().fgBrightBlue().a(" Minecraft-Forge Server install/launcher jar"));
LOGGER.info(ansi().fgBrightBlue().a(" (Created by the ").fgGreen().a("\"All The Mods\"").fgBrightBlue().a(" modpack team)"));
LOGGER.info(ansi().fgRed().a("::::::::::::::::::::::::::::::::::::::::::::::::::::"));
LOGGER.info("");
LOGGER.info(" This jar will launch a Minecraft Forge Modded server");
LOGGER.info("");
LOGGER.info(ansi().a(" Github: ").fgBrightBlue().a("https://github.com/AllTheMods/ServerStarter"));
LOGGER.info(ansi().a(" Discord: ").fgBrightBlue().a("http://discord.allthepacks.com"));
LOGGER.info("");
LOGGER.info(ansi().a("You are playing ").fgGreen().a(config.modpack.name));
LOGGER.info("Starting to install/launch the server, lean back!");
LOGGER.info(ansi().fgRed().a("::::::::::::::::::::::::::::::::::::::::::::::::::::"));
LOGGER.info("");


if (!InternetChecker.checkConnection() && config.launch.checkOffline) {
LOGGER.error("Problems with the Internet connection, shutting down.");
return;
}

ForgeManager forgeManager = new ForgeManager(config);
ForgeManager forgeManager = new ForgeManager(config);


if (lockFile.checkShouldInstall(config) || installOnly) {
IPackType packtype = TypeFactory.createPackType(config.install.modpackFormat, config);
if (packtype == null) {
LOGGER.error("Unknown pack format given in config");
return;
}
if (lockFile.checkShouldInstall(config) || installOnly) {
IPackType packtype = TypeFactory.createPackType(config.install.modpackFormat, config);
if (packtype == null) {
LOGGER.error("Unknown pack format given in config");
return;
}

packtype.installPack();
lockFile.packInstalled = true;
lockFile.packUrl = config.install.modpackUrl;
saveLockFile(lockFile);
packtype.installPack();
lockFile.packInstalled = true;
lockFile.packUrl = config.install.modpackUrl;
saveLockFile(lockFile);


if (config.install.installForge) {
String forgeVersion = packtype.getForgeVersion();
String mcVersion = packtype.getMCVersion();
forgeManager.installForge(config.install.baseInstallPath, forgeVersion, mcVersion);
}
if (config.install.installForge) {
String forgeVersion = packtype.getForgeVersion();
String mcVersion = packtype.getMCVersion();
forgeManager.installForge(config.install.baseInstallPath, forgeVersion, mcVersion);
}


FileManager filemanger = new FileManager(config);
filemanger.installAdditionalFiles();
filemanger.installLocalFiles();
FileManager filemanger = new FileManager(config);
filemanger.installAdditionalFiles();
filemanger.installLocalFiles();


} else {
LOGGER.info("Server is already installed to correct version, to force install delete the serverstarter.lock File.");
}
} else {
LOGGER.info("Server is already installed to correct version, to force install delete the serverstarter.lock File.");
}

if (installOnly) {
LOGGER.info("Install only mod, exiting now.");
return;
}
if (installOnly) {
LOGGER.info("Install only mod, exiting now.");
return;
}

forgeManager.handleServer();
forgeManager.handleServer();
} catch (Throwable e) {
LOGGER.error("Some uncaught error happened.", e);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import lombok.ToString;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;

import java.io.*;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -181,8 +182,11 @@ private void unzipFile(File downloadedPack, List<PathMatcher> patterns) throws I
if (!name.endsWith("/")) {
File outfile = new File(basePath + path);
LOGGER.info("Copying zip entry to = " + outfile, true);

//noinspection ResultOfMethodCallIgnored
new File(outfile.getParent()).mkdirs();
String parent = outfile.getParent();
if (parent != null)
new File(parent).mkdirs();

try (FileOutputStream fos = new FileOutputStream(outfile)) {
int len;
Expand Down

0 comments on commit 25c416f

Please sign in to comment.