mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-08-20 18:32:49 +00:00
Fix for pushing perms of non superperms supporting plugins
This commit is contained in:
parent
d3f6e82474
commit
f2dd51cf57
70
EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
Executable file → Normal file
70
EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
Executable file → Normal file
|
@ -79,6 +79,76 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
public String getGroup(String userName) {
|
||||
return ph.getUser(userName).getGroup().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns All permissions (including inheritance) of player name.
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllPlayersPermissions(String userName) {
|
||||
|
||||
User user = ph.getUser(userName);
|
||||
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()) {
|
||||
subGroupsPermArray.addAll(ph.getGroup(subGroup).getPermissionList());
|
||||
}
|
||||
|
||||
for (String permission : subGroupsPermArray) {
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if player is in suck group.
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
|
||||
package org.anjocaido.groupmanager.permissions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -115,11 +117,12 @@ public class BukkitPermissions {
|
|||
world = player.getWorld().getName();
|
||||
}
|
||||
|
||||
// All permissions registered with Bukkit for this player
|
||||
PermissionAttachment attachment = this.attachments.get(player);
|
||||
|
||||
OverloadedWorldHolder worldData = GroupManager.getWorldsHolder().getWorldData(world);
|
||||
|
||||
User user = worldData.getUser(player.getName());
|
||||
User user = worldData.getUser(player.getName());
|
||||
|
||||
// clear permissions
|
||||
for (String permission : attachment.getPermissions().keySet()) {
|
||||
|
@ -127,18 +130,32 @@ public class BukkitPermissions {
|
|||
}
|
||||
|
||||
// find matching permissions
|
||||
PermissionCheckResult permissionResult;
|
||||
Boolean value;
|
||||
for (Permission permission : registeredPermissions) {
|
||||
PermissionCheckResult permissionResult = worldData.getPermissionsHandler().checkFullUserPermission(user, permission.getName());
|
||||
Boolean value = false;
|
||||
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) {
|
||||
value = false;
|
||||
} else if (permissionResult.resultType.equals(PermissionCheckResult.Type.FOUND))
|
||||
permissionResult = worldData.getPermissionsHandler().checkFullUserPermission(user, permission.getName());
|
||||
if (permissionResult.resultType.equals(PermissionCheckResult.Type.FOUND))
|
||||
value = true;
|
||||
|
||||
else
|
||||
value = false;
|
||||
|
||||
attachment.setPermission(permission, value);
|
||||
}
|
||||
}
|
||||
|
||||
// Add any missing permissions for this player (non bukkit plugins)
|
||||
List<String> playerPermArray = new ArrayList<String>(worldData.getPermissionsHandler().getAllPlayersPermissions(player.getName()));
|
||||
|
||||
for (String permission : playerPermArray) {
|
||||
value = true;
|
||||
if (permission.startsWith("-")) {
|
||||
permission = permission.substring(1); // cut off -
|
||||
value = false;
|
||||
}
|
||||
|
||||
if (!attachment.getPermissions().containsKey(permission)) {
|
||||
attachment.setPermission(permission, value);
|
||||
}
|
||||
}
|
||||
player.recalculatePermissions();
|
||||
|
||||
/*
|
||||
|
|
4
EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/PermissionsReaderInterface.java
Executable file → Normal file
4
EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/PermissionsReaderInterface.java
Executable file → Normal file
|
@ -3,6 +3,8 @@ package org.anjocaido.groupmanager.permissions;
|
|||
//import java.util.Collection;
|
||||
//import java.util.Map;
|
||||
//import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
import org.anjocaido.groupmanager.data.Group;
|
||||
//import org.anjocaido.groupmanager.data.User;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -229,4 +231,6 @@ public abstract class PermissionsReaderInterface {
|
|||
|
||||
public abstract void removeGroupInfo(String name, String path);
|
||||
//////////////////////////////
|
||||
|
||||
public abstract List<String> getAllPlayersPermissions(String userName);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue