Don't pass NULL to ConcurrentHashMap when reading or removing.
May fix issue 181 on BukkitDev.
Dieser Commit ist enthalten in:
Ursprung
5267e73311
Commit
d71bea9f8a
@ -223,10 +223,13 @@ public class ConcurrentPlayerMap<TValue> extends AbstractMap<Player, TValue> imp
|
|||||||
public TValue remove(Object key) {
|
public TValue remove(Object key) {
|
||||||
if (key instanceof Player) {
|
if (key instanceof Player) {
|
||||||
Object playerKey = keyMethod.apply((Player) key);
|
Object playerKey = keyMethod.apply((Player) key);
|
||||||
TValue value = valueLookup.remove(playerKey);
|
|
||||||
|
|
||||||
keyLookup.remove(playerKey);
|
if (playerKey != null) {
|
||||||
return value;
|
TValue value = valueLookup.remove(playerKey);
|
||||||
|
|
||||||
|
keyLookup.remove(playerKey);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -236,7 +239,7 @@ public class ConcurrentPlayerMap<TValue> extends AbstractMap<Player, TValue> imp
|
|||||||
if (key instanceof Player) {
|
if (key instanceof Player) {
|
||||||
Object playerKey = keyMethod.apply((Player) key);
|
Object playerKey = keyMethod.apply((Player) key);
|
||||||
|
|
||||||
if (valueLookup.remove(playerKey, value)) {
|
if (playerKey != null && valueLookup.remove(playerKey, value)) {
|
||||||
keyLookup.remove(playerKey);
|
keyLookup.remove(playerKey);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -246,15 +249,19 @@ public class ConcurrentPlayerMap<TValue> extends AbstractMap<Player, TValue> imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue get(Object key) {
|
public TValue get(Object key) {
|
||||||
if (key instanceof Player)
|
if (key instanceof Player) {
|
||||||
return valueLookup.get(keyMethod.apply((Player) key));
|
Object playerKey = keyMethod.apply((Player) key);
|
||||||
|
return playerKey != null ? valueLookup.get(playerKey) : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsKey(Object key) {
|
public boolean containsKey(Object key) {
|
||||||
if (key instanceof Player)
|
if (key instanceof Player) {
|
||||||
return valueLookup.containsKey(keyMethod.apply((Player) key));
|
Object playerKey = keyMethod.apply((Player) key);
|
||||||
|
return playerKey != null && valueLookup.containsKey(playerKey);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren