Don't allow players to be added to SubscriptionValueMaps
This commit is contained in:
parent
30ce269873
commit
c0cd197bd0
@ -161,6 +161,9 @@ public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Bo
|
||||
private LPSubscriptionValueMap(String permission, Map<Permissible, Boolean> backing) {
|
||||
this.permission = permission;
|
||||
this.backing = backing;
|
||||
|
||||
// remove all players from the map
|
||||
this.backing.keySet().removeIf(p -> p instanceof Player);
|
||||
}
|
||||
|
||||
public LPSubscriptionValueMap(String permission) {
|
||||
@ -197,6 +200,16 @@ public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Bo
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean put(Permissible key, Boolean value) {
|
||||
// don't allow players to be put into this map
|
||||
if (key instanceof Player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.backing.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
// delegate through the get method
|
||||
@ -241,11 +254,6 @@ public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Bo
|
||||
|
||||
// just delegate to the backing map
|
||||
|
||||
@Override
|
||||
public Boolean put(Permissible key, Boolean value) {
|
||||
return this.backing.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean remove(Object key) {
|
||||
return this.backing.remove(key);
|
||||
|
@ -29,6 +29,7 @@ import com.google.common.collect.Sets;
|
||||
|
||||
import me.lucko.luckperms.nukkit.LPNukkitPlugin;
|
||||
|
||||
import cn.nukkit.Player;
|
||||
import cn.nukkit.permission.Permissible;
|
||||
import cn.nukkit.plugin.PluginManager;
|
||||
|
||||
@ -161,6 +162,9 @@ public final class LPSubscriptionMap extends HashMap<String, Set<Permissible>> {
|
||||
if (content != null) {
|
||||
this.backing.addAll(content);
|
||||
}
|
||||
|
||||
// remove all players from the map
|
||||
this.backing.removeIf(p -> p instanceof Player);
|
||||
}
|
||||
|
||||
private LPSubscriptionValueSet(String permission) {
|
||||
@ -223,6 +227,11 @@ public final class LPSubscriptionMap extends HashMap<String, Set<Permissible>> {
|
||||
|
||||
@Override
|
||||
public boolean add(Permissible permissible) {
|
||||
// don't allow players to be put into this map
|
||||
if (permissible instanceof Player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.backing.add(permissible);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user