File tree 1 file changed +19
-0
lines changed
src/main/java/me/creepermaxcz/mcbots
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -459,14 +459,33 @@ else if (commandName.equalsIgnoreCase("list") || commandName.equalsIgnoreCase("l
459
459
460
460
else if (commandName .equalsIgnoreCase ("leave" ) || commandName .equalsIgnoreCase ("exit" ))
461
461
{
462
+ int limit = -1 ;
463
+ if (split .length >= 2 ) {
464
+ try {
465
+ limit = Integer .parseInt (split [1 ]);
466
+ } catch (NumberFormatException e ) {
467
+ limit = 0 ;
468
+ Log .warn ("Invalid limit." );
469
+ }
470
+ }
471
+
472
+ int i = 0 ;
462
473
if (!controlledBots .isEmpty ()) {
463
474
Log .info ("Disconnecting controlled bots." );
464
475
for (Bot bot : controlledBots ) {
476
+ if (i ++ == limit ) {
477
+ break ;
478
+ }
479
+
465
480
bot .disconnect ();
466
481
}
467
482
} else {
468
483
Log .info ("Disconnecting all bots." );
469
484
for (Bot bot : bots ) {
485
+ if (i ++ == limit ) {
486
+ break ;
487
+ }
488
+
470
489
bot .disconnect ();
471
490
}
472
491
}
You can’t perform that action at this time.
0 commit comments