mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-01-15 21:01:34 +01:00
Pre-compile patterns, add two new commands, check args before doing DB lookup, and limit group names slightly
This commit is contained in:
parent
d5a6a4261d
commit
42322ef932
@ -59,6 +59,7 @@ Users with OP have access to all commands.
|
||||
| /perms user <user> getuuid | Shows the users Mojang UUID | luckperms.user.getuuid |
|
||||
| /perms user <user> listnodes | Lists all of the permission nodes the user has | luckperms.user.listnodes |
|
||||
| /perms user <user> haspermission <node> [server] | Checks if the user has a permission on a certain server | luckperms.user.haspermission |
|
||||
| /perms user <user> inheritspermission <node> [server] | Checks if the user inherits a permission on a certain server. (This checks all parent groups unlike haspermission) | luckperms.user.inheritspermission |
|
||||
| /perms user <user> set <node> <true/false> [server]| Sets a permission for the user | luckperms.user.setpermission |
|
||||
| /perms user <user> unset <node> [server] | Unsets a permission for the user | luckperms.user.unsetpermission |
|
||||
| /perms user <user> addgroup <group> [server] | Adds the user to a group | luckperms.user.addgroup |
|
||||
@ -71,6 +72,7 @@ Users with OP have access to all commands.
|
||||
| /perms group <group> info | Shows info about the group | luckperms.group.info |
|
||||
| /perms group <group> listnodes | Lists all of the permission nodes the group has | luckperms.group.listnodes |
|
||||
| /perms group <group> haspermission <node> [server] | Checks if the group has a permission on a certain server | luckperms.group.haspermission |
|
||||
| /perms group <group> inheritspermission <node> [server] | Checks if the group inherits a permission on a certain server. (This checks all parent groups unlike haspermission) | luckperms.group.inheritspermission |
|
||||
| /perms group <group> set <node> <true/false> [server]| Sets a permission for the group | luckperms.group.setpermission |
|
||||
| /perms group <group> unset <node> [server] | Unsets a permission for the group | luckperms.group.unsetpermission |
|
||||
| /perms group <group> setinherit <group> [server]| Sets the group to inherit all permissions from another group | luckperms.group.setinherit |
|
||||
|
@ -40,11 +40,11 @@ public class BukkitUser extends User {
|
||||
}
|
||||
|
||||
// Clear existing permissions
|
||||
attachment.getPermissions().keySet().stream().forEach(p -> attachment.setPermission(p, false));
|
||||
attachment.getPermissions().keySet().forEach(p -> attachment.setPermission(p, false));
|
||||
|
||||
// Re-add all defined permissions for the user
|
||||
Map<String, Boolean> local = getLocalPermissions(getPlugin().getConfiguration().getServer(), null);
|
||||
local.entrySet().stream().forEach(e -> attachment.setPermission(e.getKey(), e.getValue()));
|
||||
local.entrySet().forEach(e -> attachment.setPermission(e.getKey(), e.getValue()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -29,10 +29,10 @@ public class BungeeUser extends User {
|
||||
|
||||
// Clear existing permissions
|
||||
Collection<String> perms = new ArrayList<>(player.getPermissions());
|
||||
perms.stream().forEach(p -> player.setPermission(p, false));
|
||||
perms.forEach(p -> player.setPermission(p, false));
|
||||
|
||||
// Re-add all defined permissions for the user
|
||||
Map<String, Boolean> local = getLocalPermissions(getPlugin().getConfiguration().getServer(), null);
|
||||
local.entrySet().stream().forEach(e -> player.setPermission(e.getKey(), e.getValue()));
|
||||
local.entrySet().forEach(e -> player.setPermission(e.getKey(), e.getValue()));
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ public class CommandManager {
|
||||
userCommand.registerSubCommand(new UserGetUUIDCommand());
|
||||
userCommand.registerSubCommand(new UserHasPermCommand());
|
||||
userCommand.registerSubCommand(new UserInfoCommand());
|
||||
userCommand.registerSubCommand(new UserInheritsPermCommand());
|
||||
userCommand.registerSubCommand(new UserListNodesCommand());
|
||||
userCommand.registerSubCommand(new UserRemoveGroupCommand());
|
||||
userCommand.registerSubCommand(new UserSetPermissionCommand());
|
||||
@ -46,6 +47,7 @@ public class CommandManager {
|
||||
groupCommand.registerSubCommand(new GroupClearCommand());
|
||||
groupCommand.registerSubCommand(new GroupHasPermCommand());
|
||||
groupCommand.registerSubCommand(new GroupInfoCommand());
|
||||
groupCommand.registerSubCommand(new GroupInheritsPermCommand());
|
||||
groupCommand.registerSubCommand(new GroupListNodesCommand());
|
||||
groupCommand.registerSubCommand(new GroupSetInheritCommand());
|
||||
groupCommand.registerSubCommand(new GroupSetPermissionCommand());
|
||||
|
@ -6,6 +6,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.utils.Patterns;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -23,6 +24,17 @@ public class CreateGroupCommand extends MainCommand {
|
||||
}
|
||||
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
|
||||
if (groupName.length() > 36) {
|
||||
Message.GROUP_NAME_TOO_LONG.send(sender, groupName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Patterns.NON_ALPHA_NUMERIC.matcher(groupName).find()) {
|
||||
Message.GROUP_INVALID_ENTRY.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getDatastore().loadGroup(groupName, success -> {
|
||||
if (success) {
|
||||
Message.GROUP_ALREADY_EXISTS.send(sender);
|
||||
|
@ -44,6 +44,11 @@ public class GroupMainCommand extends MainCommand {
|
||||
strippedArgs.addAll(args.subList(2, args.size()));
|
||||
}
|
||||
|
||||
if (sub.isArgLengthInvalid(strippedArgs.size())) {
|
||||
sub.sendUsage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
final String groupName = args.get(0).toLowerCase();
|
||||
plugin.getDatastore().loadGroup(groupName, success -> {
|
||||
if (!success) {
|
||||
@ -57,11 +62,6 @@ public class GroupMainCommand extends MainCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sub.isArgLengthInvalid(strippedArgs.size())) {
|
||||
sub.sendUsage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
sub.execute(plugin, sender, group, strippedArgs);
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
package me.lucko.luckperms.commands.group.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.group.GroupSubCommand;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GroupInheritsPermCommand extends GroupSubCommand {
|
||||
public GroupInheritsPermCommand() {
|
||||
super("inheritspermission", "Checks to see if a group inherits a certain permission node",
|
||||
"/perms group <group> inheritspermission <node> [server]", Permission.GROUP_INHERITSPERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
|
||||
if (args.size() == 2) {
|
||||
Util.sendBoolean(sender, args.get(0), group.inheritsPermission(args.get(0), true, args.get(1).toLowerCase()));
|
||||
} else {
|
||||
Util.sendBoolean(sender, args.get(0), group.inheritsPermission(args.get(0), true));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isArgLengthInvalid(int argLength) {
|
||||
return argLength != 1 && argLength != 2;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.utils.Patterns;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -19,14 +20,14 @@ public class GroupSetPermissionCommand extends GroupSubCommand {
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
|
||||
String node = args.get(0);
|
||||
String bool = args.get(1);
|
||||
String bool = args.get(1).toLowerCase();
|
||||
|
||||
if (node.contains("/")) {
|
||||
sendUsage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.matches("group\\..*")) {
|
||||
if (Patterns.GROUP_MATCH.matcher(node).matches()) {
|
||||
Message.GROUP_USE_INHERIT.send(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksPermissionException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.utils.Patterns;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -25,7 +26,7 @@ public class GroupUnSetPermissionCommand extends GroupSubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.matches("group\\..*")) {
|
||||
if (Patterns.GROUP_MATCH.matcher(node).matches()) {
|
||||
Message.GROUP_USE_UNINHERIT.send(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -47,6 +47,11 @@ public class UserMainCommand extends MainCommand{
|
||||
strippedArgs.addAll(args.subList(2, args.size()));
|
||||
}
|
||||
|
||||
if (sub.isArgLengthInvalid(strippedArgs.size())) {
|
||||
sub.sendUsage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
final String user = args.get(0);
|
||||
UUID u = Util.parseUuid(user);
|
||||
if (u != null) {
|
||||
@ -82,11 +87,6 @@ public class UserMainCommand extends MainCommand{
|
||||
Message.USER_NOT_FOUND.send(sender);
|
||||
}
|
||||
|
||||
if (command.isArgLengthInvalid(strippedArgs.size())) {
|
||||
command.sendUsage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
command.execute(plugin, sender, user, strippedArgs);
|
||||
plugin.getUserManager().cleanupUser(user);
|
||||
});
|
||||
|
@ -0,0 +1,31 @@
|
||||
package me.lucko.luckperms.commands.user.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.user.UserSubCommand;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UserInheritsPermCommand extends UserSubCommand {
|
||||
public UserInheritsPermCommand() {
|
||||
super("inheritspermission", "Checks to see if a user inherits a certain permission node",
|
||||
"/perms user <user> inheritspermission <node> [server]", Permission.USER_INHERITSPERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
|
||||
if (args.size() >= 2) {
|
||||
Util.sendBoolean(sender, args.get(0), user.inheritsPermission(args.get(0), true, args.get(1)));
|
||||
} else {
|
||||
Util.sendBoolean(sender, args.get(0), user.inheritsPermission(args.get(0), true));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isArgLengthInvalid(int argLength) {
|
||||
return argLength != 1 && argLength != 2;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.users.User;
|
||||
import me.lucko.luckperms.utils.Patterns;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -19,14 +20,14 @@ public class UserSetPermissionCommand extends UserSubCommand {
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
|
||||
String node = args.get(0);
|
||||
String bool = args.get(1);
|
||||
String bool = args.get(1).toLowerCase();
|
||||
|
||||
if (node.contains("/")) {
|
||||
sendUsage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.matches("group\\..*")) {
|
||||
if (Patterns.GROUP_MATCH.matcher(node).matches()) {
|
||||
Message.USER_USE_ADDGROUP.send(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksPermissionException;
|
||||
import me.lucko.luckperms.users.User;
|
||||
import me.lucko.luckperms.utils.Patterns;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -25,7 +26,7 @@ public class UserUnSetPermissionCommand extends UserSubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.matches("group\\..*")) {
|
||||
if (Patterns.GROUP_MATCH.matcher(node).matches()) {
|
||||
Message.USER_USE_REMOVEGROUP.send(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ public enum Message {
|
||||
USER_NOT_MEMBER_OF("%s is not a member of '%s'.", true),
|
||||
USER_USE_ADDGROUP("Use the addgroup command instead of specifying the node.", true),
|
||||
USER_USE_REMOVEGROUP("Use the removegroup command instead of specifying the node.", true),
|
||||
USER_INVALID_ENTRY("&d%s&c is not a valid username/uuid.", true),
|
||||
|
||||
GROUP_NOT_FOUND("&eGroup could not be found.", true),
|
||||
GROUP_SAVE_SUCCESS("&7(Group data was saved to the datastore)", true),
|
||||
@ -33,13 +34,14 @@ public enum Message {
|
||||
GROUP_DOES_NOT_INHERIT("%s does not inherit '%s'.", true),
|
||||
GROUP_USE_INHERIT("Use the setinherit command instead of specifying the node.", true),
|
||||
GROUP_USE_UNINHERIT("Use the unsetinherit command instead of specifying the node.", true),
|
||||
GROUP_INVALID_ENTRY("Group names can only contain alphanumeric charcters.", true),
|
||||
|
||||
|
||||
USER_ATTEMPTING_LOOKUP("&7(Attempting UUID lookup, since you specified a user)", true),
|
||||
USER_INVALID_ENTRY("&d%s&c is not a valid username/uuid.", true),
|
||||
|
||||
GROUP_ALREADY_EXISTS("That group already exists!", true),
|
||||
GROUP_DOES_NOT_EXIST("That group does not exist!", true),
|
||||
GROUP_NAME_TOO_LONG("Group name '%s' exceeds the maximum length of 36 characters.", true),
|
||||
|
||||
GROUP_LOAD_ERROR("An unexpected error occurred. Group not loaded.", true),
|
||||
GROUPS_LOAD_ERROR("An unexpected error occurred. Unable to load all groups.", true),
|
||||
|
@ -20,6 +20,7 @@ public enum Permission {
|
||||
USER_GETUUID("getuuid", PermissionGroup.USER),
|
||||
USER_LISTNODES("listnodes", PermissionGroup.USER),
|
||||
USER_HASPERMISSION("haspermission", PermissionGroup.USER),
|
||||
USER_INHERITSPERMISSION("inheritspermission", PermissionGroup.USER),
|
||||
USER_SETPERMISSION("setpermission", PermissionGroup.USER),
|
||||
USER_UNSETPERMISSION("unsetpermission", PermissionGroup.USER),
|
||||
USER_ADDGROUP("addgroup", PermissionGroup.USER),
|
||||
@ -30,6 +31,7 @@ public enum Permission {
|
||||
GROUP_INFO("info", PermissionGroup.GROUP),
|
||||
GROUP_LISTNODES("listnodes", PermissionGroup.GROUP),
|
||||
GROUP_HASPERMISSION("haspermission", PermissionGroup.GROUP),
|
||||
GROUP_INHERITSPERMISSION("inheritspermission", PermissionGroup.GROUP),
|
||||
GROUP_SETPERMISSION("setpermission", PermissionGroup.GROUP),
|
||||
GROUP_UNSETPERMISSION("unsetpermission", PermissionGroup.GROUP),
|
||||
GROUP_SETINHERIT("setinherit", PermissionGroup.GROUP),
|
||||
|
@ -6,6 +6,7 @@ import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksPermissionException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.utils.Patterns;
|
||||
import me.lucko.luckperms.utils.PermissionObject;
|
||||
|
||||
import java.util.*;
|
||||
@ -186,7 +187,7 @@ public abstract class User extends PermissionObject {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parts[1].matches("group\\..*")) {
|
||||
if (Patterns.GROUP_MATCH.matcher(parts[1]).matches()) {
|
||||
// SERVER SPECIFIC AND GROUP
|
||||
serverSpecificGroups.put(node.getKey(), node.getValue());
|
||||
continue;
|
||||
@ -198,7 +199,7 @@ public abstract class User extends PermissionObject {
|
||||
// Skip adding global permissions if they are not requested
|
||||
if (!includeGlobal) continue;
|
||||
|
||||
if (node.getKey().matches("group\\..*")) {
|
||||
if (Patterns.GROUP_MATCH.matcher(node.getKey()).matches()) {
|
||||
// GROUP
|
||||
groupNodes.put(node.getKey(), node.getValue());
|
||||
}
|
||||
@ -208,11 +209,19 @@ public abstract class User extends PermissionObject {
|
||||
// If a group is negated at a higher priority, the group should not then be applied at a lower priority
|
||||
serverSpecificGroups.entrySet().stream().filter(node -> !node.getValue()).forEach(node -> {
|
||||
groupNodes.remove(node.getKey());
|
||||
groupNodes.remove(node.getKey().split("\\/", 2)[1]);
|
||||
groupNodes.remove(Patterns.SERVER_SPLIT.split(node.getKey(), 2)[1]);
|
||||
});
|
||||
|
||||
groups.addAll(serverSpecificGroups.entrySet().stream().filter(Map.Entry::getValue).map(e -> e.getKey().split("\\.", 2)[1]).collect(Collectors.toList()));
|
||||
groups.addAll(groupNodes.entrySet().stream().filter(Map.Entry::getValue).map(e -> e.getKey().split("\\.", 2)[1]).collect(Collectors.toList()));
|
||||
groups.addAll(serverSpecificGroups.entrySet().stream()
|
||||
.filter(Map.Entry::getValue)
|
||||
.map(e -> Patterns.SERVER_SPLIT.split(e.getKey(), 2)[1])
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
groups.addAll(groupNodes.entrySet().stream()
|
||||
.filter(Map.Entry::getValue)
|
||||
.map(e -> Patterns.SERVER_SPLIT.split(e.getKey(), 2)[1])
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
return groups;
|
||||
}
|
||||
|
||||
|
14
common/src/main/java/me/lucko/luckperms/utils/Patterns.java
Normal file
14
common/src/main/java/me/lucko/luckperms/utils/Patterns.java
Normal file
@ -0,0 +1,14 @@
|
||||
package me.lucko.luckperms.utils;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Patterns {
|
||||
|
||||
public static final Pattern SERVER_SPLIT = Pattern.compile("\\/");
|
||||
public static final Pattern DOT_SPLIT = Pattern.compile("\\.");
|
||||
public static final Pattern GROUP_MATCH = Pattern.compile("group\\..*");
|
||||
public static final Pattern NON_ALPHA_NUMERIC = Pattern.compile("[^A-Za-z0-9]");
|
||||
|
||||
private Patterns() {}
|
||||
|
||||
}
|
@ -70,6 +70,34 @@ public abstract class PermissionObject {
|
||||
return hasPermission(server + "/" + node, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the object inherits a certain permission
|
||||
* @param node The permission node
|
||||
* @param b If the node is true/false(negated)
|
||||
* @return true if the user inherits the permission
|
||||
*/
|
||||
public boolean inheritsPermission(String node, Boolean b) {
|
||||
if (node.contains("/")) {
|
||||
// Use other method
|
||||
final String[] parts = Patterns.SERVER_SPLIT.split(node, 2);
|
||||
return inheritsPermission(parts[1], b, parts[0]);
|
||||
}
|
||||
|
||||
return inheritsPermission(node, b, "global");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see the the object inherits a permission on a certain server
|
||||
* @param node The permission node
|
||||
* @param b If the node is true/false(negated)
|
||||
* @param server The server
|
||||
* @return true if the user inherits the permission
|
||||
*/
|
||||
public boolean inheritsPermission(String node, Boolean b, String server) {
|
||||
final Map<String, Boolean> local = getLocalPermissions(server, null);
|
||||
return b ? local.containsKey(node) && local.get(node) : local.containsKey(node) && !local.get(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a permission for the object
|
||||
* @param node The node to be set
|
||||
@ -126,7 +154,6 @@ public abstract class PermissionObject {
|
||||
*/
|
||||
public Map<String, Boolean> getLocalPermissions(String server, List<String> excludedGroups) {
|
||||
return getPermissions(server, excludedGroups, includeGlobalPermissions);
|
||||
|
||||
}
|
||||
|
||||
private Map<String, Boolean> getPermissions(String server, List<String> excludedGroups, boolean includeGlobal) {
|
||||
@ -159,7 +186,7 @@ public abstract class PermissionObject {
|
||||
for (Map.Entry<String, Boolean> node : getNodes().entrySet()) {
|
||||
serverSpecific:
|
||||
if (node.getKey().contains("/")) {
|
||||
String[] parts = node.getKey().split("\\/", 2);
|
||||
String[] parts = Patterns.SERVER_SPLIT.split(node.getKey(), 2);
|
||||
|
||||
if (parts[0].equalsIgnoreCase("global")) {
|
||||
// REGULAR
|
||||
@ -171,7 +198,7 @@ public abstract class PermissionObject {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parts[1].matches("group\\..*")) {
|
||||
if (Patterns.GROUP_MATCH.matcher(parts[1]).matches()) {
|
||||
// SERVER SPECIFIC AND GROUP
|
||||
serverSpecificGroups.put(node.getKey(), node.getValue());
|
||||
continue;
|
||||
@ -185,7 +212,7 @@ public abstract class PermissionObject {
|
||||
// Skip adding global permissions if they are not requested
|
||||
if (!includeGlobal) continue;
|
||||
|
||||
if (node.getKey().matches("group\\..*")) {
|
||||
if (Patterns.GROUP_MATCH.matcher(node.getKey()).matches()) {
|
||||
// GROUP
|
||||
groupNodes.put(node.getKey(), node.getValue());
|
||||
continue;
|
||||
@ -198,7 +225,7 @@ public abstract class PermissionObject {
|
||||
// If a group is negated at a higher priority, the group should not then be applied at a lower priority
|
||||
serverSpecificGroups.entrySet().stream().filter(node -> !node.getValue()).forEach(node -> {
|
||||
groupNodes.remove(node.getKey());
|
||||
groupNodes.remove(node.getKey().split("\\/", 2)[1]);
|
||||
groupNodes.remove(Patterns.SERVER_SPLIT.split(node.getKey(), 2)[1]);
|
||||
});
|
||||
|
||||
// Apply lowest priority: groupNodes
|
||||
@ -210,7 +237,7 @@ public abstract class PermissionObject {
|
||||
// Don't add negated groups
|
||||
if (!groupNode.getValue()) continue;
|
||||
|
||||
String groupName = groupNode.getKey().split("\\.", 2)[1];
|
||||
String groupName = Patterns.DOT_SPLIT.split(groupNode.getKey(), 2)[1];
|
||||
if (!excludedGroups.contains(groupName)) {
|
||||
Group group = plugin.getGroupManager().getGroup(groupName);
|
||||
if (group != null) {
|
||||
@ -224,7 +251,7 @@ public abstract class PermissionObject {
|
||||
|
||||
// Apply next priority: serverSpecificGroups
|
||||
for (Map.Entry<String, Boolean> groupNode : serverSpecificGroups.entrySet()) {
|
||||
final String rawNode = groupNode.getKey().split("\\/")[1];
|
||||
final String rawNode = Patterns.SERVER_SPLIT.split(groupNode.getKey())[1];
|
||||
|
||||
// Add the actual group perm node, so other plugins can hook
|
||||
perms.put(rawNode, groupNode.getValue());
|
||||
@ -232,7 +259,7 @@ public abstract class PermissionObject {
|
||||
// Don't add negated groups
|
||||
if (!groupNode.getValue()) continue;
|
||||
|
||||
String groupName = rawNode.split("\\.", 2)[1];
|
||||
String groupName = Patterns.DOT_SPLIT.split(rawNode, 2)[1];
|
||||
if (!excludedGroups.contains(groupName)) {
|
||||
Group group = plugin.getGroupManager().getGroup(groupName);
|
||||
if (group != null) {
|
||||
@ -249,7 +276,7 @@ public abstract class PermissionObject {
|
||||
|
||||
// Apply highest priority: serverSpecificNodes
|
||||
for (Map.Entry<String, Boolean> node : serverSpecificNodes.entrySet()) {
|
||||
final String rawNode = node.getKey().split("\\/")[1];
|
||||
final String rawNode = Patterns.SERVER_SPLIT.split(node.getKey())[1];
|
||||
perms.put(rawNode, node.getValue());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user