Identity identity = context.getIdentity();
ObjectMapper mapper = new ObjectMapper();
final File extractDir = createExtractDir();
JavaProcessBuilder builder = new JavaProcessBuilder();
ReleaseManifest manifest = mapper.readValue(
getManifestPath(), ReleaseManifest.class);
String clientToken = identity.getClientToken();
// Add libraries to classpath or extract the libraries as necessary
for (Library library : manifest.getLibraries()) {
File path = new File(getLibrariesDir(), library.getPath(context.getEnvironment()));
if (path.exists()) {
Extract extract = library.getExtract();
if (extract != null) {
ZipExtract zipExtract = new ZipExtract(
new FileResource(path), extractDir);
zipExtract.setExclude(extract.getExclude());
zipExtract.run();
} else {
builder.classPath(path);
}
}
}
// Add arguments for the .jar
String[] args = manifest.getMinecraftArguments().split(" +");
for (String arg : args) {
arg = arg.replace("${version_name}", manifest.getId());
arg = arg.replace("${game_directory}", getProfile().getContentDir().getAbsolutePath());
arg = arg.replace("${game_assets}", getAssetsDir().getAbsolutePath());
arg = arg.replace("${auth_player_name}", identity.getName());
arg = arg.replace("${auth_username}", identity.getName());
arg = arg.replace("${auth_access_token}", identity.getAccessToken());
arg = arg.replace("${auth_session}", clientToken);
builder.getArgs().add(arg);
}
// Mac OS X arguments
if (getEnvironment().getPlatform() == Platform.MAC_OS_X) {
File icnsPath = new File(getAssetsDir(), "icons/minecraft.icns");
builder.getFlags().add("-Xdock:icon=" + icnsPath.getAbsolutePath());
builder.getFlags().add("-Xdock:name=Minecraft");
}
builder.getFlags().add("-Djava.library.path=" + extractDir.getAbsoluteFile());
builder.classPath(getJarPatcher().getExecutedPath());
builder.setMainClass(manifest.getMainClass());
ProcessBuilder processBuilder = new ProcessBuilder(builder.buildCommand());
processBuilder.directory(getProfile().getContentDir());
Process process = processBuilder.start();