@@ -32,57 +32,6 @@ public TaskRun(Side side, MCP instance) {
3232 super (side , instance );
3333 }
3434
35- @ Override
36- protected Stage [] setStages () {
37- return new Stage [] {
38- stage (getLocalizedStage ("run" ), 0 , () -> {
39- Version currentVersion = mcp .getCurrentVersion ();
40- Side mcpSide = mcp .getOptions ().side ;
41- if (mcpSide == Side .ANY ) {
42- mcpSide = side ;
43- }
44-
45- String main = getMain (mcp , currentVersion , side );
46- if (main == null ) {
47- mcp .log ("Start class not found" );
48- return ;
49- }
50- mcp .log ("Using main class: " + main );
51-
52- boolean runBuild = mcp .getOptions ().getBooleanParameter (TaskParameter .RUN_BUILD );
53- boolean fullBuild = mcp .getOptions ().getBooleanParameter (TaskParameter .FULL_BUILD );
54- String [] runArgs = mcp .getOptions ().getStringArrayParameter (TaskParameter .RUN_ARGS );
55- List <Path > cpList = getClasspath (mcp , mcpSide , side , runBuild , fullBuild );
56-
57- List <String > classPath = new ArrayList <>();
58- cpList .forEach (p -> classPath .add (p .toAbsolutePath ().toString ()));
59-
60- Path natives = MCPPaths .get (mcp , NATIVES ).toAbsolutePath ();
61-
62- List <String > args = new ArrayList <>();
63- args .add (Util .getJava ());
64- String cpString = String .join (File .pathSeparator , classPath );
65- for (String s : getJvmArgs (mcp , mcpSide )) {
66- args .add (s .replace ("${classpath}" , cpString )
67- .replace ("${natives_directory}" , natives .toAbsolutePath ().toString ())
68- .replace ("${launcher_name}" , "RetroMCP" )
69- .replace ("${launcher_version}" , MCP .VERSION ));
70- }
71- Collections .addAll (args , runArgs );
72- args .add (main );
73- if (side == Side .CLIENT ) {
74- List <String > gameArgs = new ArrayList <>(getLaunchArgs (mcp , mcpSide ));
75- Collections .addAll (gameArgs , mcp .getOptions ().getStringParameter (TaskParameter .GAME_ARGS ).split (" " ));
76- args .addAll (gameArgs );
77- }
78- mcp .log ("Launch arguments: " + String .join (", " , args ));
79- // mcp.log("Classpath:\n" + String.join("\n", classPath));
80-
81- Util .runCommand (args .toArray (new String [0 ]), MCPPaths .get (mcp , GAMEDIR , side ), true );
82- })
83- };
84- }
85-
8635 public static String getMain (MCP mcp , Version version , Side side ) throws IOException {
8736 if (side == Side .CLIENT ) {
8837 return version .mainClass ;
@@ -109,16 +58,14 @@ private static List<String> getStringArguments(List<Object> objects) {
10958 for (Object o : objects ) {
11059 if (o instanceof String ) {
11160 argsList .add ((String ) o );
112- }
113- else if (o instanceof Argument ) {
114- Argument arg = (Argument )o ;
115- if (Rule .apply (arg .rules )) {
116- if (arg .value instanceof String ) {
117- argsList .add ((String )arg .value );
118- }
119- else if (arg .value instanceof JSONArray ) {
120- JSONArray arr = (JSONArray )arg .value ;
121- for (int i = 0 ; i < arr .length (); i ++) {
61+ } else if (o instanceof Argument ) {
62+ Argument arg = (Argument ) o ;
63+ if (Rule .apply (arg .rules )) {
64+ if (arg .value instanceof String ) {
65+ argsList .add ((String ) arg .value );
66+ } else if (arg .value instanceof JSONArray ) {
67+ JSONArray arr = (JSONArray ) arg .value ;
68+ for (int i = 0 ; i < arr .length (); i ++) {
12269 argsList .add (arr .getString (i ));
12370 }
12471 }
@@ -131,7 +78,7 @@ else if(arg.value instanceof JSONArray) {
13178 public static List <String > getJvmArgs (MCP mcp , Side side ) {
13279 List <String > argsList = new ArrayList <>();
13380 Version ver = mcp .getCurrentVersion ();
134- if (ver .arguments != null ) {
81+ if (ver .arguments != null ) {
13582 argsList .addAll (getStringArguments (ver .arguments .jvm ));
13683 } else {
13784 argsList .add ("-Djava.library.path=${natives_directory}" );
@@ -222,4 +169,55 @@ private static List<Path> getClasspath(MCP mcp, Side side, Side runSide, boolean
222169 }
223170 return cpList ;
224171 }
172+
173+ @ Override
174+ protected Stage [] setStages () {
175+ return new Stage []{
176+ stage (getLocalizedStage ("run" ), 0 , () -> {
177+ Version currentVersion = mcp .getCurrentVersion ();
178+ Side mcpSide = mcp .getOptions ().side ;
179+ if (mcpSide == Side .ANY ) {
180+ mcpSide = side ;
181+ }
182+
183+ String main = getMain (mcp , currentVersion , side );
184+ if (main == null ) {
185+ mcp .log ("Start class not found" );
186+ return ;
187+ }
188+ mcp .log ("Using main class: " + main );
189+
190+ boolean runBuild = mcp .getOptions ().getBooleanParameter (TaskParameter .RUN_BUILD );
191+ boolean fullBuild = mcp .getOptions ().getBooleanParameter (TaskParameter .FULL_BUILD );
192+ String [] runArgs = mcp .getOptions ().getStringArrayParameter (TaskParameter .RUN_ARGS );
193+ List <Path > cpList = getClasspath (mcp , mcpSide , side , runBuild , fullBuild );
194+
195+ List <String > classPath = new ArrayList <>();
196+ cpList .forEach (p -> classPath .add (p .toAbsolutePath ().toString ()));
197+
198+ Path natives = MCPPaths .get (mcp , NATIVES ).toAbsolutePath ();
199+
200+ List <String > args = new ArrayList <>();
201+ args .add (Util .getJava ());
202+ String cpString = String .join (File .pathSeparator , classPath );
203+ for (String s : getJvmArgs (mcp , mcpSide )) {
204+ args .add (s .replace ("${classpath}" , cpString )
205+ .replace ("${natives_directory}" , natives .toAbsolutePath ().toString ())
206+ .replace ("${launcher_name}" , "RetroMCP" )
207+ .replace ("${launcher_version}" , MCP .VERSION ));
208+ }
209+ Collections .addAll (args , runArgs );
210+ args .add (main );
211+ if (side == Side .CLIENT ) {
212+ List <String > gameArgs = new ArrayList <>(getLaunchArgs (mcp , mcpSide ));
213+ Collections .addAll (gameArgs , mcp .getOptions ().getStringParameter (TaskParameter .GAME_ARGS ).split (" " ));
214+ args .addAll (gameArgs );
215+ }
216+ mcp .log ("Launch arguments: " + String .join (", " , args ));
217+ // mcp.log("Classpath:\n" + String.join("\n", classPath));
218+
219+ Util .runCommand (args .toArray (new String [0 ]), MCPPaths .get (mcp , GAMEDIR , side ), true );
220+ })
221+ };
222+ }
225223}
0 commit comments