mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-23 00:21:26 +01:00
Merge remote-tracking branch 'origin/groupmanager'
This commit is contained in:
commit
f73a5d0e8d
@ -156,4 +156,11 @@ v 1.9:
|
||||
- Auto rename all case sensitive world folders to lower case (if possible).
|
||||
- Update GlobalGroups.yml for new/changed Towny permission nodes.
|
||||
- Stop attempting to push empty permissions when players edit the yml's incorrectly.
|
||||
- Catch errors caused by bad indentation in yml's.
|
||||
- Catch errors caused by bad indentation in yml's.
|
||||
- Force remove player attachments on disconnect, and tidyup during player join in case of any errors. Fixes a bug of losing permissions.
|
||||
- Added a new permission node 'groupmanager.op'. This will cause players with this node to be treated as op's when
|
||||
using GroupManager commands (they will still require each commands permission node to use them).
|
||||
- Prevent Null entries in group inheritance from throwing errors.
|
||||
v 2.0:
|
||||
- Fix GM reporting of permission inheritance to retain the correct order. Lower inheritance groups can no longer negate a higher groups permissions.
|
||||
- Fix an error I caused trying to modify an unmodifiable list when parsing '*' permissions.
|
@ -303,7 +303,7 @@ public class GroupManager extends JavaPlugin {
|
||||
senderPlayer = (Player) sender;
|
||||
senderUser = worldsHolder.getWorldData(senderPlayer).getUser(senderPlayer.getName());
|
||||
senderGroup = senderUser.getGroup();
|
||||
isOpOverride = (isOpOverride && senderPlayer.isOp());
|
||||
isOpOverride = (isOpOverride && (senderPlayer.isOp() || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager.op")));
|
||||
|
||||
System.out.println("[PLAYER_COMMAND] " + senderPlayer.getName() + ": /" + commandLabel + " " + Tasks.join(args, " "));
|
||||
if (isOpOverride || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager." + cmd.getName())) {
|
||||
|
@ -563,10 +563,12 @@ public class WorldDataHolder {
|
||||
List<String> inheritedList = inheritance.get(groupKey);
|
||||
Group thisGroup = ph.getGroup(groupKey);
|
||||
for (String inheritedKey : inheritedList) {
|
||||
Group inheritedGroup = ph.getGroup(inheritedKey);
|
||||
if (thisGroup != null && inheritedGroup != null) {
|
||||
thisGroup.addInherits(inheritedGroup);
|
||||
}
|
||||
if (inheritedKey != null) {
|
||||
Group inheritedGroup = ph.getGroup(inheritedKey);
|
||||
if (thisGroup != null && inheritedGroup != null) {
|
||||
thisGroup.addInherits(inheritedGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||
// Perm doesn't already exists and there is no negation for it
|
||||
// or It's a negated perm where a normal perm doesn't exists (don't allow inheritance to negate higher perms)
|
||||
if ((!negated && !playerPermArray.contains(perm) && !playerPermArray.contains("-" + perm))
|
||||
|| (negated && !playerPermArray.contains(perm.substring(1))))
|
||||
|| (negated && !playerPermArray.contains(perm.substring(1)) && !playerPermArray.contains("-" + perm)))
|
||||
playerPermArray.add(perm);
|
||||
}
|
||||
}
|
||||
@ -155,8 +155,10 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||
return playerPermArray;
|
||||
}
|
||||
|
||||
private Set<String> populatePerms (List<String> perms, boolean includeChildren) {
|
||||
private Set<String> populatePerms (List<String> permsList, boolean includeChildren) {
|
||||
|
||||
// Create a new array so it's modifiable.
|
||||
List<String> perms = new ArrayList<String>(permsList);
|
||||
Set<String> permArray = new HashSet<String>();
|
||||
Boolean allPerms = false;
|
||||
|
||||
@ -164,20 +166,17 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||
if (perms.contains("*")) {
|
||||
permArray.addAll(GroupManager.BukkitPermissions.getAllRegisteredPermissions(includeChildren));
|
||||
allPerms = true;
|
||||
perms.remove("*");
|
||||
}
|
||||
|
||||
for (String perm : perms) {
|
||||
|
||||
if (!perm.equalsIgnoreCase("*")) {
|
||||
|
||||
|
||||
/**
|
||||
* all permission sets are passed here pre-sorted, alphabetically.
|
||||
* This means negated nodes will be processed before all permissions
|
||||
* other than *.
|
||||
*/
|
||||
boolean negated = false;
|
||||
if (perm.startsWith("-"))
|
||||
negated = true;
|
||||
boolean negated = perm.startsWith("-");
|
||||
|
||||
if (!permArray.contains(perm)) {
|
||||
permArray.add(perm);
|
||||
@ -195,15 +194,16 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||
Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren((negated ? perm.substring(1) : perm), new HashSet<String>());
|
||||
|
||||
if (children != null) {
|
||||
if (negated || (negated && allPerms)) {
|
||||
if (negated)
|
||||
if (allPerms) {
|
||||
|
||||
// Remove children of negated nodes
|
||||
for (String child : children.keySet())
|
||||
if (children.get(child))
|
||||
if (permArray.contains(child))
|
||||
permArray.remove(child);
|
||||
// Remove children of negated nodes
|
||||
for (String child : children.keySet())
|
||||
if (children.get(child))
|
||||
if (permArray.contains(child))
|
||||
permArray.remove(child);
|
||||
|
||||
} else if (!negated){
|
||||
} else {
|
||||
|
||||
// Add child nodes
|
||||
for (String child : children.keySet())
|
||||
@ -214,7 +214,6 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return permArray;
|
||||
@ -959,7 +958,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||
for (String sonName : now.getInherits()) {
|
||||
Group son = ph.getGroup(sonName);
|
||||
if (son != null && !alreadyVisited.contains(son)) {
|
||||
stack.push(son);
|
||||
// Add rather than push to retain inheritance order.
|
||||
stack.add(son);
|
||||
alreadyVisited.add(son);
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.permissions.Permission;
|
||||
@ -342,6 +343,18 @@ public class BukkitPermissions {
|
||||
if (player != null)
|
||||
this.updatePermissions(player, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force remove any attachments
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
private void removeAttachment(Player player) {
|
||||
if (attachments.containsKey(player)) {
|
||||
player.removeAttachment(attachments.get(player));
|
||||
attachments.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Player events tracked to cause Superperms updates
|
||||
@ -355,6 +368,12 @@ public class BukkitPermissions {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
setPlayer_join(true);
|
||||
Player player = event.getPlayer();
|
||||
|
||||
/*
|
||||
* Tidy up any lose ends
|
||||
*/
|
||||
removeAttachment(player);
|
||||
|
||||
// force GM to create the player if they are not already listed.
|
||||
if (plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(player.getName()) != null) {
|
||||
setPlayer_join(false);
|
||||
@ -370,7 +389,25 @@ public class BukkitPermissions {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
attachments.remove(event.getPlayer());
|
||||
Player player = event.getPlayer();
|
||||
|
||||
/*
|
||||
* force remove any attachments as bukkit may not
|
||||
*/
|
||||
removeAttachment(player);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (!GroupManager.isLoaded())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
/*
|
||||
* force remove any attachments as bukkit may not
|
||||
*/
|
||||
removeAttachment(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,4 +163,9 @@ commands:
|
||||
manclear:
|
||||
description: Clear world selection. Next commands will work on your world.
|
||||
usage: /<command>
|
||||
permissions: groupmanager.manclear
|
||||
permissions: groupmanager.manclear
|
||||
|
||||
Permissions:
|
||||
groupmanager.op:
|
||||
description: User is treated as an op when using the GroupManager commands.
|
||||
default: false
|
Loading…
Reference in New Issue
Block a user