Add IPermissionsHandler#getGroups to fetch all groups

This commit is contained in:
Josh Roy 2021-08-06 13:57:42 -04:00 committed by MD
parent 939e5c5a55
commit e6af246170
4 changed files with 23 additions and 0 deletions

View File

@ -14,6 +14,8 @@ public interface IPermissionsHandler {
List<String> getGroups(Player base); List<String> getGroups(Player base);
List<String> getGroups();
boolean canBuild(Player base, String group); boolean canBuild(Player base, String group);
boolean inGroup(Player base, String group); boolean inGroup(Player base, String group);

View File

@ -55,6 +55,17 @@ public class PermissionsHandler implements IPermissionsHandler {
return Collections.unmodifiableList(groups); return Collections.unmodifiableList(groups);
} }
@Override
public List<String> getGroups() {
final long start = System.nanoTime();
List<String> groups = handler.getGroups();
if (groups == null || groups.isEmpty()) {
groups = Collections.singletonList(defaultGroup);
}
checkPermLag(start, "Getting all groups");
return Collections.unmodifiableList(groups);
}
@Override @Override
public boolean canBuild(final Player base, final String group) { public boolean canBuild(final Player base, final String group) {
return handler.canBuild(base, group); return handler.canBuild(base, group);

View File

@ -41,6 +41,11 @@ public abstract class AbstractVaultHandler extends SuperpermsHandler {
return Arrays.asList(perms.getPlayerGroups(base)); return Arrays.asList(perms.getPlayerGroups(base));
} }
@Override
public List<String> getGroups() {
return Arrays.asList(perms.getGroups());
}
@Override @Override
public boolean inGroup(final Player base, final String group) { public boolean inGroup(final Player base, final String group) {
return perms.playerInGroup(base, group); return perms.playerInGroup(base, group);

View File

@ -30,6 +30,11 @@ public class SuperpermsHandler implements IPermissionsHandler {
return null; return null;
} }
@Override
public List<String> getGroups() {
return null;
}
@Override @Override
public boolean canBuild(final Player base, final String group) { public boolean canBuild(final Player base, final String group) {
return hasPermission(base, "essentials.build"); return hasPermission(base, "essentials.build");