public class ConcurrentPlayerMap<TValue>
extends java.util.AbstractMap<org.bukkit.entity.Player,TValue>
implements java.util.concurrent.ConcurrentMap<org.bukkit.entity.Player,TValue>
This map may use player addresses as keys.
Modifier and Type | Class and Description |
---|---|
static class |
ConcurrentPlayerMap.PlayerKey
Represents the different standard player keys,
|
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.ConcurrentMap<java.lang.Object,org.bukkit.entity.Player> |
keyLookup
A cache of the associated keys for each player.
|
protected com.google.common.base.Function<org.bukkit.entity.Player,java.lang.Object> |
keyMethod
The method used to retrieve a unique key for a player.
|
protected java.util.concurrent.ConcurrentMap<java.lang.Object,TValue> |
valueLookup
An internal map of player keys to values.
|
Constructor and Description |
---|
ConcurrentPlayerMap(ConcurrentPlayerMap.PlayerKey standardMethod)
Construct a new concurrent player map using the given standard key method.
|
ConcurrentPlayerMap(com.google.common.base.Function<org.bukkit.entity.Player,java.lang.Object> method)
Construct a new concurrent player map using the given custom key method.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
cachePlayerKey(org.bukkit.entity.Player player)
Retrieve the key of a particular player, ensuring it is cached.
|
boolean |
containsKey(java.lang.Object key) |
protected java.util.concurrent.ConcurrentMap<java.lang.Object,org.bukkit.entity.Player> |
createKeyCache()
Construct a cache of keys and the associated player.
|
protected java.util.concurrent.ConcurrentMap<java.lang.Object,TValue> |
createValueMap()
Construct the map that will store the associated values.
|
java.util.Set<java.util.Map.Entry<org.bukkit.entity.Player,TValue>> |
entrySet() |
protected org.bukkit.entity.Player |
findOnlinePlayer(java.lang.Object key)
Find an online player from the given key.
|
TValue |
get(java.lang.Object key) |
protected org.bukkit.entity.Player |
lookupPlayer(java.lang.Object key)
Lookup a player by key in the cache, optionally searching every online player.
|
TValue |
put(org.bukkit.entity.Player key,
TValue value) |
TValue |
putIfAbsent(org.bukkit.entity.Player key,
TValue value) |
TValue |
remove(java.lang.Object key) |
boolean |
remove(java.lang.Object key,
java.lang.Object value) |
TValue |
replace(org.bukkit.entity.Player key,
TValue value) |
boolean |
replace(org.bukkit.entity.Player key,
TValue oldValue,
TValue newValue) |
static <T> ConcurrentPlayerMap<T> |
usingAddress()
Construct a new concurrent player map that uses each player's address as key.
|
static <T> ConcurrentPlayerMap<T> |
usingName()
Construct a new concurrent player map that uses each player's name as key.
|
clear, clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, toString, values
protected java.util.concurrent.ConcurrentMap<java.lang.Object,TValue> valueLookup
protected java.util.concurrent.ConcurrentMap<java.lang.Object,org.bukkit.entity.Player> keyLookup
protected final com.google.common.base.Function<org.bukkit.entity.Player,java.lang.Object> keyMethod
public ConcurrentPlayerMap(ConcurrentPlayerMap.PlayerKey standardMethod)
standardMethod
- - the standard key method.public ConcurrentPlayerMap(com.google.common.base.Function<org.bukkit.entity.Player,java.lang.Object> method)
method
- - custom key method.public static <T> ConcurrentPlayerMap<T> usingAddress()
public static <T> ConcurrentPlayerMap<T> usingName()
protected java.util.concurrent.ConcurrentMap<java.lang.Object,TValue> createValueMap()
The default implementation uses a ConcurrentHashMap
.
protected java.util.concurrent.ConcurrentMap<java.lang.Object,org.bukkit.entity.Player> createKeyCache()
protected org.bukkit.entity.Player findOnlinePlayer(java.lang.Object key)
key
- - a non-null key.protected org.bukkit.entity.Player lookupPlayer(java.lang.Object key)
key
- - the key of the player we are locating.java.util.concurrent.ExecutionException
protected java.lang.Object cachePlayerKey(org.bukkit.entity.Player player)
player
- - the player whose key we want to retrieve.public TValue putIfAbsent(org.bukkit.entity.Player key, TValue value)
putIfAbsent
in interface java.util.concurrent.ConcurrentMap<org.bukkit.entity.Player,TValue>
public TValue replace(org.bukkit.entity.Player key, TValue value)
replace
in interface java.util.concurrent.ConcurrentMap<org.bukkit.entity.Player,TValue>
public boolean replace(org.bukkit.entity.Player key, TValue oldValue, TValue newValue)
replace
in interface java.util.concurrent.ConcurrentMap<org.bukkit.entity.Player,TValue>
public TValue remove(java.lang.Object key)
public boolean remove(java.lang.Object key, java.lang.Object value)
remove
in interface java.util.concurrent.ConcurrentMap<org.bukkit.entity.Player,TValue>
public TValue get(java.lang.Object key)
public boolean containsKey(java.lang.Object key)