mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-19 23:28:59 +01:00
#1035 Fix handling of new login command constraints
- Incorporate ConfigMe fix - Various fixes in the integration
This commit is contained in:
parent
8dbba1dc93
commit
3c0236e15e
2
pom.xml
2
pom.xml
@ -709,7 +709,7 @@
|
||||
<dependency>
|
||||
<groupId>ch.jalu</groupId>
|
||||
<artifactId>configme</artifactId>
|
||||
<version>0.4</version>
|
||||
<version>0.4.1</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
<exclusions>
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
/**
|
||||
* Test for {@link CommandManager}.
|
||||
*/
|
||||
// TODO #1035: Tests currently fail because ConfigMe can't handle Optional fields
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CommandManagerTest {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user