From 34ba8e89bc9e9be00a539bb07a8ddaca16f9e954 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Mon, 31 Oct 2011 08:34:07 +0000 Subject: Added Global Groups Defined in groupmanager/globalgroups.yml. Create groups in the yml with a g: prefix, then inherit in the worlds groups files. --- .../groupmanager/dataholder/WorldDataHolder.java | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java') 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; -- cgit v1.2.3