@@ -335,16 +335,10 @@ private Map.Entry<Command, Map.Entry<Method, Object>> getAssociatedCommand(@NotN
335
335
final String name = cmd .name ();
336
336
337
337
if (name .equalsIgnoreCase (commandName ) || Stream .of (cmd .aliases ()).anyMatch (commandName ::equalsIgnoreCase )) {
338
- command = cmd ;
339
- break ;
338
+ return Utils .mapEntry (cmd , commands .get (cmd ));
340
339
}
341
340
}
342
341
343
- // If we found the command return it, otherwise return null
344
- if (command != null ) {
345
- return Utils .mapEntry (command , commands .get (command ));
346
- }
347
-
348
342
// Return null if the given command is not registered by Command Framework
349
343
return null ;
350
344
}
@@ -485,34 +479,22 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.comm
485
479
486
480
@ Nullable
487
481
private Map .Entry <Completer , Map .Entry <Method , Object >> getAssociatedCompleter (@ NotNull String commandName , @ NotNull String [] possibleArgs ) {
488
- Completer completer = null ;
489
-
490
482
for (Completer comp : subCommandCompletions .keySet ()) {
491
483
final String name = comp .name (), cmdName = commandName + (possibleArgs .length == 0 ? "" : "." + String .join ("." , Arrays .copyOfRange (possibleArgs , 0 , name .split ("\\ ." ).length - 1 )));
492
484
493
485
if (name .equalsIgnoreCase (cmdName ) || Stream .of (comp .aliases ()).anyMatch (target -> target .equalsIgnoreCase (cmdName ) || target .equalsIgnoreCase (commandName ))) {
494
- completer = comp ;
495
- break ;
486
+ return Utils .mapEntry (comp , subCommandCompletions .get (comp ));
496
487
}
497
488
}
498
489
499
- if (completer != null ) {
500
- return Utils .mapEntry (completer , subCommandCompletions .get (completer ));
501
- }
502
-
503
490
for (Completer comp : commandCompletions .keySet ()) {
504
491
final String name = comp .name ();
505
492
506
493
if (name .equalsIgnoreCase (commandName ) || Stream .of (comp .aliases ()).anyMatch (commandName ::equalsIgnoreCase )) {
507
- completer = comp ;
508
- break ;
494
+ return Utils .mapEntry (comp , commandCompletions .get (comp ));
509
495
}
510
496
}
511
497
512
- if (completer != null ) {
513
- return Utils .mapEntry (completer , commandCompletions .get (completer ));
514
- }
515
-
516
498
return null ;
517
499
}
518
500
0 commit comments