Merge branch 'develop' into feature_derpstances
This commit is contained in:
commit
d166b48072
@ -22,6 +22,7 @@ import org.simplericity.macify.eawt.DefaultApplication;
|
|||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
public class EntryPoint
|
public class EntryPoint
|
||||||
{
|
{
|
||||||
@ -93,12 +94,21 @@ public class EntryPoint
|
|||||||
|
|
||||||
public int listen()
|
public int listen()
|
||||||
{
|
{
|
||||||
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
|
BufferedReader buffer;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
buffer = new BufferedReader(new InputStreamReader(System.in, "UTF-8"));
|
||||||
|
} catch (UnsupportedEncodingException e)
|
||||||
|
{
|
||||||
|
System.err.println("For some reason, your java does not support UTF-8. Consider living in the current century.");
|
||||||
|
e.printStackTrace();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
boolean isListening = true;
|
boolean isListening = true;
|
||||||
// Main loop
|
// Main loop
|
||||||
while (isListening)
|
while (isListening)
|
||||||
{
|
{
|
||||||
String inData="";
|
String inData;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Read from the pipe one line at a time
|
// Read from the pipe one line at a time
|
||||||
@ -113,11 +123,13 @@ public class EntryPoint
|
|||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
System.err.println("Launcher ABORT due to IO exception:");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
catch (ParseException e)
|
catch (ParseException e)
|
||||||
{
|
{
|
||||||
|
System.err.println("Launcher ABORT due to PARSE exception:");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -16,24 +16,28 @@
|
|||||||
|
|
||||||
package org.multimc;
|
package org.multimc;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
public class Utils
|
public class Utils
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Combine two parts of a path.
|
* Combine two parts of a path.
|
||||||
|
*
|
||||||
* @param path1
|
* @param path1
|
||||||
* @param path2
|
* @param path2
|
||||||
* @return the paths, combined
|
* @return the paths, combined
|
||||||
*/
|
*/
|
||||||
public static String combine (String path1, String path2)
|
public static String combine(String path1, String path2)
|
||||||
{
|
{
|
||||||
File file1 = new File(path1);
|
File file1 = new File(path1);
|
||||||
File file2 = new File(file1, path2);
|
File file2 = new File(file1, path2);
|
||||||
@ -42,15 +46,16 @@ public class Utils
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Join a list of strings into a string using a separator!
|
* Join a list of strings into a string using a separator!
|
||||||
* @param strings the string list to join
|
*
|
||||||
|
* @param strings the string list to join
|
||||||
* @param separator the glue
|
* @param separator the glue
|
||||||
* @return the result.
|
* @return the result.
|
||||||
*/
|
*/
|
||||||
public static String join (List<String> strings, String separator)
|
public static String join(List<String> strings, String separator)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
String sep = "";
|
String sep = "";
|
||||||
for(String s: strings)
|
for (String s : strings)
|
||||||
{
|
{
|
||||||
sb.append(sep).append(s);
|
sb.append(sep).append(s);
|
||||||
sep = separator;
|
sep = separator;
|
||||||
@ -105,7 +110,8 @@ public class Utils
|
|||||||
* @param pathToAdd the path to add
|
* @param pathToAdd the path to add
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Deprecated public static void addLibraryPath(String pathToAdd) throws Exception
|
@Deprecated
|
||||||
|
public static void addLibraryPath(String pathToAdd) throws Exception
|
||||||
{
|
{
|
||||||
final Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths");
|
final Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths");
|
||||||
usrPathsField.setAccessible(true);
|
usrPathsField.setAccessible(true);
|
||||||
@ -154,26 +160,83 @@ public class Utils
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log to the MultiMC console
|
* Log to the MultiMC console
|
||||||
*
|
*
|
||||||
* @param message A String containing the message
|
* @param message A String containing the message
|
||||||
* @param level A String containing the level name. See MinecraftProcess::getLevel()
|
* @param level A String containing the level name. See MinecraftProcess::getLevel()
|
||||||
*/
|
*/
|
||||||
public static void log(String message, String level)
|
public static void log(String message, String level)
|
||||||
{
|
{
|
||||||
// Kinda dirty
|
// Kinda dirty
|
||||||
String tag = "!![" + level + "]!";
|
String tag = "!![" + level + "]!";
|
||||||
System.out.println(tag + message.replace("\n", "\n" + tag));
|
System.out.println(tag + message.replace("\n", "\n" + tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(String message)
|
public static void log(String message)
|
||||||
{
|
{
|
||||||
log(message, "MultiMC");
|
log(message, "MultiMC");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log()
|
public static void log()
|
||||||
{
|
{
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pushes bytes from in to out. Closes both streams no matter what.
|
||||||
|
* @param in the input stream
|
||||||
|
* @param out the output stream
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private static void copyStream(InputStream in, OutputStream out) throws IOException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int len;
|
||||||
|
|
||||||
|
while((len = in.read(buffer)) >= 0)
|
||||||
|
out.write(buffer, 0, len);
|
||||||
|
} finally
|
||||||
|
{
|
||||||
|
in.close();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unzip zip file 'source' into the folder 'targetFolder'
|
||||||
|
* @param source
|
||||||
|
* @param targetFolder
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static void unzip(File source, File targetFolder) throws IOException
|
||||||
|
{
|
||||||
|
ZipFile zip = new ZipFile(source);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Enumeration entries = zip.entries();
|
||||||
|
|
||||||
|
while (entries.hasMoreElements())
|
||||||
|
{
|
||||||
|
ZipEntry entry = (ZipEntry) entries.nextElement();
|
||||||
|
|
||||||
|
File targetFile = new File(targetFolder, entry.getName());
|
||||||
|
if (targetFile.getParentFile() != null)
|
||||||
|
{
|
||||||
|
targetFile.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.isDirectory())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
copyStream(zip.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(targetFile)));
|
||||||
|
}
|
||||||
|
} finally
|
||||||
|
{
|
||||||
|
zip.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package org.multimc.onesix;
|
|||||||
import org.multimc.*;
|
import org.multimc.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -34,6 +35,7 @@ public class OneSixLauncher implements Launcher
|
|||||||
{
|
{
|
||||||
// get and process the launch script params
|
// get and process the launch script params
|
||||||
List<String> libraries;
|
List<String> libraries;
|
||||||
|
List<String> extlibs;
|
||||||
List<String> mcparams;
|
List<String> mcparams;
|
||||||
List<String> mods;
|
List<String> mods;
|
||||||
String mainClass;
|
String mainClass;
|
||||||
@ -43,10 +45,12 @@ public class OneSixLauncher implements Launcher
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
libraries = params.all("cp");
|
libraries = params.all("cp");
|
||||||
|
extlibs = params.all("ext");
|
||||||
mcparams = params.all("param");
|
mcparams = params.all("param");
|
||||||
mainClass = params.first("mainClass");
|
mainClass = params.first("mainClass");
|
||||||
mods = params.allSafe("mods", new ArrayList<String>());
|
mods = params.allSafe("mods", new ArrayList<String>());
|
||||||
natives = params.first("natives");
|
natives = params.first("natives");
|
||||||
|
|
||||||
windowTitle = params.first("windowTitle");
|
windowTitle = params.first("windowTitle");
|
||||||
// windowParams = params.first("windowParams");
|
// windowParams = params.first("windowParams");
|
||||||
} catch (NotFoundException e)
|
} catch (NotFoundException e)
|
||||||
@ -66,23 +70,14 @@ public class OneSixLauncher implements Launcher
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
String property = System.getProperty("os.arch");
|
|
||||||
List<String> allNativePaths = new ArrayList<String>();
|
|
||||||
boolean is_64 = property.equalsIgnoreCase("x86_64") || property.equalsIgnoreCase("amd64");
|
|
||||||
allNativePaths.add(natives);
|
|
||||||
allNativePaths.add(natives + "/" + (is_64 ? "64" : "32"));
|
|
||||||
|
|
||||||
// print the pretty things
|
// print the pretty things
|
||||||
{
|
{
|
||||||
Utils.log("Main Class:");
|
Utils.log("Main Class:");
|
||||||
Utils.log(" " + mainClass);
|
Utils.log(" " + mainClass);
|
||||||
Utils.log();
|
Utils.log();
|
||||||
|
|
||||||
Utils.log("Native paths:");
|
Utils.log("Native path:");
|
||||||
for (String s : allNativePaths)
|
Utils.log(" " + natives);
|
||||||
{
|
|
||||||
Utils.log(" " + s);
|
|
||||||
}
|
|
||||||
Utils.log();
|
Utils.log();
|
||||||
|
|
||||||
Utils.log("Libraries:");
|
Utils.log("Libraries:");
|
||||||
@ -107,11 +102,28 @@ public class OneSixLauncher implements Launcher
|
|||||||
Utils.log();
|
Utils.log();
|
||||||
}
|
}
|
||||||
|
|
||||||
final ClassLoader cl = ClassLoader.getSystemClassLoader();
|
|
||||||
|
|
||||||
// set up the natives path(s).
|
// set up the natives path(s).
|
||||||
String libpath = Utils.join(allNativePaths, String.valueOf(File.pathSeparatorChar));
|
Utils.log("Preparing native libraries...");
|
||||||
System.setProperty("java.library.path", libpath);
|
String property = System.getProperty("os.arch");
|
||||||
|
boolean is_64 = property.equalsIgnoreCase("x86_64") || property.equalsIgnoreCase("amd64");
|
||||||
|
for(String extlib: extlibs)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String cleanlib = extlib.replace("${arch}", is_64 ? "64" : "32");
|
||||||
|
File cleanlibf = new File(cleanlib);
|
||||||
|
Utils.log("Extracting " + cleanlibf.getName());
|
||||||
|
Utils.unzip(cleanlibf, new File(natives));
|
||||||
|
} catch (IOException e)
|
||||||
|
{
|
||||||
|
System.err.println("Failed to extract native library:");
|
||||||
|
e.printStackTrace(System.err);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Utils.log();
|
||||||
|
|
||||||
|
System.setProperty("java.library.path", natives);
|
||||||
Field fieldSysPath;
|
Field fieldSysPath;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -126,6 +138,7 @@ public class OneSixLauncher implements Launcher
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the Minecraft Class.
|
// Get the Minecraft Class.
|
||||||
|
final ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||||
Class<?> mc;
|
Class<?> mc;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -226,6 +226,11 @@ MinecraftProcess *DerpInstance::prepareForLaunch(MojangAccountPtr account)
|
|||||||
}
|
}
|
||||||
QDir natives_dir(PathCombine(instanceRoot(), "natives/"));
|
QDir natives_dir(PathCombine(instanceRoot(), "natives/"));
|
||||||
launchScript += "windowTitle " + windowTitle() + "\n";
|
launchScript += "windowTitle " + windowTitle() + "\n";
|
||||||
|
for(auto native: version->getActiveNativeLibs())
|
||||||
|
{
|
||||||
|
QFileInfo finfo(PathCombine("libraries", native->storagePath()));
|
||||||
|
launchScript += "ext " + finfo.absoluteFilePath() + "\n";
|
||||||
|
}
|
||||||
launchScript += "natives " + natives_dir.absolutePath() + "\n";
|
launchScript += "natives " + natives_dir.absolutePath() + "\n";
|
||||||
launchScript += "launch onesix\n";
|
launchScript += "launch onesix\n";
|
||||||
|
|
||||||
|
@ -349,11 +349,6 @@ void DerpUpdate::prepareForLaunch()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* emitFailed("Could not create the native library folder:\n" + natives_dir_raw +
|
|
||||||
"\nMake sure MultiMC has appropriate permissions and there is enough
|
|
||||||
space "
|
|
||||||
"on the storage device.");
|
|
||||||
*/
|
|
||||||
for (auto lib : version->getActiveNativeLibs())
|
for (auto lib : version->getActiveNativeLibs())
|
||||||
{
|
{
|
||||||
if (!lib->filesExist())
|
if (!lib->filesExist())
|
||||||
@ -372,6 +367,6 @@ void DerpUpdate::prepareForLaunch()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user