diff --git a/src/main/java/net/neoforged/devlaunch/Main.java b/src/main/java/net/neoforged/devlaunch/Main.java index f1d2240..4a5d705 100644 --- a/src/main/java/net/neoforged/devlaunch/Main.java +++ b/src/main/java/net/neoforged/devlaunch/Main.java @@ -43,22 +43,19 @@ public static void main(String[] args) throws Throwable { throw new IllegalArgumentException("DevLaunch requires at least one argument: the main class."); } - String mainClass = newArgs.get(1); - newArgs.remove(1); - Method mainMethod; try { - mainMethod = Class.forName(mainClass).getMethod("main", String[].class); + mainMethod = Class.forName(newArgs.get(0)).getMethod("main", String[].class); } catch (ReflectiveOperationException e) { - throw new IllegalArgumentException("Could not find main class or main method. Given main class: " + mainClass, e); + throw new IllegalArgumentException("Could not find main class or main method. Given main class: " + newArgs.get(0), e); } try { - mainMethod.invoke(null, (Object) newArgs.toArray(String[]::new)); + mainMethod.invoke(null, (Object) newArgs.subList(1, newArgs.size()).toArray(String[]::new)); } catch (InvocationTargetException e) { throw e.getTargetException(); } catch (ReflectiveOperationException e) { - throw new IllegalArgumentException("Could not invoke main class: " + mainClass, e); + throw new IllegalArgumentException("Could not invoke main class: " + newArgs.get(0), e); } }