summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java')
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java108
1 files changed, 66 insertions, 42 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
index 751dc8fd6..5fe7365ce 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
@@ -14,97 +14,108 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
+
/**
- *
+ *
* @author gabrielcouto/ElgarL
*/
-public class Group extends DataUnit implements Cloneable {
-
+public class Group extends DataUnit implements Cloneable
+{
/**
* The group it inherits DIRECTLY!
*/
private ArrayList<String> inherits = new ArrayList<String>();
/**
- * This one holds the fields in INFO node.
- * like prefix = 'c'
- * or build = false
+ * This one holds the fields in INFO node. like prefix = 'c' or build = false
*/
private GroupVariables variables = new GroupVariables(this);
/**
* Constructor for individual World Groups.
- *
+ *
* @param name
*/
- public Group(WorldDataHolder source, String name) {
+ public Group(WorldDataHolder source, String name)
+ {
super(source, name);
}
/**
* Constructor for Global Groups.
- *
+ *
* @param name
*/
- public Group(String name) {
+ public Group(String name)
+ {
super(name);
}
/**
* Is this a GlobalGroup
- *
+ *
* @return true if this is a global group
*/
- public boolean isGlobal() {
+ public boolean isGlobal()
+ {
return (getDataSource() == null);
}
/**
* Clone this group
- *
+ *
* @return a clone of this group
*/
@Override
- public Group clone() {
+ public Group clone()
+ {
Group clone;
- if (isGlobal()) {
+ if (isGlobal())
+ {
clone = new Group(this.getName());
- } else {
+ }
+ else
+ {
clone = new Group(getDataSource(), this.getName());
clone.inherits = new ArrayList<String>(this.getInherits());
}
- for (String perm : this.getPermissionList()) {
+ for (String perm : this.getPermissionList())
+ {
clone.addPermission(perm);
}
- clone.variables = ((GroupVariables) variables).clone(clone);
+ clone.variables = ((GroupVariables)variables).clone(clone);
//clone.flagAsChanged();
return clone;
}
/**
* Use this to deliver a group from a different dataSource to another
- *
+ *
* @param dataSource
* @return Null or Clone
*/
- public Group clone(WorldDataHolder dataSource) {
+ public Group clone(WorldDataHolder dataSource)
+ {
- if (dataSource.groupExists(this.getName())) {
+ if (dataSource.groupExists(this.getName()))
+ {
return null;
}
Group clone = dataSource.createGroup(this.getName());
// Don't add inheritance for GlobalGroups
- if (!isGlobal()) {
+ if (!isGlobal())
+ {
clone.inherits = new ArrayList<String>(this.getInherits());
}
- for (String perm : this.getPermissionList()) {
+ for (String perm : this.getPermissionList())
+ {
clone.addPermission(perm);
}
clone.variables = variables.clone(clone);
@@ -113,13 +124,13 @@ public class Group extends DataUnit implements Cloneable {
}
/**
- * an unmodifiable list of inherits list
- * You can't manage the list by here
- * Lol... version 0.6 had a problem because this.
- *
+ * an unmodifiable list of inherits list You can't manage the list by here Lol... version 0.6 had a problem because
+ * this.
+ *
* @return the inherits
*/
- public List<String> getInherits() {
+ public List<String> getInherits()
+ {
return Collections.unmodifiableList(inherits);
}
@@ -127,27 +138,35 @@ public class Group extends DataUnit implements Cloneable {
/**
* @param inherit the inherits to set
*/
- public void addInherits(Group inherit) {
+ public void addInherits(Group inherit)
+ {
- if (!isGlobal()) {
- if (!this.getDataSource().groupExists(inherit.getName())) {
+ if (!isGlobal())
+ {
+ if (!this.getDataSource().groupExists(inherit.getName()))
+ {
getDataSource().addGroup(inherit);
}
- if (!inherits.contains(inherit.getName().toLowerCase())) {
+ if (!inherits.contains(inherit.getName().toLowerCase()))
+ {
inherits.add(inherit.getName().toLowerCase());
}
flagAsChanged();
- if (GroupManager.isLoaded()) {
+ if (GroupManager.isLoaded())
+ {
GroupManager.BukkitPermissions.updateAllPlayers();
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
}
}
}
- public boolean removeInherits(String inherit) {
+ public boolean removeInherits(String inherit)
+ {
- if (!isGlobal()) {
- if (this.inherits.contains(inherit.toLowerCase())) {
+ if (!isGlobal())
+ {
+ if (this.inherits.contains(inherit.toLowerCase()))
+ {
this.inherits.remove(inherit.toLowerCase());
flagAsChanged();
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
@@ -160,25 +179,30 @@ public class Group extends DataUnit implements Cloneable {
/**
* @return the variables
*/
- public GroupVariables getVariables() {
+ public GroupVariables getVariables()
+ {
return variables;
}
/**
- *
+ *
* @param varList
*/
- public void setVariables(Map<String, Object> varList) {
+ public void setVariables(Map<String, Object> varList)
+ {
- if (!isGlobal()) {
+ if (!isGlobal())
+ {
GroupVariables temp = new GroupVariables(this, varList);
variables.clearVars();
- for (String key : temp.getVarKeyList()) {
+ for (String key : temp.getVarKeyList())
+ {
variables.addVar(key, temp.getVarObject(key));
}
flagAsChanged();
- if (GroupManager.isLoaded()) {
+ if (GroupManager.isLoaded())
+ {
GroupManager.BukkitPermissions.updateAllPlayers();
GroupManagerEventHandler.callEvent(this, Action.GROUP_INFO_CHANGED);
}