Fix manload to properly clone user variables.

This commit is contained in:
ElgarL 2011-12-08 02:28:12 +00:00
parent 5f0936cf44
commit 789a6b9540
3 changed files with 17 additions and 20 deletions

View file

@ -76,7 +76,7 @@ public class User extends DataUnit implements Cloneable {
for (String perm : this.getPermissionList()) {
clone.addPermission(perm);
}
// clone.variables = this.variables.clone();
clone.variables = this.variables.clone(this);
clone.flagAsChanged();
return clone;
}
@ -213,10 +213,11 @@ public class User extends DataUnit implements Cloneable {
* @param varList
*/
public void setVariables(Map<String, Object> varList) {
UserVariables temp = new UserVariables(this, varList);
//UserVariables temp = new UserVariables(this, varList);
variables.clearVars();
for (String key : temp.getVarKeyList()) {
variables.addVar(key, temp.getVarObject(key));
for (String key : varList.keySet()) {
System.out.print("Adding variable - " + key);
variables.addVar(key, varList.get(key));
}
flagAsChanged();
if (GroupManager.isLoaded())

View file

@ -108,8 +108,6 @@ public abstract class Variables implements Cloneable {
return o == null ? -1.0D : Double.parseDouble(o.toString());
} catch (Exception e) {
return -1.0D;
}
}
@ -119,8 +117,6 @@ public abstract class Variables implements Cloneable {
*/
public Set<String> getVarKeyList() {
return variables.keySet();
}
/**
@ -130,8 +126,6 @@ public abstract class Variables implements Cloneable {
*/
public boolean hasVar(String name) {
return variables.containsKey(name);
}
/**
@ -140,8 +134,6 @@ public abstract class Variables implements Cloneable {
*/
public int getSize() {
return variables.size();
}
/**

View file

@ -631,7 +631,6 @@ public class WorldDataHolder {
} else
throw new IllegalArgumentException("Unknown entry found in Info section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
//END INFO NODE
if (thisGroupNode.get("inheritance") == null || thisGroupNode.get("inheritance") instanceof List) {
@ -753,14 +752,19 @@ public class WorldDataHolder {
}
//USER INFO NODE - BETA
//USER INFO NODE
//INFO NODE
Map<String, Object> infoNode = (Map<String, Object>) thisUserNode.get("info");
if (infoNode != null) {
thisUser.setVariables(infoNode);
}
//END INFO NODE - BETA
if (thisUserNode.get("info") instanceof Map) {
Map<String, Object> infoNode = (Map<String, Object>) thisUserNode.get("info");
if (infoNode != null) {
thisUser.setVariables(infoNode);
}
} else if (thisUserNode.get("info") != null)
throw new IllegalArgumentException("Unknown entry found in Info section for user: " + thisUser.getName() + " in file: " + usersFile.getPath());
//END INFO NODE
if (thisUserNode.get("group") != null) {
Group hisGroup = ph.getGroup(thisUserNode.get("group").toString());