Match negative priorities and fix PEX weight migration

This commit is contained in:
Luck 2016-08-30 11:04:34 +01:00
parent ba10b1c06e
commit a217727bb4
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 8 additions and 10 deletions

View File

@ -128,11 +128,9 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
int groupCount = 0;
for (PermissionGroup group : manager.getGroupList()) {
int groupWeight = group.getWeight() * -1;
groupCount ++;
if (group.getWeight() > maxGroupWeight) {
maxGroupWeight = group.getWeight();
}
maxGroupWeight = Math.max(maxGroupWeight, groupWeight);
final String name = group.getName().toLowerCase();
plugin.getDatastore().createAndLoadGroup(name);
@ -232,10 +230,10 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
if (prefix != null && !prefix.equals("")) {
prefix = ArgumentChecker.escapeCharacters(prefix);
try {
lpGroup.setPermission("prefix." + group.getWeight() + "." + prefix, true);
lpGroup.setPermission("prefix." + groupWeight + "." + prefix, true);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpGroup).action("set prefix." + group.getWeight() + "." + prefix + " true")
.acted(lpGroup).action("set prefix." + groupWeight + "." + prefix + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
@ -247,10 +245,10 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
if (suffix != null && !suffix.equals("")) {
suffix = ArgumentChecker.escapeCharacters(suffix);
try {
lpGroup.setPermission("suffix." + group.getWeight() + "." + suffix, true);
lpGroup.setPermission("suffix." + groupWeight + "." + suffix, true);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpGroup).action("set suffix." + group.getWeight() + "." + suffix + " true")
.acted(lpGroup).action("set suffix." + groupWeight + "." + suffix + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {

View File

@ -38,8 +38,8 @@ import java.util.stream.Collectors;
@ToString
@EqualsAndHashCode
public class Node implements me.lucko.luckperms.api.Node {
private static final Pattern PREFIX_PATTERN = Pattern.compile("(?i)prefix\\.\\d+\\..*");
private static final Pattern SUFFIX_PATTERN = Pattern.compile("(?i)suffix\\.\\d+\\..*");
private static final Pattern PREFIX_PATTERN = Pattern.compile("(?i)prefix\\.-?\\d+\\..*");
private static final Pattern SUFFIX_PATTERN = Pattern.compile("(?i)suffix\\.-?\\d+\\..*");
public static me.lucko.luckperms.api.Node fromSerialisedNode(String s, Boolean b) {
return builderFromSerialisedNode(s, b).build();