mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 02:25:41 +01:00
fix: Resolve issue where permission is not registering
This commit is contained in:
parent
a6eea018ac
commit
913618101a
@ -21,15 +21,15 @@ public class PermissionsRegistrar {
|
|||||||
|
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
worldPermissions = new ArrayList<>() {{
|
worldPermissions = new ArrayList<>() {{
|
||||||
worldAccessPermission = new PrefixPermission("multiverse.access.", "Allows access to a world.");
|
add(worldAccessPermission = new PrefixPermission("multiverse.access.", "Allows access to a world."));
|
||||||
worldGamemodeBypassPermission = new PrefixPermission("mv.bypass.gamemode.", "Allows bypassing of gamemode restrictions.", PermissionDefault.FALSE);
|
add(worldGamemodeBypassPermission = new PrefixPermission("mv.bypass.gamemode.", "Allows bypassing of gamemode restrictions.", PermissionDefault.FALSE));
|
||||||
worldExemptPermission = new PrefixPermission("multiverse.exempt.", "A player who has this does not pay to enter this world.");
|
add(worldExemptPermission = new PrefixPermission("multiverse.exempt.", "A player who has this does not pay to enter this world."));
|
||||||
worldPlayerLimitBypassPermission = new PrefixPermission("mv.bypass.playerlimit.", "Allows bypassing of player limit restrictions.");
|
add(worldPlayerLimitBypassPermission = new PrefixPermission("mv.bypass.playerlimit.", "Allows bypassing of player limit restrictions."));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
destinationPermissions = new ArrayList<>() {{
|
destinationPermissions = new ArrayList<>() {{
|
||||||
teleportSelfPermission = new PrefixPermission("multiverse.teleport.self.", "Allows teleporting to a world.");
|
add(teleportSelfPermission = new PrefixPermission("multiverse.teleport.self.", "Allows teleporting to a world."));
|
||||||
teleportOtherPermission = new PrefixPermission("multiverse.teleport.other.", "Allows teleporting other players to a world.");
|
add(teleportOtherPermission = new PrefixPermission("multiverse.teleport.other.", "Allows teleporting other players to a world."));
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,15 +57,15 @@ public class PermissionsRegistrar {
|
|||||||
removeAllPrefixPermissions(destinationPermissions);
|
removeAllPrefixPermissions(destinationPermissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void removePrefixPermissions(List<PrefixPermission> worldPermissions, String name) {
|
private static void registerPrefixPermissionList(List<PrefixPermission> permissions, String permissionSuffix) {
|
||||||
for (PrefixPermission permission : worldPermissions) {
|
for (PrefixPermission permission : permissions) {
|
||||||
permission.removePermission(name);
|
permission.registerPermission(permissionSuffix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerPrefixPermissionList(List<PrefixPermission> permissions, String permissionSuffix) {
|
private static void removePrefixPermissions(List<PrefixPermission> worldPermissions, String name) {
|
||||||
for (PrefixPermission permission : permissions) {
|
for (PrefixPermission permission : worldPermissions) {
|
||||||
permission.registerWildcardPermission();
|
permission.removePermission(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.onarandombox.MultiverseCore.utils.permission;
|
package com.onarandombox.MultiverseCore.utils.permission;
|
||||||
|
|
||||||
|
import com.dumptruckman.minecraft.util.Logging;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.permissions.PermissionDefault;
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
@ -26,9 +27,10 @@ public class PrefixPermission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Permission registerPermission(String permissionSuffix) {
|
public Permission registerPermission(String permissionSuffix) {
|
||||||
String permissionName = permissionPrefix + permissionSuffix;
|
String permissionName = getPermissionName(permissionSuffix);
|
||||||
Permission permission = pluginManager.getPermission(permissionName);
|
Permission permission = pluginManager.getPermission(permissionName);
|
||||||
if (permission != null) {
|
if (permission != null) {
|
||||||
|
Logging.warning("Permission already registered: " + permission.getName());
|
||||||
return permission;
|
return permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,6 +40,9 @@ public class PrefixPermission {
|
|||||||
registerWildcardPermission();
|
registerWildcardPermission();
|
||||||
}
|
}
|
||||||
permission.addParent(wildcardPermission, true);
|
permission.addParent(wildcardPermission, true);
|
||||||
|
pluginManager.recalculatePermissionDefaults(permission);
|
||||||
|
pluginManager.recalculatePermissionDefaults(wildcardPermission);
|
||||||
|
Logging.finest("Registered permission: " + permission.getName());
|
||||||
return permission;
|
return permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +54,7 @@ public class PrefixPermission {
|
|||||||
}
|
}
|
||||||
wildcardPermission = new Permission(permissionName, description, permissionDefault);
|
wildcardPermission = new Permission(permissionName, description, permissionDefault);
|
||||||
pluginManager.addPermission(wildcardPermission);
|
pluginManager.addPermission(wildcardPermission);
|
||||||
|
pluginManager.recalculatePermissionDefaults(wildcardPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removePermission(String permissionSuffix) {
|
public boolean removePermission(String permissionSuffix) {
|
||||||
@ -68,8 +74,10 @@ public class PrefixPermission {
|
|||||||
|
|
||||||
public boolean removeAllPermissions() {
|
public boolean removeAllPermissions() {
|
||||||
try {
|
try {
|
||||||
wildcardPermission.getChildren().forEach((child, value) -> pluginManager.removePermission(child));
|
if (wildcardPermission != null) {
|
||||||
pluginManager.removePermission(wildcardPermission);
|
wildcardPermission.getChildren().forEach((child, value) -> pluginManager.removePermission(child));
|
||||||
|
pluginManager.removePermission(wildcardPermission);
|
||||||
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user