From 409f98e1e6e37308052ce562b641cfae7ff5f405 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Mon, 22 Aug 2011 15:13:12 -0500 Subject: [PATCH] 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 --- src/com/massivecraft/factions/Faction.java | 5 +++-- src/com/massivecraft/factions/struct/Role.java | 8 ++++++++ .../factions/util/MapFLocToStringSetTypeAdapter.java | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index 7cce2504..2d5e83b6 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -3,6 +3,7 @@ package com.massivecraft.factions; import java.io.*; import java.lang.reflect.Type; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.Map.Entry; import java.util.logging.Level; @@ -28,7 +29,7 @@ public class Faction { private transient int id; private Map relationWish; - private Map> claimOwnership = new HashMap>(); + private Map> claimOwnership = new ConcurrentHashMap>(); private Set invites; // Where string is a lowercase player name private boolean open; private boolean peaceful; @@ -559,7 +560,7 @@ public class Faction { } // 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; } diff --git a/src/com/massivecraft/factions/struct/Role.java b/src/com/massivecraft/factions/struct/Role.java index 496ae73e..ecbd4ebf 100644 --- a/src/com/massivecraft/factions/struct/Role.java +++ b/src/com/massivecraft/factions/struct/Role.java @@ -15,6 +15,14 @@ public enum Role { this.nicename = nicename; } + public boolean isAtLeast(Role role) { + return this.value >= role.value; + } + + public boolean isAtMost(Role role) { + return this.value <= role.value; + } + @Override public String toString() { return this.nicename; diff --git a/src/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java b/src/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java index 5f8e77fb..77f27ac7 100644 --- a/src/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java +++ b/src/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java @@ -1,7 +1,7 @@ package com.massivecraft.factions.util; import java.lang.reflect.Type; -import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; @@ -32,7 +32,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer> locationMap = new HashMap>(); + Map> locationMap = new ConcurrentHashMap>(); Set nameSet; Iterator iter; String worldName;