mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-15 08:28:10 +02:00
Fix PermissionUtil/npe (ensure a Permission instance is present).
This commit is contained in:
parent
1db8b695bb
commit
c0eceb9473
@ -121,7 +121,7 @@ public class PermissionUtil {
|
|||||||
}
|
}
|
||||||
// Set the permission for the command.
|
// Set the permission for the command.
|
||||||
String cmdPermName = command.getPermission();
|
String cmdPermName = command.getPermission();
|
||||||
boolean cmdHadPerm;
|
final boolean cmdHadPerm;
|
||||||
if (cmdPermName == null) {
|
if (cmdPermName == null) {
|
||||||
// Set a permission.
|
// Set a permission.
|
||||||
cmdPermName = permissionBase + "." + lcLabel;
|
cmdPermName = permissionBase + "." + lcLabel;
|
||||||
@ -133,23 +133,21 @@ public class PermissionUtil {
|
|||||||
}
|
}
|
||||||
// Set permission default behavior.
|
// Set permission default behavior.
|
||||||
Permission cmdPerm = pm.getPermission(cmdPermName);
|
Permission cmdPerm = pm.getPermission(cmdPermName);
|
||||||
if (cmdPerm == null) {
|
final boolean permRegistered = cmdPerm != null;
|
||||||
|
if (!permRegistered) {
|
||||||
|
cmdPerm = new Permission(cmdPermName);
|
||||||
if (!cmdHadPerm) {
|
if (!cmdHadPerm) {
|
||||||
cmdPerm = new Permission(cmdPermName);
|
// NCP added the permission, allow root.
|
||||||
cmdPerm.addParent(rootPerm, true);
|
cmdPerm.addParent(rootPerm, true);
|
||||||
pm.addPermission(cmdPerm);
|
} // else: permission was present, but not registered.
|
||||||
}
|
pm.addPermission(cmdPerm);
|
||||||
}
|
}
|
||||||
// Create change history entry.
|
// Create change history entry.
|
||||||
if (cmdHadPerm) {
|
if (cmdHadPerm && permRegistered) {
|
||||||
if (cmdPerm == null) {
|
changed.add(new CommandProtectionEntry(command, lcLabel, cmdPermName, cmdPerm.getDefault(), command.getPermissionMessage()));
|
||||||
changed.add(new CommandProtectionEntry(command, lcLabel, cmdPermName, null, command.getPermissionMessage()));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
changed.add(new CommandProtectionEntry(command, lcLabel, cmdPermName, cmdPerm.getDefault(), command.getPermissionMessage()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// (New Permission instances will not be touched on restore.)
|
||||||
changed.add(new CommandProtectionEntry(command, lcLabel, null, null, command.getPermissionMessage()));
|
changed.add(new CommandProtectionEntry(command, lcLabel, null, null, command.getPermissionMessage()));
|
||||||
}
|
}
|
||||||
// Change
|
// Change
|
||||||
|
Loading…
Reference in New Issue
Block a user