mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 12:23:59 +00:00
Merge remote branch 'remotes/ess/groupmanager' into essmaster
This commit is contained in:
commit
8b23f8608d
3 changed files with 16 additions and 84 deletions
|
@ -20,3 +20,5 @@ v 1.1:
|
||||||
- manucheckp also outputs superperms results.
|
- manucheckp also outputs superperms results.
|
||||||
- Removed superperms update on plugins unloading. Unneeded and created undesired lag on shutdown.
|
- Removed superperms update on plugins unloading. Unneeded and created undesired lag on shutdown.
|
||||||
- Added a BukkitPermsUpdateTask to only update superperms once on a load/reload.
|
- Added a BukkitPermsUpdateTask to only update superperms once on a load/reload.
|
||||||
|
- Fix for GM not checking inheritance for known superperms nodes.
|
||||||
|
- Optimized getAllPlayersPermissions and fixed pushing unknown perms to superperms.
|
|
@ -81,73 +81,24 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns All permissions (including inheritance) of player name.
|
* Returns All permissions (including inheritance and sub groups) for the player.
|
||||||
|
*
|
||||||
* @param userName
|
* @param userName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getAllPlayersPermissions(String userName) {
|
public List<String> getAllPlayersPermissions(String userName) {
|
||||||
|
|
||||||
User user = ph.getUser(userName);
|
List<String> playerPermArray = new ArrayList<String>(ph.getUser(userName).getPermissionList());
|
||||||
List<String> playerPermArray = new ArrayList<String>(user.getPermissionList());
|
|
||||||
List<String> playerMainGroupPermArray = new ArrayList<String>(user.getGroup().getPermissionList());
|
|
||||||
List<String> subGroupsPermArray = new ArrayList<String>();
|
|
||||||
List<String> returnPermArray = new ArrayList<String>();
|
|
||||||
|
|
||||||
for (String subGroup : user.subGroupListStringCopy()) {
|
for (String group : getGroups(userName)) {
|
||||||
subGroupsPermArray.addAll(ph.getGroup(subGroup).getPermissionList());
|
for (String perm : ph.getGroup(group).getPermissionList()) {
|
||||||
|
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm)))
|
||||||
|
playerPermArray.add(perm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String permission : subGroupsPermArray) {
|
return playerPermArray;
|
||||||
/*
|
|
||||||
* Add each Negated permission
|
|
||||||
* unless it's being overridden by a higher permission
|
|
||||||
*/
|
|
||||||
if (permission.startsWith("-")
|
|
||||||
&& !playerMainGroupPermArray.contains(permission.substring(1))
|
|
||||||
&& !playerPermArray.contains(permission.substring(1))
|
|
||||||
&& !playerMainGroupPermArray.contains("*")
|
|
||||||
&& !playerPermArray.contains("*")) {
|
|
||||||
if (!returnPermArray.contains(permission)) {
|
|
||||||
returnPermArray.add(permission);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
if (!returnPermArray.contains(permission)
|
|
||||||
&& !playerMainGroupPermArray.contains("-"+permission)
|
|
||||||
&& !playerPermArray.contains("-"+permission)) {
|
|
||||||
returnPermArray.add(permission);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String permission : playerMainGroupPermArray) {
|
|
||||||
/*
|
|
||||||
* Add each Negated permission
|
|
||||||
* unless it's being overridden by a higher permission
|
|
||||||
*/
|
|
||||||
if (permission.startsWith("-")
|
|
||||||
&& !playerPermArray.contains(permission.substring(1))
|
|
||||||
&& !playerMainGroupPermArray.contains("*")
|
|
||||||
&& !playerPermArray.contains("*")) {
|
|
||||||
if (!returnPermArray.contains(permission)) {
|
|
||||||
returnPermArray.add(permission);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
if (!returnPermArray.contains(permission)
|
|
||||||
&& !playerPermArray.contains("-"+permission)) {
|
|
||||||
returnPermArray.add(permission);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String permission : playerPermArray) {
|
|
||||||
/*
|
|
||||||
* Add each permission
|
|
||||||
*/
|
|
||||||
if (!returnPermArray.contains(permission)) {
|
|
||||||
returnPermArray.add(permission);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnPermArray;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,7 +110,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||||
* And verify the player 'MyAdmin', which is Admin, it will return true for both
|
* And verify the player 'MyAdmin', which is Admin, it will return true for both
|
||||||
* Admin or Moderator groups.
|
* Admin or Moderator groups.
|
||||||
*
|
*
|
||||||
* Mas if you haave a player 'MyModerator', which is Moderator,
|
* Mas if you have a player 'MyModerator', which is Moderator,
|
||||||
* it will give false if you pass Admin in group parameter.
|
* it will give false if you pass Admin in group parameter.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
package org.anjocaido.groupmanager.permissions;
|
package org.anjocaido.groupmanager.permissions;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -28,7 +26,6 @@ import java.util.Set;
|
||||||
import org.anjocaido.groupmanager.GroupManager;
|
import org.anjocaido.groupmanager.GroupManager;
|
||||||
import org.anjocaido.groupmanager.data.User;
|
import org.anjocaido.groupmanager.data.User;
|
||||||
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
|
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
|
||||||
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -134,14 +131,9 @@ public class BukkitPermissions {
|
||||||
}
|
}
|
||||||
|
|
||||||
// find matching permissions
|
// find matching permissions
|
||||||
PermissionCheckResult permissionResult;
|
|
||||||
Boolean value;
|
Boolean value;
|
||||||
for (Permission permission : registeredPermissions) {
|
for (Permission permission : registeredPermissions) {
|
||||||
permissionResult = worldData.getPermissionsHandler().checkFullUserPermission(user, permission.getName());
|
value = worldData.getPermissionsHandler().checkUserPermission(user, permission.getName());
|
||||||
if (permissionResult.resultType.equals(PermissionCheckResult.Type.FOUND))
|
|
||||||
value = true;
|
|
||||||
else
|
|
||||||
value = false;
|
|
||||||
|
|
||||||
attachment.setPermission(permission, value);
|
attachment.setPermission(permission, value);
|
||||||
}
|
}
|
||||||
|
@ -161,19 +153,6 @@ public class BukkitPermissions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.recalculatePermissions();
|
player.recalculatePermissions();
|
||||||
|
|
||||||
/*
|
|
||||||
// List perms for this player
|
|
||||||
GroupManager.logger.info("Attachment Permissions:");
|
|
||||||
for(Map.Entry<String, Boolean> entry : attachment.getPermissions().entrySet()){
|
|
||||||
GroupManager.logger.info(" " + entry.getKey() + " = " + entry.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
GroupManager.logger.info("Effective Permissions:");
|
|
||||||
for(PermissionAttachmentInfo info : player.getEffectivePermissions()){
|
|
||||||
GroupManager.logger.info(" " + info.getPermission() + " = " + info.getValue());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> listPerms(Player player) {
|
public List<String> listPerms(Player player) {
|
||||||
|
|
Loading…
Reference in a new issue