Changed ownership mapping from HashMap to ConcurrentHashMap to hopefully take care of reported ConcurrentModificicationException error; bugfix for faction admin not being able to bypass ownership if "ownedAreaModeratorsBypass" was set

This commit is contained in:
Brettflan 2011-08-22 15:13:12 -05:00
parent 697e0cf466
commit 409f98e1e6
3 changed files with 13 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions;
import java.io.*; import java.io.*;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.logging.Level; import java.util.logging.Level;
@ -28,7 +29,7 @@ public class Faction {
private transient int id; private transient int id;
private Map<Integer, Relation> relationWish; private Map<Integer, Relation> relationWish;
private Map<FLocation, Set<String>> claimOwnership = new HashMap<FLocation, Set<String>>(); private Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<FLocation, Set<String>>();
private Set<String> invites; // Where string is a lowercase player name private Set<String> invites; // Where string is a lowercase player name
private boolean open; private boolean open;
private boolean peaceful; private boolean peaceful;
@ -559,7 +560,7 @@ public class Faction {
} }
// sufficient role to bypass ownership? // sufficient role to bypass ownership?
if (fplayer.getRole() == (Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.ADMIN)) { if (fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.ADMIN)) {
return true; return true;
} }

View File

@ -15,6 +15,14 @@ public enum Role {
this.nicename = nicename; this.nicename = nicename;
} }
public boolean isAtLeast(Role role) {
return this.value >= role.value;
}
public boolean isAtMost(Role role) {
return this.value <= role.value;
}
@Override @Override
public String toString() { public String toString() {
return this.nicename; return this.nicename;

View File

@ -1,7 +1,7 @@
package com.massivecraft.factions.util; package com.massivecraft.factions.util;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -32,7 +32,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
return null; return null;
} }
Map<FLocation, Set<String>> locationMap = new HashMap<FLocation, Set<String>>(); Map<FLocation, Set<String>> locationMap = new ConcurrentHashMap<FLocation, Set<String>>();
Set<String> nameSet; Set<String> nameSet;
Iterator<JsonElement> iter; Iterator<JsonElement> iter;
String worldName; String worldName;