diff --git a/fml/conf/patches/Start.java b/fml/conf/patches/Start.java index 77d92b13c..ef08ff60b 100644 --- a/fml/conf/patches/Start.java +++ b/fml/conf/patches/Start.java @@ -5,75 +5,110 @@ import java.lang.reflect.Field; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; +import java.util.Arrays; + +import joptsimple.ArgumentAcceptingOptionSpec; +import joptsimple.OptionParser; +import joptsimple.OptionSet; import net.minecraft.client.Minecraft; +import net.minecraft.client.main.Main; public class Start { - public static void main(String[] args) + public static void main(String[] args) throws Exception + { + int userIndex = -1; + int passIndex = -1; + int sessIndex = -1; + int versIndex = -1; + + for( int x = 0; x < args.length; x++) + { + if (args[x].equals("--username")) userIndex = x + 1; + else if (args[x].equals("--password")) passIndex = x + 1; + else if (args[x].equals("--session")) sessIndex = x + 1; + else if (args[x].equals("--version")) versIndex = x + 1; + } + + if (userIndex != 0-1 && passIndex != -1 && sessIndex == -1) + { + String[] session = getSession(args[userIndex], args[passIndex]); + if (session != null) + { + args[userIndex] = session[0]; + args = concat(args, new String[]{"--session", session[1]}); + } + } + + //Kill the password if its there so it isn't printed to the console. + if (passIndex != -1) + { + args[passIndex-1] = "no_password_for_joo"; + args[passIndex] = "no_password_for_joo"; + } + + if (versIndex == -1) + { + args = concat(args, new String[]{ "--version", "fml_mcp" }); + } + + Main.main(args); + } + + private static String[] getSession(String username, String password) throws UnsupportedEncodingException + { + String parameters = "http://login.minecraft.net/?user=" + URLEncoder.encode(username, "UTF-8") + + "&password=" + URLEncoder.encode(password, "UTF-8") + + "&version=" + 13; + String result = openUrl(parameters); + + if (result == null) + { + System.out.println("Can't connect to minecraft.net"); + return null; + } + + if (!result.contains(":")) + { + System.out.println("Login Failed: " + result); + return null; + } + String[] values = result.split(":"); + return new String[]{ values[2].trim(), values[3].trim() }; + } + + private static String openUrl(String addr) { try { - Field f = Minecraft.class.getDeclaredField("field_71463_am"); - Field.setAccessible(new Field[] { f }, true); - f.set(null, new File(".")); - } - catch (Exception e) - { - e.printStackTrace(); - return; - } - if (args.length != 2) - { - Minecraft.main(args); - } - else - { - try { - String parameters = "http://login.minecraft.net/?user=" + URLEncoder.encode(args[0], "UTF-8") + - "&password=" + URLEncoder.encode(args[1], "UTF-8") + - "&version=" + 13; - String result = openUrl(parameters); - - if (result == null) - { - System.out.println("Can't connect to minecraft.net"); - return; - } - - if (!result.contains(":")) - { - System.out.println("Login Failed: " + result); - return; - } - //latestVersion, downloadTicket, userName, sessionId - String[] values = result.split(":"); - Minecraft.main(new String[]{values[2].trim(), values[3].trim()}); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - private static String openUrl(String addr) - { - try { URL url = new URL(addr); java.io.InputStream is; is = url.openConnection().getInputStream(); - java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(is)); String buf = ""; String line = null; - while((line = reader.readLine() ) != null) + + while ((line = reader.readLine()) != null) { - buf += "\n" + line; + buf += "\n" + line; } + reader.close(); return buf; - } catch (IOException e) { + } + catch (IOException e) + { e.printStackTrace(); } + return null; } + + private static T[] concat(T[] first, T[] second) + { + T[] result = Arrays.copyOf(first, first.length + second.length); + System.arraycopy(second, 0, result, first.length, second.length); + return result; + } } \ No newline at end of file diff --git a/fml/eclipse-workspace-dev.zip b/fml/eclipse-workspace-dev.zip index 7fa77305b..3264b8032 100644 Binary files a/fml/eclipse-workspace-dev.zip and b/fml/eclipse-workspace-dev.zip differ diff --git a/fml/install/eclipse/Minecraft/.classpath b/fml/install/eclipse/Minecraft/.classpath index 58c6bbd0f..0eb8509ac 100644 --- a/fml/install/eclipse/Minecraft/.classpath +++ b/fml/install/eclipse/Minecraft/.classpath @@ -20,17 +20,17 @@ - + - + - + diff --git a/fml/install/eclipse/Minecraft/.project b/fml/install/eclipse/Minecraft/.project index 06690cb49..b8e6ba212 100644 --- a/fml/install/eclipse/Minecraft/.project +++ b/fml/install/eclipse/Minecraft/.project @@ -30,6 +30,11 @@ 2 MCP_LOC/lib + + natives + 2 + MCP_LOC/jars/libraries/natives +