mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-24 17:47:38 +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>
|
<dependency>
|
||||||
<groupId>ch.jalu</groupId>
|
<groupId>ch.jalu</groupId>
|
||||||
<artifactId>configme</artifactId>
|
<artifactId>configme</artifactId>
|
||||||
<version>0.4</version>
|
<version>0.4.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
|
@ -136,9 +136,9 @@ public class CommandManager implements Reloadable {
|
|||||||
|
|
||||||
private static boolean shouldCommandBeRun(OnLoginCommand command, int numberOfOtherAccounts) {
|
private static boolean shouldCommandBeRun(OnLoginCommand command, int numberOfOtherAccounts) {
|
||||||
return (!command.getNumberOfOtherAccountsAtLeast().isPresent()
|
return (!command.getNumberOfOtherAccountsAtLeast().isPresent()
|
||||||
|| command.getNumberOfOtherAccountsAtLeast().get() >= numberOfOtherAccounts)
|
|| command.getNumberOfOtherAccountsAtLeast().get() <= numberOfOtherAccounts)
|
||||||
&& (!command.getNumberOfOtherAccountsLessThan().isPresent()
|
&& (!command.getNumberOfOtherAccountsLessThan().isPresent()
|
||||||
|| command.getNumberOfOtherAccountsLessThan().get() <= numberOfOtherAccounts);
|
|| command.getNumberOfOtherAccountsLessThan().get() >= numberOfOtherAccounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -167,7 +167,8 @@ public class CommandManager implements Reloadable {
|
|||||||
Map<String, OnLoginCommand> commands) {
|
Map<String, OnLoginCommand> commands) {
|
||||||
|
|
||||||
return new WrappedTagReplacer<>(availableTags, commands.values(), Command::getCommand,
|
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() {
|
private List<Tag<Player>> buildAvailableTags() {
|
||||||
|
@ -26,6 +26,21 @@ public class OnLoginCommand extends Command {
|
|||||||
super(command, executor);
|
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() {
|
public Optional<Integer> getNumberOfOtherAccountsAtLeast() {
|
||||||
return numberOfOtherAccountsAtLeast;
|
return numberOfOtherAccountsAtLeast;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
|||||||
/**
|
/**
|
||||||
* Test for {@link CommandManager}.
|
* Test for {@link CommandManager}.
|
||||||
*/
|
*/
|
||||||
// TODO #1035: Tests currently fail because ConfigMe can't handle Optional fields
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class CommandManagerTest {
|
public class CommandManagerTest {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user