#1035 Fix handling of new login command constraints
- Incorporate ConfigMe fix - Various fixes in the integration
This commit is contained in:
@@ -136,9 +136,9 @@ public class CommandManager implements Reloadable {
|
||||
|
||||
private static boolean shouldCommandBeRun(OnLoginCommand command, int numberOfOtherAccounts) {
|
||||
return (!command.getNumberOfOtherAccountsAtLeast().isPresent()
|
||||
|| command.getNumberOfOtherAccountsAtLeast().get() >= numberOfOtherAccounts)
|
||||
|| command.getNumberOfOtherAccountsAtLeast().get() <= numberOfOtherAccounts)
|
||||
&& (!command.getNumberOfOtherAccountsLessThan().isPresent()
|
||||
|| command.getNumberOfOtherAccountsLessThan().get() <= numberOfOtherAccounts);
|
||||
|| command.getNumberOfOtherAccountsLessThan().get() >= numberOfOtherAccounts);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,7 +167,8 @@ public class CommandManager implements Reloadable {
|
||||
Map<String, OnLoginCommand> commands) {
|
||||
|
||||
return new WrappedTagReplacer<>(availableTags, commands.values(), Command::getCommand,
|
||||
(cmd, text) -> new OnLoginCommand(text, cmd.getExecutor()));
|
||||
(cmd, text) -> new OnLoginCommand(text, cmd.getExecutor(), cmd.getNumberOfOtherAccountsAtLeast(),
|
||||
cmd.getNumberOfOtherAccountsLessThan()));
|
||||
}
|
||||
|
||||
private List<Tag<Player>> buildAvailableTags() {
|
||||
|
||||
@@ -26,6 +26,21 @@ public class OnLoginCommand extends Command {
|
||||
super(command, executor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param command the command to execute
|
||||
* @param executor the executor of the command
|
||||
* @param numberOfOtherAccountsAtLeast required number of accounts for the command to run
|
||||
* @param numberOfOtherAccountsLessThan max threshold of accounts, from which the command will not be run
|
||||
*/
|
||||
public OnLoginCommand(String command, Executor executor, Optional<Integer> numberOfOtherAccountsAtLeast,
|
||||
Optional<Integer> numberOfOtherAccountsLessThan) {
|
||||
super(command, executor);
|
||||
this.numberOfOtherAccountsAtLeast = numberOfOtherAccountsAtLeast;
|
||||
this.numberOfOtherAccountsLessThan = numberOfOtherAccountsLessThan;
|
||||
}
|
||||
|
||||
public Optional<Integer> getNumberOfOtherAccountsAtLeast() {
|
||||
return numberOfOtherAccountsAtLeast;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user