mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-06 14:46:32 +02:00
Fixed GM to recognize Superperm child nodes.
If you add a node like Towny.admin GM will now correctly report on all child nodes.
This commit is contained in:
@@ -51,4 +51,6 @@ v 1.4:
|
|||||||
- Added data.save.hours setting to config. This allow control over how long backups are retained.
|
- Added data.save.hours setting to config. This allow control over how long backups are retained.
|
||||||
v 1.5:
|
v 1.5:
|
||||||
- Fixed opOverrides and bukkit_perms_override to read the correct entries.
|
- Fixed opOverrides and bukkit_perms_override to read the correct entries.
|
||||||
- Better commenting in config.yml
|
- Better commenting in config.yml
|
||||||
|
- Fixed GM to recognize Superperm child nodes.
|
||||||
|
If you add a node like Towny.admin GM will now correctly report on all child nodes.
|
@@ -763,6 +763,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
permissionResult = permissionHandler.checkFullUserPermission(auxUser, args[1]);
|
permissionResult = permissionHandler.checkFullUserPermission(auxUser, args[1]);
|
||||||
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) {
|
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) {
|
||||||
sender.sendMessage(ChatColor.RED + "The player doesn't have access to that permission");
|
sender.sendMessage(ChatColor.RED + "The player doesn't have access to that permission");
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "SuperPerms reports Node: " + targetPlayer.hasPermission(args[1]));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//PARECE OK
|
//PARECE OK
|
||||||
|
@@ -7,6 +7,7 @@ package org.anjocaido.groupmanager.permissions;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import org.anjocaido.groupmanager.GroupManager;
|
import org.anjocaido.groupmanager.GroupManager;
|
||||||
import org.anjocaido.groupmanager.data.Group;
|
import org.anjocaido.groupmanager.data.Group;
|
||||||
@@ -14,6 +15,7 @@ import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
|
|||||||
import org.anjocaido.groupmanager.data.User;
|
import org.anjocaido.groupmanager.data.User;
|
||||||
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
||||||
import org.anjocaido.groupmanager.utils.PermissionCheckResult.Type;
|
import org.anjocaido.groupmanager.utils.PermissionCheckResult.Type;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,8 +95,19 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
|
|
||||||
for (String group : getGroups(userName)) {
|
for (String group : getGroups(userName)) {
|
||||||
for (String perm : ph.getGroup(group).getPermissionList()) {
|
for (String perm : ph.getGroup(group).getPermissionList()) {
|
||||||
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm)))
|
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm))) {
|
||||||
playerPermArray.add(perm);
|
playerPermArray.add(perm);
|
||||||
|
|
||||||
|
Map<String, Boolean> children = GroupManager.BukkitPermissions.getChildren(perm);
|
||||||
|
if (children != null) {
|
||||||
|
for (String child : children.keySet()) {
|
||||||
|
if (children.get(child))
|
||||||
|
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm)))
|
||||||
|
playerPermArray.add(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,6 +579,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
|| result.resultType.equals(PermissionCheckResult.Type.FOUND)) {
|
|| result.resultType.equals(PermissionCheckResult.Type.FOUND)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (Bukkit.getPlayer(user.getName()).hasPermission(permission))
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,7 +603,6 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
PermissionCheckResult resultUser = checkUserOnlyPermission(user, targetPermission);
|
PermissionCheckResult resultUser = checkUserOnlyPermission(user, targetPermission);
|
||||||
if (!resultUser.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) {
|
if (!resultUser.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) {
|
||||||
return resultUser;
|
return resultUser;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//IT ONLY CHECKS GROUPS PERMISSIONS IF RESULT FOR USER IS NOT FOUND
|
//IT ONLY CHECKS GROUPS PERMISSIONS IF RESULT FOR USER IS NOT FOUND
|
||||||
@@ -603,6 +618,12 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
return resultSubGroup;
|
return resultSubGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Bukkit.getPlayer(user.getName()).hasPermission(targetPermission)) {
|
||||||
|
result.resultType = PermissionCheckResult.Type.FOUND;
|
||||||
|
result.owner = user;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//THEN IT RETURNS A NOT FOUND
|
//THEN IT RETURNS A NOT FOUND
|
||||||
return result;
|
return result;
|
||||||
|
@@ -150,8 +150,19 @@ public class BukkitPermissions {
|
|||||||
value = true;
|
value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == true)
|
if (value == true){
|
||||||
|
// Set the root permission
|
||||||
attachment.setPermission(permission, value);
|
attachment.setPermission(permission, value);
|
||||||
|
// fetch and set all children of this permission node
|
||||||
|
Map<String, Boolean> children = permission.getChildren();
|
||||||
|
if (children != null) {
|
||||||
|
for (String child : children.keySet()) {
|
||||||
|
if (children.get(child))
|
||||||
|
attachment.setPermission(child, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add any missing permissions for this player (non bukkit plugins)
|
// Add any missing permissions for this player (non bukkit plugins)
|
||||||
@@ -171,6 +182,22 @@ public class BukkitPermissions {
|
|||||||
player.recalculatePermissions();
|
player.recalculatePermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a map of the child permissions as defined by the supplying plugin
|
||||||
|
* null is empty
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Map<String, Boolean> getChildren(String node) {
|
||||||
|
for (Permission permission : registeredPermissions) {
|
||||||
|
if (permission.getName() == node) {
|
||||||
|
return permission.getChildren();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> listPerms(Player player) {
|
public List<String> listPerms(Player player) {
|
||||||
List<String> perms = new ArrayList<String>();
|
List<String> perms = new ArrayList<String>();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user