summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager/src
diff options
context:
space:
mode:
authormd_5 <md_5@bigpond.com>2012-09-16 23:02:56 +1000
committermd_5 <md_5@bigpond.com>2012-09-16 23:02:56 +1000
commitfd61cd17502eae4097df692063f9e76ea647226c (patch)
tree4c850d22c45f180d670bca0663c35dbf00bc2f2d /EssentialsGroupManager/src
parente7ae8bcc4756fd8306814565ded2ec4a06897bf9 (diff)
parent75f7b06a23e8bed40d30068542b97959663c75e8 (diff)
downloadEssentials-fd61cd17502eae4097df692063f9e76ea647226c.tar
Essentials-fd61cd17502eae4097df692063f9e76ea647226c.tar.gz
Essentials-fd61cd17502eae4097df692063f9e76ea647226c.tar.lz
Essentials-fd61cd17502eae4097df692063f9e76ea647226c.tar.xz
Essentials-fd61cd17502eae4097df692063f9e76ea647226c.zip
Merge remote-tracking branch 'origin/groupmanager' into 2.9
Diffstat (limited to 'EssentialsGroupManager/src')
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java25
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java18
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java21
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/GroupVariables.java5
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java11
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/UserVariables.java5
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Variables.java11
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/GroupsDataHolder.java11
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java11
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/UsersDataHolder.java12
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java29
11 files changed, 109 insertions, 50 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java
index d0f5fed8b..ae6ba501b 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java
@@ -7,12 +7,11 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
-import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.logging.Level;
import org.anjocaido.groupmanager.data.Group;
@@ -35,7 +34,7 @@ public class GlobalGroups {
private GroupManager plugin;
//private Yaml GGroups;
- private Map<String, Group> groups;
+ private final Map<String, Group> groups = Collections.synchronizedMap(new HashMap<String, Group>());
protected long timeStampGroups = 0;
protected boolean haveGroupsChanged = false;
@@ -55,11 +54,13 @@ public class GlobalGroups {
if (this.haveGroupsChanged) {
return true;
}
+ synchronized(groups) {
for (Group g : groups.values()) {
if (g.isChanged()) {
return true;
}
}
+ }
return false;
}
@@ -227,6 +228,7 @@ public class GlobalGroups {
Map<String, Object> groupsMap = new HashMap<String, Object>();
root.put("groups", groupsMap);
+ synchronized(groups) {
for (String groupKey : groups.keySet()) {
Group group = groups.get(groupKey);
@@ -245,6 +247,7 @@ public class GlobalGroups {
// Permission nodes
aGroupMap.put("permissions", group.getPermissionList());
}
+ }
if (!root.isEmpty()) {
DumperOptions opt = new DumperOptions();
@@ -418,26 +421,26 @@ public class GlobalGroups {
*
* @return Set containing all group names.
*/
- public Set<String> getGlobalGroups() {
+ /*public Set<String> getGlobalGroups() {
return groups.keySet();
- }
+ }*/
/**
* Resets GlobalGroups.
*/
public void resetGlobalGroups() {
-
- this.groups = new HashMap<String, Group>();
+ this.groups.clear();
}
/**
*
* @return a collection of the groups
*/
- public Collection<Group> getGroupList() {
-
- return groups.values();
+ public Group[] getGroupList() {
+ synchronized(groups) {
+ return groups.values().toArray(new Group[0]);
+ }
}
/**
@@ -469,9 +472,11 @@ public class GlobalGroups {
public void removeGroupsChangedFlag() {
setGroupsChanged(false);
+ synchronized(groups) {
for (Group g : groups.values()) {
g.flagAsSaved();
}
+ }
}
} \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java
index bb04fa3d7..5cd07048f 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java
@@ -21,7 +21,7 @@ public abstract class DataUnit {
private WorldDataHolder dataSource;
private String name;
private boolean changed, sorted = false;
- private ArrayList<String> permissions = new ArrayList<String>();
+ private List<String> permissions = Collections.unmodifiableList(Collections.<String>emptyList());
public DataUnit(WorldDataHolder dataSource, String name) {
@@ -144,7 +144,9 @@ public abstract class DataUnit {
public void addPermission(String permission) {
if (!hasSamePermissionNode(permission)) {
- permissions.add(permission);
+ List<String> clone = new ArrayList<String>(permissions);
+ clone.add(permission);
+ permissions = Collections.unmodifiableList(clone);
}
flagAsChanged();
}
@@ -152,7 +154,10 @@ public abstract class DataUnit {
public boolean removePermission(String permission) {
flagAsChanged();
- return permissions.remove(permission);
+ List<String> clone = new ArrayList<String>(permissions);
+ boolean ret = clone.remove(permission);
+ permissions = Collections.unmodifiableList(clone);
+ return ret;
}
/**
@@ -162,8 +167,7 @@ public abstract class DataUnit {
* @return a copy of the permission list
*/
public List<String> getPermissionList() {
-
- return Collections.unmodifiableList(permissions);
+ return permissions;
}
public boolean isSorted() {
@@ -174,7 +178,9 @@ public abstract class DataUnit {
public void sortPermissions() {
if (!isSorted()) {
- Collections.sort(permissions, StringPermissionComparator.getInstance());
+ List<String> clone = new ArrayList<String>(permissions);
+ Collections.sort(clone, StringPermissionComparator.getInstance());
+ permissions = Collections.unmodifiableList(clone);
sorted = true;
}
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
index 751dc8fd6..8da6ba85a 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java
@@ -23,7 +23,7 @@ public class Group extends DataUnit implements Cloneable {
/**
* The group it inherits DIRECTLY!
*/
- private ArrayList<String> inherits = new ArrayList<String>();
+ private List<String> inherits = Collections.unmodifiableList(Collections.<String>emptyList());
/**
* This one holds the fields in INFO node.
* like prefix = 'c'
@@ -75,7 +75,9 @@ public class Group extends DataUnit implements Cloneable {
clone = new Group(this.getName());
} else {
clone = new Group(getDataSource(), this.getName());
- clone.inherits = new ArrayList<String>(this.getInherits());
+ clone.inherits = this.getInherits().isEmpty() ?
+ Collections.unmodifiableList(Collections.<String>emptyList())
+ : Collections.unmodifiableList(new ArrayList<String>(this.getInherits()));
}
for (String perm : this.getPermissionList()) {
@@ -102,7 +104,9 @@ public class Group extends DataUnit implements Cloneable {
// Don't add inheritance for GlobalGroups
if (!isGlobal()) {
- clone.inherits = new ArrayList<String>(this.getInherits());
+ clone.inherits = this.getInherits().isEmpty() ?
+ Collections.unmodifiableList(Collections.<String>emptyList())
+ : Collections.unmodifiableList(new ArrayList<String>(this.getInherits()));
}
for (String perm : this.getPermissionList()) {
clone.addPermission(perm);
@@ -120,8 +124,7 @@ public class Group extends DataUnit implements Cloneable {
* @return the inherits
*/
public List<String> getInherits() {
-
- return Collections.unmodifiableList(inherits);
+ return inherits;
}
/**
@@ -134,7 +137,9 @@ public class Group extends DataUnit implements Cloneable {
getDataSource().addGroup(inherit);
}
if (!inherits.contains(inherit.getName().toLowerCase())) {
- inherits.add(inherit.getName().toLowerCase());
+ List<String> clone = new ArrayList<String>(inherits);
+ clone.add(inherit.getName().toLowerCase());
+ inherits = Collections.unmodifiableList(clone);
}
flagAsChanged();
if (GroupManager.isLoaded()) {
@@ -148,7 +153,9 @@ public class Group extends DataUnit implements Cloneable {
if (!isGlobal()) {
if (this.inherits.contains(inherit.toLowerCase())) {
- this.inherits.remove(inherit.toLowerCase());
+ List<String> clone = new ArrayList<String>(inherits);
+ clone.remove(inherit.toLowerCase());
+ inherits = Collections.unmodifiableList(clone);
flagAsChanged();
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
return true;
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/GroupVariables.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/GroupVariables.java
index e08d1db7d..588d50116 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/GroupVariables.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/GroupVariables.java
@@ -26,7 +26,8 @@ public class GroupVariables extends Variables implements Cloneable {
public GroupVariables(Group owner, Map<String, Object> varList) {
super(owner);
- variables = varList;
+ variables.clear();
+ variables.putAll(varList);
if (variables.get("prefix") == null) {
variables.put("prefix", "");
owner.flagAsChanged();
@@ -54,9 +55,11 @@ public class GroupVariables extends Variables implements Cloneable {
protected GroupVariables clone(Group newOwner) {
GroupVariables clone = new GroupVariables(newOwner);
+ synchronized(variables) {
for (String key : variables.keySet()) {
clone.variables.put(key, variables.get(key));
}
+ }
newOwner.flagAsChanged();
return clone;
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java
index 6c74c2e50..a7e5cdc8b 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java
@@ -6,6 +6,8 @@ package org.anjocaido.groupmanager.data;
//import com.sun.org.apache.bcel.internal.generic.AALOAD;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
@@ -26,7 +28,7 @@ public class User extends DataUnit implements Cloneable {
*
*/
private String group = null;
- private ArrayList<String> subGroups = new ArrayList<String>();
+ private final List<String> subGroups = Collections.synchronizedList(Collections.<String>emptyList());
/**
* This one holds the fields in INFO node. like prefix = 'c' or build =
* false
@@ -213,6 +215,7 @@ public class User extends DataUnit implements Cloneable {
public ArrayList<Group> subGroupListCopy() {
ArrayList<Group> val = new ArrayList<Group>();
+ synchronized(subGroups) {
for (String gstr : subGroups) {
Group g = getDataSource().getGroup(gstr);
if (g == null) {
@@ -221,12 +224,14 @@ public class User extends DataUnit implements Cloneable {
}
val.add(g);
}
+ }
return val;
}
public ArrayList<String> subGroupListStringCopy() {
-
- return new ArrayList<String>(subGroups);
+ synchronized(subGroups) {
+ return new ArrayList<String>(subGroups);
+ }
}
/**
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/UserVariables.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/UserVariables.java
index f994595c1..05c3aecee 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/UserVariables.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/UserVariables.java
@@ -23,7 +23,8 @@ public class UserVariables extends Variables {
public UserVariables(User owner, Map<String, Object> varList) {
super(owner);
- this.variables = varList;
+ this.variables.clear();
+ this.variables.putAll(varList);
this.owner = owner;
}
@@ -35,9 +36,11 @@ public class UserVariables extends Variables {
protected UserVariables clone(User newOwner) {
UserVariables clone = new UserVariables(newOwner);
+ synchronized(variables) {
for (String key : variables.keySet()) {
clone.variables.put(key, variables.get(key));
}
+ }
newOwner.flagAsChanged();
return clone;
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Variables.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Variables.java
index 42ceba7e4..8e1a54b98 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Variables.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Variables.java
@@ -4,9 +4,9 @@
*/
package org.anjocaido.groupmanager.data;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
/**
* A class that holds variables of a user/group.
@@ -21,7 +21,7 @@ import java.util.Set;
public abstract class Variables implements Cloneable {
private DataUnit owner;
- protected Map<String, Object> variables = new HashMap<String, Object>();
+ protected final Map<String, Object> variables = Collections.synchronizedMap(new HashMap<String, Object>());
public Variables(DataUnit owner) {
@@ -126,9 +126,10 @@ public abstract class Variables implements Cloneable {
*
* @return Set of all variable names.
*/
- public Set<String> getVarKeyList() {
-
- return variables.keySet();
+ public String[] getVarKeyList() {
+ synchronized(variables) {
+ return variables.keySet().toArray(new String[0]);
+ }
}
/**
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/GroupsDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/GroupsDataHolder.java
index eaaaace74..fdd099c87 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/GroupsDataHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/GroupsDataHolder.java
@@ -1,6 +1,7 @@
package org.anjocaido.groupmanager.dataholder;
import java.io.File;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -23,7 +24,7 @@ public class GroupsDataHolder {
/**
* The actual groups holder
*/
- private Map<String, Group> groups = new HashMap<String, Group>();
+ private final Map<String, Group> groups = Collections.synchronizedMap(new HashMap<String, Group>());
/**
* Constructor
@@ -36,8 +37,10 @@ public class GroupsDataHolder {
this.dataSource = dataSource;
//push this data source to the users, so they pull the correct groups data.
+ synchronized(groups) {
for (Group group : groups.values())
group.setDataSource(this.dataSource);
+ }
}
/**
@@ -57,6 +60,7 @@ public class GroupsDataHolder {
}
/**
+ * Note: Iteration over this object has to be synchronized!
* @return the groups
*/
public Map<String, Group> getGroups() {
@@ -67,9 +71,8 @@ public class GroupsDataHolder {
/**
* @param groups the groups to set
*/
- public void setGroups(Map<String, Group> groups) {
-
- this.groups = groups;
+ public void resetGroups() {
+ this.groups.clear();
}
/**
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java
index 84561b6e5..ef9f605ed 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java
@@ -6,6 +6,7 @@ package org.anjocaido.groupmanager.dataholder;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.anjocaido.groupmanager.data.User;
@@ -19,7 +20,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
/**
*
*/
- protected Map<String, User> overloadedUsers = new HashMap<String, User>();
+ protected final Map<String, User> overloadedUsers = Collections.synchronizedMap(new HashMap<String, User>());
/**
*
@@ -112,9 +113,11 @@ public class OverloadedWorldHolder extends WorldDataHolder {
if (groupName.equals(getDefaultGroup())) {
return false;
}
+ synchronized(getGroups()) {
for (String key : getGroups().keySet()) {
if (groupName.equalsIgnoreCase(key)) {
getGroups().remove(key);
+ synchronized(getUsers()) {
for (String userKey : getUsers().keySet()) {
User user = getUsers().get(userKey);
if (user.getGroupName().equalsIgnoreCase(key)) {
@@ -122,7 +125,9 @@ public class OverloadedWorldHolder extends WorldDataHolder {
}
}
+ }
//OVERLOADED CODE
+ synchronized(overloadedUsers) {
for (String userKey : overloadedUsers.keySet()) {
User user = overloadedUsers.get(userKey);
if (user.getGroupName().equalsIgnoreCase(key)) {
@@ -130,11 +135,13 @@ public class OverloadedWorldHolder extends WorldDataHolder {
}
}
+ }
//END OVERLOAD
setGroupsChanged(true);
return true;
}
}
+ }
return false;
}
@@ -146,6 +153,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
public Collection<User> getUserList() {
Collection<User> overloadedList = new ArrayList<User>();
+ synchronized(getUsers()) {
Collection<User> normalList = getUsers().values();
for (User u : normalList) {
if (overloadedUsers.containsKey(u.getName().toLowerCase())) {
@@ -154,6 +162,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
overloadedList.add(u);
}
}
+ }
return overloadedList;
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/UsersDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/UsersDataHolder.java
index 665fe227d..8a3c4c102 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/UsersDataHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/UsersDataHolder.java
@@ -1,6 +1,7 @@
package org.anjocaido.groupmanager.dataholder;
import java.io.File;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -22,7 +23,7 @@ public class UsersDataHolder {
/**
* The actual groups holder
*/
- private Map<String, User> users = new HashMap<String, User>();
+ private final Map<String, User> users = Collections.synchronizedMap(new HashMap<String, User>());
/**
* Constructor
@@ -35,12 +36,14 @@ public class UsersDataHolder {
this.dataSource = dataSource;
//push this data source to the users, so they pull the correct groups data.
+ synchronized(users) {
for (User user : users.values())
user.setDataSource(this.dataSource);
-
+ }
}
/**
+ * Note: Iteration over this object has to be synchronized!
* @return the users
*/
public Map<String, User> getUsers() {
@@ -51,9 +54,8 @@ public class UsersDataHolder {
/**
* @param users the users to set
*/
- public void setUsers(Map<String, User> users) {
-
- this.users = users;
+ public void resetUsers() {
+ this.users.clear();
}
/**
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
index aad59e5aa..4d85eff68 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
@@ -319,8 +319,9 @@ public class WorldDataHolder {
* @return a collection of the groups
*/
public Collection<Group> getGroupList() {
-
- return getGroups().values();
+ synchronized(getGroups()) {
+ return new ArrayList<Group>(getGroups().values());
+ }
}
/**
@@ -328,8 +329,9 @@ public class WorldDataHolder {
* @return a collection of the users
*/
public Collection<User> getUserList() {
-
- return getUsers().values();
+ synchronized(getUsers()) {
+ return new ArrayList<User>(getUsers().values());
+ }
}
/**
@@ -944,6 +946,7 @@ public class WorldDataHolder {
Map<String, Object> groupsMap = new HashMap<String, Object>();
root.put("groups", groupsMap);
+ synchronized(ph.getGroups()) {
for (String groupKey : ph.getGroups().keySet()) {
Group group = ph.getGroups().get(groupKey);
@@ -966,6 +969,7 @@ public class WorldDataHolder {
aGroupMap.put("permissions", group.getPermissionList());
}
+ }
if (!root.isEmpty()) {
DumperOptions opt = new DumperOptions();
@@ -1031,6 +1035,7 @@ public class WorldDataHolder {
Map<String, Object> usersMap = new HashMap<String, Object>();
root.put("users", usersMap);
+ synchronized(ph.getUsers()) {
for (String userKey : ph.getUsers().keySet()) {
User user = ph.getUsers().get(userKey);
if ((user.getGroup() == null || user.getGroup().equals(ph.getDefaultGroup())) && user.getPermissionList().isEmpty() && user.getVariables().isEmpty() && user.isSubGroupsEmpty()) {
@@ -1060,6 +1065,7 @@ public class WorldDataHolder {
aUserMap.put("subgroups", user.subGroupListStringCopy());
// END SUBGROUPS NODE - BETA
}
+ }
if (!root.isEmpty()) {
DumperOptions opt = new DumperOptions();
@@ -1159,11 +1165,13 @@ public class WorldDataHolder {
if (users.HaveUsersChanged()) {
return true;
}
+ synchronized(users.getUsers()) {
for (User u : users.getUsers().values()) {
if (u.isChanged()) {
return true;
}
}
+ }
return false;
}
@@ -1184,11 +1192,13 @@ public class WorldDataHolder {
if (groups.HaveGroupsChanged()) {
return true;
}
+ synchronized(groups.getGroups()) {
for (Group g : groups.getGroups().values()) {
if (g.isChanged()) {
return true;
}
}
+ }
return false;
}
@@ -1198,9 +1208,11 @@ public class WorldDataHolder {
public void removeUsersChangedFlag() {
setUsersChanged(false);
+ synchronized(getUsers()) {
for (User u : getUsers().values()) {
u.flagAsSaved();
}
+ }
}
/**
@@ -1209,9 +1221,11 @@ public class WorldDataHolder {
public void removeGroupsChangedFlag() {
setGroupsChanged(false);
+ synchronized(getGroups()) {
for (Group g : getGroups().values()) {
g.flagAsSaved();
}
+ }
}
/**
@@ -1260,18 +1274,18 @@ public class WorldDataHolder {
public void resetGroups() {
// setDefaultGroup(null);
- groups.setGroups(new HashMap<String, Group>());
+ groups.resetGroups();
}
/**
* Resets Users
*/
public void resetUsers() {
-
- users.setUsers(new HashMap<String, User>());
+ users.resetUsers();
}
/**
+ * Note: Iteration over this object has to be synchronized!
* @return the groups
*/
public Map<String, Group> getGroups() {
@@ -1280,6 +1294,7 @@ public class WorldDataHolder {
}
/**
+ * Note: Iteration over this object has to be synchronized!
* @return the users
*/
public Map<String, User> getUsers() {