mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-19 15:17:56 +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
|
* @param executor the executor of the command
|
||||||
*/
|
*/
|
||||||
public Command(String command, Executor executor) {
|
public Command(String command, Executor executor) {
|
||||||
this.command = command;
|
this(command, executor, 0);
|
||||||
this.executor = executor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,20 +124,26 @@ public class CommandManager implements Reloadable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <T extends Command> void executeCommands(Player player, List<T> commands, Predicate<T> predicate) {
|
private <T extends Command> void executeCommands(Player player, List<T> commands, Predicate<T> predicate) {
|
||||||
for (T command : commands) {
|
for (T cmd : commands) {
|
||||||
if (predicate.test(command)) {
|
if (predicate.test(cmd)) {
|
||||||
final String execution = command.getCommand();
|
long delay = cmd.getDelay();
|
||||||
bukkitService.scheduleSyncDelayedTask(() -> {
|
if (delay > 0) {
|
||||||
if (Executor.CONSOLE.equals(command.getExecutor())) {
|
bukkitService.scheduleSyncDelayedTask(() -> dispatchCommand(player, cmd), delay);
|
||||||
bukkitService.dispatchConsoleCommand(execution);
|
} else {
|
||||||
} else {
|
dispatchCommand(player, cmd);
|
||||||
bukkitService.dispatchCommand(player, execution);
|
}
|
||||||
}
|
|
||||||
}, command.getDelay());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
private static boolean shouldCommandBeRun(OnLoginCommand command, int numberOfOtherAccounts) {
|
||||||
return (!command.getIfNumberOfAccountsAtLeast().isPresent()
|
return (!command.getIfNumberOfAccountsAtLeast().isPresent()
|
||||||
|| command.getIfNumberOfAccountsAtLeast().get() <= numberOfOtherAccounts)
|
|| command.getIfNumberOfAccountsAtLeast().get() <= numberOfOtherAccounts)
|
||||||
|
Loading…
Reference in New Issue
Block a user