@@ -270,30 +270,32 @@ private void readObject(ObjectInputStream stream) throws ClassNotFoundException,
270
270
}
271
271
272
272
@ Override
273
- public final String toParameterString () {
274
- String parameterString = runescapeAccount .get ().toParameterString ();
273
+ public final String [] toParameter () {
274
+
275
+ List <String > parameter = new ArrayList <>();
276
+
277
+ Collections .addAll (parameter , runescapeAccount .get ().toParameter ());
278
+
275
279
if (proxy .get () != null ) {
276
- parameterString += " " + proxy .get ().toParameterString ( );
280
+ Collections . addAll ( parameter , proxy .get ().toParameter () );
277
281
}
278
282
279
283
if (memoryAllocation .get () != -1 ) {
280
- parameterString += " -mem " + memoryAllocation .get ();
284
+ Collections . addAll ( parameter , " -mem" , String . valueOf ( memoryAllocation .get ()) );
281
285
}
282
286
283
287
if (collectData .get ()) {
284
- parameterString += " -data 1" ;
288
+ Collections . addAll ( parameter , " -data" , "1" ) ;
285
289
}
286
290
287
291
if (debugMode .get () && debugPort .get () != -1 ) {
288
- parameterString += " -debug " + debugPort .get ();
292
+ Collections . addAll ( parameter , " -debug" , String . valueOf ( debugPort .get ()) );
289
293
} else {
290
- Optional <Integer > availablePort = getAvailablePort ();
291
- if (availablePort .isPresent ()) {
292
- parameterString += " -debug " + availablePort .get ();
293
- }
294
+ getAvailablePort ().ifPresent (integer -> Collections .addAll (parameter , "-debug" , String .valueOf (integer )));
294
295
}
295
296
296
297
List <String > allowParams = new ArrayList <>();
298
+
297
299
if (lowResourceMode .get ()) {
298
300
allowParams .add ("lowresource" );
299
301
}
@@ -314,7 +316,7 @@ public final String toParameterString() {
314
316
}
315
317
316
318
if (!allowParams .isEmpty ()) {
317
- parameterString += " -allow " + String .join ("," , allowParams );
319
+ Collections . addAll ( parameter , " -allow" , String .join ("," , allowParams ) );
318
320
}
319
321
320
322
int worldVal ;
@@ -325,10 +327,10 @@ public final String toParameterString() {
325
327
}
326
328
327
329
if (worldVal != -1 ) {
328
- parameterString += " -world " + worldVal ;
330
+ Collections . addAll ( parameter , " -world" , String . valueOf ( worldVal )) ;
329
331
}
330
332
331
- return parameterString ;
333
+ return parameter . toArray ( new String [ parameter . size ()]) ;
332
334
}
333
335
334
336
private Optional <Integer > getAvailablePort () {
@@ -451,10 +453,10 @@ public List<List<String>> getCommands(final Bot bot, final OSBotAccount osBotAcc
451
453
for (final Script script : scripts .get ()) {
452
454
List <String > command = new ArrayList <>();
453
455
454
- Collections .addAll (command , bot .toParameterString (). split ( " " ));
455
- Collections .addAll (command , osBotAccount .toParameterString (). split ( " " ));
456
- Collections .addAll (command , this .toParameterString (). split ( " " ));
457
- Collections .addAll (command , script .toParameterString (). split ( " " ));
456
+ Collections .addAll (command , bot .toParameter ( ));
457
+ Collections .addAll (command , osBotAccount .toParameter ( ));
458
+ Collections .addAll (command , this .toParameter ( ));
459
+ Collections .addAll (command , script .toParameter ( ));
458
460
459
461
commands .add (command );
460
462
}
0 commit comments