mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-12-25 15:16:02 +00:00
[NOISSUE] Unwrap InvocationTargetException and allow non-public main classes
This commit is contained in:
parent
ff64d2ad59
commit
81b7e5f769
@ -21,6 +21,7 @@ import java.applet.Applet;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -143,12 +144,14 @@ public class OneSixLauncher implements Launcher
|
|||||||
String[] paramsArray = mcparams.toArray(new String[mcparams.size()]);
|
String[] paramsArray = mcparams.toArray(new String[mcparams.size()]);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mc.getMethod("main", String[].class).invoke(null, (Object) paramsArray);
|
Method meth = mc.getMethod("main", String[].class);
|
||||||
|
meth.setAccessible(true);
|
||||||
|
meth.invoke(null, (Object) paramsArray);
|
||||||
return 0;
|
return 0;
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
Utils.log("Failed to invoke the Minecraft main class:", "Fatal");
|
Utils.log("Failed to invoke the Minecraft main class:", "Fatal");
|
||||||
e.printStackTrace(System.err);
|
(e instanceof InvocationTargetException ? e.getCause() : e).printStackTrace(System.err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,7 +198,8 @@ public class OneSixLauncher implements Launcher
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
meth = mc.getMethod("main", String[].class);
|
meth = mc.getMethod("main", String[].class);
|
||||||
} catch (NoSuchMethodException e)
|
meth.setAccessible(true);
|
||||||
|
} catch (NoSuchMethodException | SecurityException e)
|
||||||
{
|
{
|
||||||
System.err.println("Failed to acquire the main method:");
|
System.err.println("Failed to acquire the main method:");
|
||||||
e.printStackTrace(System.err);
|
e.printStackTrace(System.err);
|
||||||
@ -211,7 +215,7 @@ public class OneSixLauncher implements Launcher
|
|||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
System.err.println("Failed to start Minecraft:");
|
System.err.println("Failed to start Minecraft:");
|
||||||
e.printStackTrace(System.err);
|
(e instanceof InvocationTargetException ? e.getCause() : e).printStackTrace(System.err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user