summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager
diff options
context:
space:
mode:
authorElgarL <ElgarL@palmergames.com>2012-02-25 09:22:54 +0000
committerElgarL <ElgarL@palmergames.com>2012-02-25 09:22:54 +0000
commitfa49fc91d2454b2da193ed2b757356b2496d504c (patch)
tree2c0ba8ca41a6d136ce9ab61659900f93d81bb16e /EssentialsGroupManager
parent9c68cbae727f84a7b4dfb2594c458c3353a739d3 (diff)
downloadEssentials-fa49fc91d2454b2da193ed2b757356b2496d504c.tar
Essentials-fa49fc91d2454b2da193ed2b757356b2496d504c.tar.gz
Essentials-fa49fc91d2454b2da193ed2b757356b2496d504c.tar.lz
Essentials-fa49fc91d2454b2da193ed2b757356b2496d504c.tar.xz
Essentials-fa49fc91d2454b2da193ed2b757356b2496d504c.zip
Prevent adding inheritances to globalgroups. These are permissions
collections, not player groups.
Diffstat (limited to 'EssentialsGroupManager')
-rw-r--r--EssentialsGroupManager/src/Changelog.txt3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java10
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java73
3 files changed, 56 insertions, 30 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index cb14c4e6e..bb5cbf550 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -143,4 +143,5 @@ v 1.9:
This also means we no longer update permissions before we change worlds.
- A command of '/manload' with no world arguments now performs a full reload of GM.
- Update for Bukkit R5 compatability.
- - Removed BukkitPermsOverride as this is now the default with bukkit handling child nodes. \ No newline at end of file
+ - Removed BukkitPermsOverride as this is now the default with bukkit handling child nodes.
+ - Prevent adding inheritances to globalgroups. These are permissions collections, not player groups. \ 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 d8d151200..3c39c24d7 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
@@ -1019,6 +1019,11 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "Group 2 does not exists!");
return false;
}
+ if (auxGroup.isGlobal()) {
+ sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support inheritance.");
+ return false;
+ }
+
// VALIDANDO PERMISSAO
if (permissionHandler.searchGroupInInheritance(auxGroup, auxGroup2.getName(), null)) {
sender.sendMessage(ChatColor.RED + "Group " + auxGroup.getName() + " already inherits " + auxGroup2.getName() + " (might not be directly)");
@@ -1052,6 +1057,11 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "Group 2 does not exists!");
return false;
}
+ if (auxGroup.isGlobal()) {
+ sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support inheritance.");
+ return false;
+ }
+
// VALIDANDO PERMISSAO
if (!permissionHandler.searchGroupInInheritance(auxGroup, auxGroup2.getName(), null)) {
sender.sendMessage(ChatColor.RED + "Group " + auxGroup.getName() + " does not inherits " + auxGroup2.getName() + ".");
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
index 5a39600b6..396240ec6 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
@@ -48,6 +48,15 @@ public class Group extends DataUnit implements Cloneable {
public Group(String name) {
super(name);
}
+
+ /**
+ * Is this a GlobalGroup
+ *
+ * @return
+ */
+ public boolean isGlobal() {
+ return (getDataSource() == null);
+ }
/**
* Clone this group
@@ -57,7 +66,7 @@ public class Group extends DataUnit implements Cloneable {
public Group clone() {
Group clone;
- if (getDataSource() == null) {
+ if (isGlobal()) {
clone = new Group(this.getName());
} else {
clone = new Group(getDataSource(), this.getName());
@@ -85,7 +94,7 @@ public class Group extends DataUnit implements Cloneable {
Group clone = dataSource.createGroup(this.getName());
// Don't add inheritance for GlobalGroups
- if (getDataSource() != null) {
+ if (!isGlobal()) {
clone.inherits = new ArrayList<String>(this.getInherits());
}
for (String perm : this.getPermissionList()) {
@@ -110,26 +119,30 @@ public class Group extends DataUnit implements Cloneable {
* @param inherit the inherits to set
*/
public void addInherits(Group inherit) {
- if (!this.getDataSource().groupExists(inherit.getName())) {
- getDataSource().addGroup(inherit);
- }
- if (!inherits.contains(inherit.getName().toLowerCase())) {
- inherits.add(inherit.getName().toLowerCase());
- }
- flagAsChanged();
- if (GroupManager.isLoaded()) {
- GroupManager.BukkitPermissions.updateAllPlayers();
- GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
- }
+ if (!isGlobal()) {
+ if (!this.getDataSource().groupExists(inherit.getName())) {
+ getDataSource().addGroup(inherit);
+ }
+ if (!inherits.contains(inherit.getName().toLowerCase())) {
+ inherits.add(inherit.getName().toLowerCase());
+ }
+ flagAsChanged();
+ if (GroupManager.isLoaded()) {
+ GroupManager.BukkitPermissions.updateAllPlayers();
+ GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
+ }
+ }
}
public boolean removeInherits(String inherit) {
- if (this.inherits.contains(inherit.toLowerCase())) {
- this.inherits.remove(inherit.toLowerCase());
- flagAsChanged();
- GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
- return true;
- }
+ if (!isGlobal()) {
+ if (this.inherits.contains(inherit.toLowerCase())) {
+ this.inherits.remove(inherit.toLowerCase());
+ flagAsChanged();
+ GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
+ return true;
+ }
+ }
return false;
}
@@ -145,15 +158,17 @@ public class Group extends DataUnit implements Cloneable {
* @param varList
*/
public void setVariables(Map<String, Object> varList) {
- GroupVariables temp = new GroupVariables(this, varList);
- variables.clearVars();
- for (String key : temp.getVarKeyList()) {
- variables.addVar(key, temp.getVarObject(key));
- }
- flagAsChanged();
- if (GroupManager.isLoaded()) {
- GroupManager.BukkitPermissions.updateAllPlayers();
- GroupManagerEventHandler.callEvent(this, Action.GROUP_INFO_CHANGED);
- }
+ if (!isGlobal()) {
+ GroupVariables temp = new GroupVariables(this, varList);
+ variables.clearVars();
+ for (String key : temp.getVarKeyList()) {
+ variables.addVar(key, temp.getVarObject(key));
+ }
+ flagAsChanged();
+ if (GroupManager.isLoaded()) {
+ GroupManager.BukkitPermissions.updateAllPlayers();
+ GroupManagerEventHandler.callEvent(this, Action.GROUP_INFO_CHANGED);
+ }
+ }
}
}