diff options
author | ElgarL <ElgarL@palmergames.com> | 2011-10-31 08:34:07 +0000 |
---|---|---|
committer | ElgarL <ElgarL@palmergames.com> | 2011-10-31 08:34:07 +0000 |
commit | 34ba8e89bc9e9be00a539bb07a8ddaca16f9e954 (patch) | |
tree | d2f5478c1ea30ccfd8888c451e5fd861d211c29b /EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java | |
parent | b1c6173995721831c88570dd32edc77c369dca7a (diff) | |
download | Essentials-34ba8e89bc9e9be00a539bb07a8ddaca16f9e954.tar Essentials-34ba8e89bc9e9be00a539bb07a8ddaca16f9e954.tar.gz Essentials-34ba8e89bc9e9be00a539bb07a8ddaca16f9e954.tar.lz Essentials-34ba8e89bc9e9be00a539bb07a8ddaca16f9e954.tar.xz Essentials-34ba8e89bc9e9be00a539bb07a8ddaca16f9e954.zip |
Added Global Groups
Defined in groupmanager/globalgroups.yml.
Create groups in the yml with a g: prefix, then inherit in the worlds
groups files.
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java')
-rw-r--r-- | EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java index c8dc8cbd1..c8aa15cec 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -183,7 +183,10 @@ public class WorldDataHolder { * @return a group if it is found. null if not found. */ public Group getGroup(String groupName) { - return groups.get(groupName.toLowerCase()); + if (groupName.startsWith("g:")) + return GroupManager.getGlobalGroups().getGroup(groupName); + else + return groups.get(groupName.toLowerCase()); } /** @@ -193,7 +196,10 @@ public class WorldDataHolder { * @return true if exists. false if not. */ public boolean groupExists(String groupName) { - return groups.containsKey(groupName.toLowerCase()); + if (groupName.startsWith("g:")) + return GroupManager.getGlobalGroups().hasGroup(groupName); + else + return groups.containsKey(groupName.toLowerCase()); } /** @@ -215,6 +221,10 @@ public class WorldDataHolder { * @return true if had something to remove. false the group was default or non-existant */ public boolean removeGroup(String groupName) { + if (groupName.startsWith("g:")) { + return GroupManager.getGlobalGroups().removeGroup(groupName); + } + if (defaultGroup != null && groupName.equalsIgnoreCase(defaultGroup.getName())) { return false; } @@ -251,10 +261,16 @@ public class WorldDataHolder { * @return null if group already exists. or new Group */ public Group createGroup(String groupName) { - if (this.groups.containsKey(groupName.toLowerCase())) { + if (groupName.startsWith("g:")) { + Group newGroup = new Group(groupName); + return GroupManager.getGlobalGroups().addGroup(newGroup); + } + + if (this.groups.containsKey(groupName.toLowerCase())) { return null; } - Group newGroup = new Group(this, groupName); + + Group newGroup = new Group(this, groupName); this.addGroup(newGroup); haveGroupsChanged = true; return newGroup; |