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