mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-19 07:07:55 +01:00
Command with 0 delay should be run immediately
This commit is contained in:
parent
2e5fdb4ca0
commit
b741c0da14
@ -25,8 +25,7 @@ public class Command {
|
||||
* @param executor the executor of the command
|
||||
*/
|
||||
public Command(String command, Executor executor) {
|
||||
this.command = command;
|
||||
this.executor = executor;
|
||||
this(command, executor, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,20 +124,26 @@ public class CommandManager implements Reloadable {
|
||||
}
|
||||
|
||||
private <T extends Command> void executeCommands(Player player, List<T> commands, Predicate<T> predicate) {
|
||||
for (T command : commands) {
|
||||
if (predicate.test(command)) {
|
||||
final String execution = command.getCommand();
|
||||
bukkitService.scheduleSyncDelayedTask(() -> {
|
||||
if (Executor.CONSOLE.equals(command.getExecutor())) {
|
||||
bukkitService.dispatchConsoleCommand(execution);
|
||||
} else {
|
||||
bukkitService.dispatchCommand(player, execution);
|
||||
}
|
||||
}, command.getDelay());
|
||||
for (T cmd : commands) {
|
||||
if (predicate.test(cmd)) {
|
||||
long delay = cmd.getDelay();
|
||||
if (delay > 0) {
|
||||
bukkitService.scheduleSyncDelayedTask(() -> dispatchCommand(player, cmd), delay);
|
||||
} else {
|
||||
dispatchCommand(player, cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dispatchCommand(Player player, Command command) {
|
||||
if (Executor.CONSOLE.equals(command.getExecutor())) {
|
||||
bukkitService.dispatchConsoleCommand(command.getCommand());
|
||||
} else {
|
||||
bukkitService.dispatchCommand(player, command.getCommand());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean shouldCommandBeRun(OnLoginCommand command, int numberOfOtherAccounts) {
|
||||
return (!command.getIfNumberOfAccountsAtLeast().isPresent()
|
||||
|| command.getIfNumberOfAccountsAtLeast().get() <= numberOfOtherAccounts)
|
||||
|
Loading…
Reference in New Issue
Block a user