public class ConcurrentPlayerMap<TValue> extends AbstractMap<org.bukkit.entity.Player,TValue> implements 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,
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Modifier and Type | Field and Description |
|---|---|
protected ConcurrentMap<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,Object> |
keyMethod
The method used to retrieve a unique key for a player.
|
protected ConcurrentMap<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,Object> method)
Construct a new concurrent player map using the given custom key method.
|
| Modifier and Type | Method and Description |
|---|---|
protected Object |
cachePlayerKey(org.bukkit.entity.Player player)
Retrieve the key of a particular player, ensuring it is cached.
|
boolean |
containsKey(Object key) |
protected ConcurrentMap<Object,org.bukkit.entity.Player> |
createKeyCache()
Construct a cache of keys and the associated player.
|
protected ConcurrentMap<Object,TValue> |
createValueMap()
Construct the map that will store the associated values.
|
Set<Map.Entry<org.bukkit.entity.Player,TValue>> |
entrySet() |
protected org.bukkit.entity.Player |
findOnlinePlayer(Object key)
Find an online player from the given key.
|
TValue |
get(Object key) |
protected org.bukkit.entity.Player |
lookupPlayer(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(Object key) |
boolean |
remove(Object key,
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, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAllprotected ConcurrentMap<Object,TValue> valueLookup
protected ConcurrentMap<Object,org.bukkit.entity.Player> keyLookup
protected final com.google.common.base.Function<org.bukkit.entity.Player,Object> keyMethod
public ConcurrentPlayerMap(ConcurrentPlayerMap.PlayerKey standardMethod)
standardMethod - - the standard key method.public ConcurrentPlayerMap(com.google.common.base.Function<org.bukkit.entity.Player,Object> method)
method - - custom key method.public static <T> ConcurrentPlayerMap<T> usingAddress()
T - Parameter typepublic static <T> ConcurrentPlayerMap<T> usingName()
T - Parameter typeprotected ConcurrentMap<Object,TValue> createValueMap()
The default implementation uses a ConcurrentHashMap.
protected ConcurrentMap<Object,org.bukkit.entity.Player> createKeyCache()
protected org.bukkit.entity.Player findOnlinePlayer(Object key)
key - - a non-null key.protected org.bukkit.entity.Player lookupPlayer(Object key)
key - - the key of the player we are locating.protected 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 ConcurrentMap<org.bukkit.entity.Player,TValue>putIfAbsent in interface Map<org.bukkit.entity.Player,TValue>public boolean containsKey(Object key)
containsKey in interface Map<org.bukkit.entity.Player,TValue>containsKey in class AbstractMap<org.bukkit.entity.Player,TValue>Copyright © 2012–2017 Comphenix and dmulloy2. Licensed under the GNU GPL v2.