diff options
author | snowleo <schneeleo@gmail.com> | 2012-04-05 17:05:43 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2012-04-05 17:05:43 +0200 |
commit | f73a5d0e8d370c1273685533b44ce526d9d8cdef (patch) | |
tree | 64f106d2442f8b84a8ff14b5fdf056a581d2dc24 /EssentialsGroupManager/src | |
parent | aa437030945a59a0cbfe7d940f36135e40072b30 (diff) | |
parent | f7bc04bc347c088d35ee5a939c026f28b2ce0c19 (diff) | |
download | Essentials-f73a5d0e8d370c1273685533b44ce526d9d8cdef.tar Essentials-f73a5d0e8d370c1273685533b44ce526d9d8cdef.tar.gz Essentials-f73a5d0e8d370c1273685533b44ce526d9d8cdef.tar.lz Essentials-f73a5d0e8d370c1273685533b44ce526d9d8cdef.tar.xz Essentials-f73a5d0e8d370c1273685533b44ce526d9d8cdef.zip |
Merge remote-tracking branch 'origin/groupmanager'
Diffstat (limited to 'EssentialsGroupManager/src')
6 files changed, 76 insertions, 25 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index c57b050c3..c5fe5564d 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -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.
\ No newline at end of file + - 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.
\ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index 09ea3b247..8bd346735 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -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())) { diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java index d7f146438..cee2ec0b8 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -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); + } + } } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java index 6b6ae58ea..b40694bb0 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java @@ -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); } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index dc08168dc..5c711351e 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -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);
}
}
diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml index bf42a08c3..f7faa5896 100644 --- a/EssentialsGroupManager/src/plugin.yml +++ b/EssentialsGroupManager/src/plugin.yml @@ -163,4 +163,9 @@ commands: manclear: description: Clear world selection. Next commands will work on your world. usage: /<command> - permissions: groupmanager.manclear
\ No newline at end of file + permissions: groupmanager.manclear + +Permissions: + groupmanager.op: + description: User is treated as an op when using the GroupManager commands. + default: false
\ No newline at end of file |