Send brigadier permissions to bukkit command manager
This commit is contained in:
parent
e8a1a9a6cf
commit
d3ed876df6
5 changed files with 29 additions and 6 deletions
|
|
@ -222,6 +222,9 @@ public abstract class CommandManager<C> {
|
|||
* @return {@code true} if the sender has the permission, else {@code false}
|
||||
*/
|
||||
public boolean hasPermission(@Nonnull final C sender, @Nonnull final CommandPermission permission) {
|
||||
if (permission.toString().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (permission instanceof Permission) {
|
||||
return hasPermission(sender, permission.toString());
|
||||
}
|
||||
|
|
@ -233,7 +236,7 @@ public abstract class CommandManager<C> {
|
|||
}
|
||||
}
|
||||
}
|
||||
return !(permission instanceof OrPermission);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import javax.annotation.Nonnull;
|
|||
class CommandPermissionTest {
|
||||
|
||||
private final static CommandManager<TestCommandSender> manager = new PermissionOutputtingCommandManager();
|
||||
private static boolean acceptOne = false;
|
||||
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
|
|
@ -46,7 +47,9 @@ class CommandPermissionTest {
|
|||
|
||||
@Test
|
||||
void testCompoundPermission() {
|
||||
Assertions.assertTrue(manager.suggest(new TestCommandSender(), "").isEmpty());
|
||||
Assertions.assertTrue(manager.suggest(new TestCommandSender(), "t").isEmpty());
|
||||
acceptOne = true;
|
||||
Assertions.assertFalse(manager.suggest(new TestCommandSender(), "t").isEmpty());
|
||||
}
|
||||
|
||||
private static final class PermissionOutputtingCommandManager extends CommandManager<TestCommandSender> {
|
||||
|
|
@ -58,7 +61,7 @@ class CommandPermissionTest {
|
|||
@Override
|
||||
public boolean hasPermission(@Nonnull final TestCommandSender sender,
|
||||
@Nonnull final String permission) {
|
||||
return false;
|
||||
return acceptOne && permission.equalsIgnoreCase("test.permission.four");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue