mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-03-02 11:31:13 +01:00
Lots of misc cleanup
This commit is contained in:
parent
b2593d409e
commit
b84518e1f1
@ -71,8 +71,8 @@ public class BukkitConfigAdapter implements ConfigurationAdapter {
|
||||
|
||||
@Override
|
||||
public List<String> getStringList(String path, List<String> def) {
|
||||
List<String> ret = this.configuration.getStringList(path);
|
||||
return ret == null ? def : ret;
|
||||
List<String> list = this.configuration.getStringList(path);
|
||||
return list == null ? def : list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
package me.lucko.luckperms.bukkit;
|
||||
|
||||
import me.lucko.luckperms.bukkit.compat.CraftBukkitUtil;
|
||||
import me.lucko.luckperms.bukkit.util.CraftBukkitImplementation;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.sender.SenderFactory;
|
||||
@ -78,7 +78,7 @@ public class BukkitSenderFactory extends SenderFactory<CommandSender> {
|
||||
|
||||
@Override
|
||||
protected void sendMessage(CommandSender sender, Component message) {
|
||||
if (CraftBukkitUtil.isChatCompatible() && sender instanceof Player) {
|
||||
if (CraftBukkitImplementation.isChatCompatible() && sender instanceof Player) {
|
||||
TextAdapter.sendComponent(sender, message);
|
||||
} else {
|
||||
// Fallback to legacy format
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
package me.lucko.luckperms.bukkit;
|
||||
|
||||
import me.lucko.luckperms.bukkit.compat.NullSafeConsoleCommandSender;
|
||||
import me.lucko.luckperms.bukkit.util.NullSafeConsoleCommandSender;
|
||||
import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader;
|
||||
import me.lucko.luckperms.common.dependencies.classloader.ReflectionClassLoader;
|
||||
import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
|
||||
|
@ -25,19 +25,19 @@
|
||||
|
||||
package me.lucko.luckperms.bukkit;
|
||||
|
||||
import me.lucko.luckperms.bukkit.brigadier.LuckPermsBrigadier;
|
||||
import me.lucko.luckperms.bukkit.calculator.BukkitCalculatorFactory;
|
||||
import me.lucko.luckperms.bukkit.compat.LuckPermsBrigadier;
|
||||
import me.lucko.luckperms.bukkit.context.BukkitContextManager;
|
||||
import me.lucko.luckperms.bukkit.context.WorldCalculator;
|
||||
import me.lucko.luckperms.bukkit.inject.permissible.LPPermissible;
|
||||
import me.lucko.luckperms.bukkit.inject.permissible.LuckPermsPermissible;
|
||||
import me.lucko.luckperms.bukkit.inject.permissible.PermissibleInjector;
|
||||
import me.lucko.luckperms.bukkit.inject.permissible.PermissibleMonitoringInjector;
|
||||
import me.lucko.luckperms.bukkit.inject.server.InjectorDefaultsMap;
|
||||
import me.lucko.luckperms.bukkit.inject.server.InjectorPermissionMap;
|
||||
import me.lucko.luckperms.bukkit.inject.server.InjectorSubscriptionMap;
|
||||
import me.lucko.luckperms.bukkit.inject.server.LPDefaultsMap;
|
||||
import me.lucko.luckperms.bukkit.inject.server.LPPermissionMap;
|
||||
import me.lucko.luckperms.bukkit.inject.server.LPSubscriptionMap;
|
||||
import me.lucko.luckperms.bukkit.inject.server.LuckPermsDefaultsMap;
|
||||
import me.lucko.luckperms.bukkit.inject.server.LuckPermsPermissionMap;
|
||||
import me.lucko.luckperms.bukkit.inject.server.LuckPermsSubscriptionMap;
|
||||
import me.lucko.luckperms.bukkit.listeners.BukkitConnectionListener;
|
||||
import me.lucko.luckperms.bukkit.listeners.BukkitPlatformListener;
|
||||
import me.lucko.luckperms.bukkit.messaging.BukkitMessagingFactory;
|
||||
@ -93,9 +93,9 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
||||
private StandardGroupManager groupManager;
|
||||
private StandardTrackManager trackManager;
|
||||
private BukkitContextManager contextManager;
|
||||
private LPSubscriptionMap subscriptionMap;
|
||||
private LPPermissionMap permissionMap;
|
||||
private LPDefaultsMap defaultPermissionMap;
|
||||
private LuckPermsSubscriptionMap subscriptionMap;
|
||||
private LuckPermsPermissionMap permissionMap;
|
||||
private LuckPermsDefaultsMap defaultPermissionMap;
|
||||
private VaultHookManager vaultHookManager = null;
|
||||
|
||||
public LPBukkitPlugin(LPBukkitBootstrap bootstrap) {
|
||||
@ -281,7 +281,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
||||
if (user != null) {
|
||||
this.bootstrap.getScheduler().executeSync(() -> {
|
||||
try {
|
||||
LPPermissible lpPermissible = new LPPermissible(player, user, this);
|
||||
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this);
|
||||
PermissibleInjector.inject(player, lpPermissible);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
@ -411,27 +411,27 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
||||
return this.contextManager;
|
||||
}
|
||||
|
||||
public LPSubscriptionMap getSubscriptionMap() {
|
||||
public LuckPermsSubscriptionMap getSubscriptionMap() {
|
||||
return this.subscriptionMap;
|
||||
}
|
||||
|
||||
public void setSubscriptionMap(LPSubscriptionMap subscriptionMap) {
|
||||
public void setSubscriptionMap(LuckPermsSubscriptionMap subscriptionMap) {
|
||||
this.subscriptionMap = subscriptionMap;
|
||||
}
|
||||
|
||||
public LPPermissionMap getPermissionMap() {
|
||||
public LuckPermsPermissionMap getPermissionMap() {
|
||||
return this.permissionMap;
|
||||
}
|
||||
|
||||
public void setPermissionMap(LPPermissionMap permissionMap) {
|
||||
public void setPermissionMap(LuckPermsPermissionMap permissionMap) {
|
||||
this.permissionMap = permissionMap;
|
||||
}
|
||||
|
||||
public LPDefaultsMap getDefaultPermissionMap() {
|
||||
public LuckPermsDefaultsMap getDefaultPermissionMap() {
|
||||
return this.defaultPermissionMap;
|
||||
}
|
||||
|
||||
public void setDefaultPermissionMap(LPDefaultsMap defaultPermissionMap) {
|
||||
public void setDefaultPermissionMap(LuckPermsDefaultsMap defaultPermissionMap) {
|
||||
this.defaultPermissionMap = defaultPermissionMap;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.bukkit.compat;
|
||||
package me.lucko.luckperms.bukkit.brigadier;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
@ -58,8 +58,18 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/**
|
||||
* Utility for registering LuckPerms command data to brigadier using {@link Commodore}.
|
||||
*/
|
||||
public class LuckPermsBrigadier {
|
||||
|
||||
/**
|
||||
* Registers LuckPerms command data for the given {@code pluginCommand}.
|
||||
*
|
||||
* @param plugin the luckperms plugin
|
||||
* @param pluginCommand the command
|
||||
* @throws Exception if something goes wrong
|
||||
*/
|
||||
public static void register(LPBukkitPlugin plugin, Command pluginCommand) throws Exception {
|
||||
// register completions with commodore
|
||||
Commodore commodore = CommodoreProvider.getCommodore(plugin.getBootstrap());
|
@ -72,7 +72,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* This class is **thread safe**. This means that when LuckPerms is installed on the server,
|
||||
* is is safe to call Player#hasPermission asynchronously.
|
||||
*/
|
||||
public class LPPermissible extends PermissibleBase {
|
||||
public class LuckPermsPermissible extends PermissibleBase {
|
||||
|
||||
private static final Field ATTACHMENTS_FIELD;
|
||||
|
||||
@ -105,9 +105,9 @@ public class LPPermissible extends PermissibleBase {
|
||||
|
||||
// the attachments hooked onto the permissible.
|
||||
// this collection is only modified by the attachments themselves
|
||||
final Set<LPPermissionAttachment> lpAttachments = ConcurrentHashMap.newKeySet();
|
||||
final Set<LuckPermsPermissionAttachment> hookedAttachments = ConcurrentHashMap.newKeySet();
|
||||
|
||||
public LPPermissible(Player player, User user, LPBukkitPlugin plugin) {
|
||||
public LuckPermsPermissible(Player player, User user, LPBukkitPlugin plugin) {
|
||||
super(player);
|
||||
this.user = Objects.requireNonNull(user, "user");
|
||||
this.player = Objects.requireNonNull(player, "player");
|
||||
@ -200,7 +200,7 @@ public class LPPermissible extends PermissibleBase {
|
||||
*/
|
||||
void convertAndAddAttachments(Collection<PermissionAttachment> attachments) {
|
||||
for (PermissionAttachment attachment : attachments) {
|
||||
new LPPermissionAttachment(this, attachment).hook();
|
||||
new LuckPermsPermissionAttachment(this, attachment).hook();
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,14 +217,14 @@ public class LPPermissible extends PermissibleBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull LPPermissionAttachment addAttachment(@NonNull Plugin plugin) {
|
||||
public @NonNull LuckPermsPermissionAttachment addAttachment(@NonNull Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new NullPointerException("plugin");
|
||||
}
|
||||
|
||||
LPPermissionAttachment ret = new LPPermissionAttachment(this, plugin);
|
||||
ret.hook();
|
||||
return ret;
|
||||
LuckPermsPermissionAttachment attachment = new LuckPermsPermissionAttachment(this, plugin);
|
||||
attachment.hook();
|
||||
return attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -236,13 +236,13 @@ public class LPPermissible extends PermissibleBase {
|
||||
throw new NullPointerException("permission");
|
||||
}
|
||||
|
||||
PermissionAttachment ret = addAttachment(plugin);
|
||||
ret.setPermission(permission, value);
|
||||
return ret;
|
||||
PermissionAttachment attachment = addAttachment(plugin);
|
||||
attachment.setPermission(permission, value);
|
||||
return attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LPPermissionAttachment addAttachment(@NonNull Plugin plugin, int ticks) {
|
||||
public LuckPermsPermissionAttachment addAttachment(@NonNull Plugin plugin, int ticks) {
|
||||
if (plugin == null) {
|
||||
throw new NullPointerException("plugin");
|
||||
}
|
||||
@ -251,16 +251,16 @@ public class LPPermissible extends PermissibleBase {
|
||||
throw new IllegalArgumentException("Plugin " + plugin.getDescription().getFullName() + " is not enabled");
|
||||
}
|
||||
|
||||
LPPermissionAttachment ret = addAttachment(plugin);
|
||||
if (getPlugin().getBootstrap().getServer().getScheduler().scheduleSyncDelayedTask(plugin, ret::remove, ticks) == -1) {
|
||||
ret.remove();
|
||||
LuckPermsPermissionAttachment attachment = addAttachment(plugin);
|
||||
if (getPlugin().getBootstrap().getServer().getScheduler().scheduleSyncDelayedTask(plugin, attachment::remove, ticks) == -1) {
|
||||
attachment.remove();
|
||||
throw new RuntimeException("Could not add PermissionAttachment to " + this.player + " for plugin " + plugin.getDescription().getFullName() + ": Scheduler returned -1");
|
||||
}
|
||||
return ret;
|
||||
return attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LPPermissionAttachment addAttachment(@NonNull Plugin plugin, @NonNull String permission, boolean value, int ticks) {
|
||||
public LuckPermsPermissionAttachment addAttachment(@NonNull Plugin plugin, @NonNull String permission, boolean value, int ticks) {
|
||||
if (plugin == null) {
|
||||
throw new NullPointerException("plugin");
|
||||
}
|
||||
@ -268,9 +268,9 @@ public class LPPermissible extends PermissibleBase {
|
||||
throw new NullPointerException("permission");
|
||||
}
|
||||
|
||||
LPPermissionAttachment ret = addAttachment(plugin, ticks);
|
||||
ret.setPermission(permission, value);
|
||||
return ret;
|
||||
LuckPermsPermissionAttachment attachment = addAttachment(plugin, ticks);
|
||||
attachment.setPermission(permission, value);
|
||||
return attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -279,25 +279,25 @@ public class LPPermissible extends PermissibleBase {
|
||||
throw new NullPointerException("attachment");
|
||||
}
|
||||
|
||||
LPPermissionAttachment a;
|
||||
LuckPermsPermissionAttachment luckPermsAttachment;
|
||||
|
||||
if (!(attachment instanceof LPPermissionAttachment)) {
|
||||
if (!(attachment instanceof LuckPermsPermissionAttachment)) {
|
||||
// try to find a match
|
||||
LPPermissionAttachment match = this.lpAttachments.stream().filter(at -> at.getSource() == attachment).findFirst().orElse(null);
|
||||
LuckPermsPermissionAttachment match = this.hookedAttachments.stream().filter(at -> at.getSource() == attachment).findFirst().orElse(null);
|
||||
if (match != null) {
|
||||
a = match;
|
||||
luckPermsAttachment = match;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Given attachment is not a LPPermissionAttachment.");
|
||||
}
|
||||
} else {
|
||||
a = (LPPermissionAttachment) attachment;
|
||||
luckPermsAttachment = (LuckPermsPermissionAttachment) attachment;
|
||||
}
|
||||
|
||||
if (a.getPermissible() != this) {
|
||||
if (luckPermsAttachment.getPermissible() != this) {
|
||||
throw new IllegalArgumentException("Attachment does not belong to this permissible.");
|
||||
}
|
||||
|
||||
a.remove();
|
||||
luckPermsAttachment.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -315,7 +315,7 @@ public class LPPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public void clearPermissions() {
|
||||
this.lpAttachments.forEach(LPPermissionAttachment::remove);
|
||||
this.hookedAttachments.forEach(LuckPermsPermissionAttachment::remove);
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
@ -355,11 +355,11 @@ public class LPPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public boolean add(PermissionAttachment attachment) {
|
||||
if (LPPermissible.this.lpAttachments.stream().anyMatch(at -> at.getSource() == attachment)) {
|
||||
if (LuckPermsPermissible.this.hookedAttachments.stream().anyMatch(at -> at.getSource() == attachment)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
new LPPermissionAttachment(LPPermissible.this, attachment).hook();
|
||||
new LuckPermsPermissionAttachment(LuckPermsPermissible.this, attachment).hook();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -388,27 +388,27 @@ public class LPPermissible extends PermissibleBase {
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
PermissionAttachment attachment = (PermissionAttachment) o;
|
||||
return LPPermissible.this.lpAttachments.stream().anyMatch(at -> at.getSource() == attachment);
|
||||
return LuckPermsPermissible.this.hookedAttachments.stream().anyMatch(at -> at.getSource() == attachment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<PermissionAttachment> iterator() {
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LPPermissible.this.lpAttachments).iterator();
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LuckPermsPermissible.this.hookedAttachments).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<PermissionAttachment> listIterator() {
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LPPermissible.this.lpAttachments).listIterator();
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LuckPermsPermissible.this.hookedAttachments).listIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Object[] toArray() {
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LPPermissible.this.lpAttachments).toArray();
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LuckPermsPermissible.this.hookedAttachments).toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull <T> T[] toArray(@NonNull T[] a) {
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LPPermissible.this.lpAttachments).toArray(a);
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LuckPermsPermissible.this.hookedAttachments).toArray(a);
|
||||
}
|
||||
|
||||
@Override public int size() { throw new UnsupportedOperationException(); }
|
@ -56,9 +56,9 @@ import java.util.Set;
|
||||
*
|
||||
* Applies all permissions directly to the backing user instance via transient nodes.
|
||||
*/
|
||||
public class LPPermissionAttachment extends PermissionAttachment {
|
||||
public class LuckPermsPermissionAttachment extends PermissionAttachment {
|
||||
|
||||
public static final NodeMetadataKey<LPPermissionAttachment> TRANSIENT_SOURCE_KEY = NodeMetadataKey.of("transientsource", LPPermissionAttachment.class);
|
||||
public static final NodeMetadataKey<LuckPermsPermissionAttachment> TRANSIENT_SOURCE_KEY = NodeMetadataKey.of("transientsource", LuckPermsPermissionAttachment.class);
|
||||
|
||||
/**
|
||||
* The field in PermissionAttachment where the attachments applied permissions
|
||||
@ -78,7 +78,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
/**
|
||||
* The parent LPPermissible
|
||||
*/
|
||||
private final LPPermissible permissible;
|
||||
private final LuckPermsPermissible permissible;
|
||||
|
||||
/**
|
||||
* The plugin which "owns" this attachment, may be null
|
||||
@ -105,7 +105,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
*/
|
||||
private PermissionAttachment source;
|
||||
|
||||
public LPPermissionAttachment(LPPermissible permissible, Plugin owner) {
|
||||
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, Plugin owner) {
|
||||
super(DummyPlugin.INSTANCE, null);
|
||||
this.permissible = permissible;
|
||||
this.owner = owner;
|
||||
@ -113,7 +113,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
injectFakeMap();
|
||||
}
|
||||
|
||||
public LPPermissionAttachment(LPPermissible permissible, PermissionAttachment source) {
|
||||
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, PermissionAttachment source) {
|
||||
super(DummyPlugin.INSTANCE, null);
|
||||
this.permissible = permissible;
|
||||
this.owner = source.getPlugin();
|
||||
@ -146,7 +146,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull LPPermissible getPermissible() {
|
||||
public @NonNull LuckPermsPermissible getPermissible() {
|
||||
return this.permissible;
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
*/
|
||||
public void hook() {
|
||||
this.hooked = true;
|
||||
this.permissible.lpAttachments.add(this);
|
||||
this.permissible.hookedAttachments.add(this);
|
||||
for (Map.Entry<String, Boolean> entry : this.perms.entrySet()) {
|
||||
if (entry.getKey() == null || entry.getKey().isEmpty()) {
|
||||
continue;
|
||||
@ -231,7 +231,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
|
||||
// unhook from the permissible
|
||||
this.hooked = false;
|
||||
this.permissible.lpAttachments.remove(this);
|
||||
this.permissible.hookedAttachments.remove(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
@Override
|
||||
public Boolean put(String key, Boolean value) {
|
||||
// grab the previous result, so we can still satisfy the method signature of Map
|
||||
Boolean previous = LPPermissionAttachment.this.perms.get(key);
|
||||
Boolean previous = LuckPermsPermissionAttachment.this.perms.get(key);
|
||||
|
||||
// proxy the call back through the PermissionAttachment instance
|
||||
setPermission(key, value);
|
||||
@ -335,7 +335,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
String permission = ((String) key);
|
||||
|
||||
// grab the previous result, so we can still satisfy the method signature of Map
|
||||
Boolean previous = LPPermissionAttachment.this.perms.get(permission);
|
||||
Boolean previous = LuckPermsPermissionAttachment.this.perms.get(permission);
|
||||
|
||||
// proxy the call back through the PermissionAttachment instance
|
||||
unsetPermission(permission);
|
||||
@ -354,71 +354,71 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
@Override
|
||||
public void clear() {
|
||||
// remove the permissions which have already been applied
|
||||
if (LPPermissionAttachment.this.hooked) {
|
||||
if (LuckPermsPermissionAttachment.this.hooked) {
|
||||
clearInternal();
|
||||
}
|
||||
|
||||
// clear the backing map
|
||||
LPPermissionAttachment.this.perms.clear();
|
||||
LuckPermsPermissionAttachment.this.perms.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
// return the size of the permissions map - probably the most accurate value we have
|
||||
return LPPermissionAttachment.this.perms.size();
|
||||
return LuckPermsPermissionAttachment.this.perms.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
// return if the permissions map is empty - again probably the most accurate thing
|
||||
// we can return
|
||||
return LPPermissionAttachment.this.perms.isEmpty();
|
||||
return LuckPermsPermissionAttachment.this.perms.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
// just proxy
|
||||
return LPPermissionAttachment.this.perms.containsKey(key);
|
||||
return LuckPermsPermissionAttachment.this.perms.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
// just proxy
|
||||
return LPPermissionAttachment.this.perms.containsValue(value);
|
||||
return LuckPermsPermissionAttachment.this.perms.containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean get(Object key) {
|
||||
// just proxy
|
||||
return LPPermissionAttachment.this.perms.get(key);
|
||||
return LuckPermsPermissionAttachment.this.perms.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> keySet() {
|
||||
// just proxy
|
||||
return Collections.unmodifiableSet(LPPermissionAttachment.this.perms.keySet());
|
||||
return Collections.unmodifiableSet(LuckPermsPermissionAttachment.this.perms.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Boolean> values() {
|
||||
// just proxy
|
||||
return Collections.unmodifiableCollection(LPPermissionAttachment.this.perms.values());
|
||||
return Collections.unmodifiableCollection(LuckPermsPermissionAttachment.this.perms.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Entry<String, Boolean>> entrySet() {
|
||||
// just proxy
|
||||
return Collections.unmodifiableSet(LPPermissionAttachment.this.perms.entrySet());
|
||||
return Collections.unmodifiableSet(LuckPermsPermissionAttachment.this.perms.entrySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof Map<?, ?> && LPPermissionAttachment.this.perms.equals(obj);
|
||||
return obj instanceof Map<?, ?> && LuckPermsPermissionAttachment.this.perms.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return LPPermissionAttachment.this.perms.hashCode();
|
||||
return LuckPermsPermissionAttachment.this.perms.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
@ -25,8 +25,8 @@
|
||||
|
||||
package me.lucko.luckperms.bukkit.inject.permissible;
|
||||
|
||||
import me.lucko.luckperms.bukkit.compat.CraftBukkitUtil;
|
||||
import me.lucko.luckperms.bukkit.inject.dummy.DummyPermissibleBase;
|
||||
import me.lucko.luckperms.bukkit.util.CraftBukkitImplementation;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissibleBase;
|
||||
@ -36,7 +36,7 @@ import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Injects a {@link LPPermissible} into a {@link Player}.
|
||||
* Injects a {@link LuckPermsPermissible} into a {@link Player}.
|
||||
*
|
||||
* This allows LuckPerms to directly intercept permission checks and take over all handling of
|
||||
* checks made by plugins.
|
||||
@ -63,7 +63,7 @@ public final class PermissibleInjector {
|
||||
Field humanEntityPermissibleField;
|
||||
try {
|
||||
// craftbukkit
|
||||
humanEntityPermissibleField = CraftBukkitUtil.obcClass("entity.CraftHumanEntity").getDeclaredField("perm");
|
||||
humanEntityPermissibleField = CraftBukkitImplementation.obcClass("entity.CraftHumanEntity").getDeclaredField("perm");
|
||||
humanEntityPermissibleField.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
// glowstone
|
||||
@ -81,19 +81,19 @@ public final class PermissibleInjector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects a {@link LPPermissible} into a {@link Player}.
|
||||
* Injects a {@link LuckPermsPermissible} into a {@link Player}.
|
||||
*
|
||||
* @param player the player to inject into
|
||||
* @param newPermissible the permissible to inject
|
||||
* @throws Exception propagates any exceptions which were thrown during injection
|
||||
*/
|
||||
public static void inject(Player player, LPPermissible newPermissible) throws Exception {
|
||||
public static void inject(Player player, LuckPermsPermissible newPermissible) throws Exception {
|
||||
|
||||
// get the existing PermissibleBase held by the player
|
||||
PermissibleBase oldPermissible = (PermissibleBase) HUMAN_ENTITY_PERMISSIBLE_FIELD.get(player);
|
||||
|
||||
// seems we have already injected into this player.
|
||||
if (oldPermissible instanceof LPPermissible) {
|
||||
if (oldPermissible instanceof LuckPermsPermissible) {
|
||||
throw new IllegalStateException("LPPermissible already injected into player " + player.toString());
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ public final class PermissibleInjector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninjects a {@link LPPermissible} from a {@link Player}.
|
||||
* Uninjects a {@link LuckPermsPermissible} from a {@link Player}.
|
||||
*
|
||||
* @param player the player to uninject from
|
||||
* @param dummy if the replacement permissible should be a dummy.
|
||||
@ -127,8 +127,8 @@ public final class PermissibleInjector {
|
||||
PermissibleBase permissible = (PermissibleBase) HUMAN_ENTITY_PERMISSIBLE_FIELD.get(player);
|
||||
|
||||
// only uninject if the permissible was a luckperms one.
|
||||
if (permissible instanceof LPPermissible) {
|
||||
LPPermissible lpPermissible = ((LPPermissible) permissible);
|
||||
if (permissible instanceof LuckPermsPermissible) {
|
||||
LuckPermsPermissible lpPermissible = ((LuckPermsPermissible) permissible);
|
||||
|
||||
// clear all permissions
|
||||
lpPermissible.clearPermissions();
|
||||
|
@ -26,7 +26,7 @@
|
||||
package me.lucko.luckperms.bukkit.inject.permissible;
|
||||
|
||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||
import me.lucko.luckperms.bukkit.compat.CraftBukkitUtil;
|
||||
import me.lucko.luckperms.bukkit.util.CraftBukkitImplementation;
|
||||
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.permissions.PermissibleBase;
|
||||
@ -101,7 +101,7 @@ public class PermissibleMonitoringInjector implements Runnable {
|
||||
ConsoleCommandSender consoleSender = this.plugin.getBootstrap().getServer().getConsoleSender();
|
||||
|
||||
// get the ServerCommandSender class
|
||||
Class<?> serverCommandSenderClass = CraftBukkitUtil.obcClass("command.ServerCommandSender");
|
||||
Class<?> serverCommandSenderClass = CraftBukkitImplementation.obcClass("command.ServerCommandSender");
|
||||
|
||||
// get the perm field
|
||||
Field permField = serverCommandSenderClass.getDeclaredField("perm");
|
||||
@ -122,7 +122,7 @@ public class PermissibleMonitoringInjector implements Runnable {
|
||||
|
||||
private void injectCommandBlock() throws Exception {
|
||||
// get the ServerCommandSender class
|
||||
Class<?> serverCommandSenderClass = CraftBukkitUtil.obcClass("command.ServerCommandSender");
|
||||
Class<?> serverCommandSenderClass = CraftBukkitImplementation.obcClass("command.ServerCommandSender");
|
||||
|
||||
// get the blockPermInst field
|
||||
Field permField = serverCommandSenderClass.getDeclaredField("blockPermInst");
|
||||
@ -149,7 +149,7 @@ public class PermissibleMonitoringInjector implements Runnable {
|
||||
|
||||
private void injectEntity() throws Exception {
|
||||
// get the CraftEntity class
|
||||
Class<?> entityClass = CraftBukkitUtil.obcClass("entity.CraftEntity");
|
||||
Class<?> entityClass = CraftBukkitImplementation.obcClass("entity.CraftEntity");
|
||||
|
||||
// get the method used to obtain a PermissibleBase
|
||||
// this method will initialise a new PB instance if one doesn't yet exist
|
||||
|
@ -39,7 +39,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Injects a {@link LPDefaultsMap} info the {@link PluginManager}.
|
||||
* Injects a {@link LuckPermsDefaultsMap} info the {@link PluginManager}.
|
||||
*/
|
||||
public class InjectorDefaultsMap implements Runnable {
|
||||
private static final Field DEFAULT_PERMISSIONS_FIELD;
|
||||
@ -64,9 +64,9 @@ public class InjectorDefaultsMap implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LPDefaultsMap ret = inject();
|
||||
if (ret != null) {
|
||||
this.plugin.setDefaultPermissionMap(ret);
|
||||
LuckPermsDefaultsMap defaultsMap = inject();
|
||||
if (defaultsMap != null) {
|
||||
this.plugin.setDefaultPermissionMap(defaultsMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Default Permission map.");
|
||||
@ -74,7 +74,7 @@ public class InjectorDefaultsMap implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private LPDefaultsMap inject() throws Exception {
|
||||
private LuckPermsDefaultsMap inject() throws Exception {
|
||||
Objects.requireNonNull(DEFAULT_PERMISSIONS_FIELD, "DEFAULT_PERMISSIONS_FIELD");
|
||||
PluginManager pluginManager = this.plugin.getBootstrap().getServer().getPluginManager();
|
||||
|
||||
@ -85,7 +85,7 @@ public class InjectorDefaultsMap implements Runnable {
|
||||
}
|
||||
|
||||
Object map = DEFAULT_PERMISSIONS_FIELD.get(pluginManager);
|
||||
if (map instanceof LPDefaultsMap && ((LPDefaultsMap) map).plugin == this.plugin) {
|
||||
if (map instanceof LuckPermsDefaultsMap && ((LuckPermsDefaultsMap) map).plugin == this.plugin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ public class InjectorDefaultsMap implements Runnable {
|
||||
Map<Boolean, Set<Permission>> castedMap = (Map<Boolean, Set<Permission>>) map;
|
||||
|
||||
// make a new map & inject it
|
||||
LPDefaultsMap newMap = new LPDefaultsMap(this.plugin, castedMap);
|
||||
LuckPermsDefaultsMap newMap = new LuckPermsDefaultsMap(this.plugin, castedMap);
|
||||
DEFAULT_PERMISSIONS_FIELD.set(pluginManager, newMap);
|
||||
return newMap;
|
||||
}
|
||||
@ -108,8 +108,8 @@ public class InjectorDefaultsMap implements Runnable {
|
||||
}
|
||||
|
||||
Object map = DEFAULT_PERMISSIONS_FIELD.get(pluginManager);
|
||||
if (map instanceof LPDefaultsMap) {
|
||||
LPDefaultsMap lpMap = (LPDefaultsMap) map;
|
||||
if (map instanceof LuckPermsDefaultsMap) {
|
||||
LuckPermsDefaultsMap lpMap = (LuckPermsDefaultsMap) map;
|
||||
DEFAULT_PERMISSIONS_FIELD.set(pluginManager, new HashMap<>(lpMap));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -38,7 +38,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Injects a {@link LPPermissionMap} into the {@link PluginManager}.
|
||||
* Injects a {@link LuckPermsPermissionMap} into the {@link PluginManager}.
|
||||
*/
|
||||
public class InjectorPermissionMap implements Runnable {
|
||||
private static final Field PERMISSIONS_FIELD;
|
||||
@ -63,9 +63,9 @@ public class InjectorPermissionMap implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LPPermissionMap ret = inject();
|
||||
if (ret != null) {
|
||||
this.plugin.setPermissionMap(ret);
|
||||
LuckPermsPermissionMap permissionMap = inject();
|
||||
if (permissionMap != null) {
|
||||
this.plugin.setPermissionMap(permissionMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Permission map.");
|
||||
@ -73,7 +73,7 @@ public class InjectorPermissionMap implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private LPPermissionMap inject() throws Exception {
|
||||
private LuckPermsPermissionMap inject() throws Exception {
|
||||
Objects.requireNonNull(PERMISSIONS_FIELD, "PERMISSIONS_FIELD");
|
||||
PluginManager pluginManager = this.plugin.getBootstrap().getServer().getPluginManager();
|
||||
|
||||
@ -84,7 +84,7 @@ public class InjectorPermissionMap implements Runnable {
|
||||
}
|
||||
|
||||
Object map = PERMISSIONS_FIELD.get(pluginManager);
|
||||
if (map instanceof LPPermissionMap && ((LPPermissionMap) map).plugin == this.plugin) {
|
||||
if (map instanceof LuckPermsPermissionMap && ((LuckPermsPermissionMap) map).plugin == this.plugin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class InjectorPermissionMap implements Runnable {
|
||||
Map<String, Permission> castedMap = (Map<String, Permission>) map;
|
||||
|
||||
// make a new map & inject it
|
||||
LPPermissionMap newMap = new LPPermissionMap(this.plugin, castedMap);
|
||||
LuckPermsPermissionMap newMap = new LuckPermsPermissionMap(this.plugin, castedMap);
|
||||
PERMISSIONS_FIELD.set(pluginManager, newMap);
|
||||
return newMap;
|
||||
}
|
||||
@ -107,8 +107,8 @@ public class InjectorPermissionMap implements Runnable {
|
||||
}
|
||||
|
||||
Object map = PERMISSIONS_FIELD.get(pluginManager);
|
||||
if (map instanceof LPPermissionMap) {
|
||||
LPPermissionMap lpMap = (LPPermissionMap) map;
|
||||
if (map instanceof LuckPermsPermissionMap) {
|
||||
LuckPermsPermissionMap lpMap = (LuckPermsPermissionMap) map;
|
||||
PERMISSIONS_FIELD.set(pluginManager, new HashMap<>(lpMap));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -37,7 +37,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Injects a {@link LPSubscriptionMap} into the {@link PluginManager}.
|
||||
* Injects a {@link LuckPermsSubscriptionMap} into the {@link PluginManager}.
|
||||
*/
|
||||
public class InjectorSubscriptionMap implements Runnable {
|
||||
private static final Field PERM_SUBS_FIELD;
|
||||
@ -62,9 +62,9 @@ public class InjectorSubscriptionMap implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LPSubscriptionMap ret = inject();
|
||||
if (ret != null) {
|
||||
this.plugin.setSubscriptionMap(ret);
|
||||
LuckPermsSubscriptionMap subscriptionMap = inject();
|
||||
if (subscriptionMap != null) {
|
||||
this.plugin.setSubscriptionMap(subscriptionMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Permission Subscription map.");
|
||||
@ -72,7 +72,7 @@ public class InjectorSubscriptionMap implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private LPSubscriptionMap inject() throws Exception {
|
||||
private LuckPermsSubscriptionMap inject() throws Exception {
|
||||
Objects.requireNonNull(PERM_SUBS_FIELD, "PERM_SUBS_FIELD");
|
||||
PluginManager pluginManager = this.plugin.getBootstrap().getServer().getPluginManager();
|
||||
|
||||
@ -83,19 +83,19 @@ public class InjectorSubscriptionMap implements Runnable {
|
||||
}
|
||||
|
||||
Object map = PERM_SUBS_FIELD.get(pluginManager);
|
||||
if (map instanceof LPSubscriptionMap) {
|
||||
if (((LPSubscriptionMap) map).plugin == this.plugin) {
|
||||
if (map instanceof LuckPermsSubscriptionMap) {
|
||||
if (((LuckPermsSubscriptionMap) map).plugin == this.plugin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
map = ((LPSubscriptionMap) map).detach();
|
||||
map = ((LuckPermsSubscriptionMap) map).detach();
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
Map<String, Map<Permissible, Boolean>> castedMap = (Map<String, Map<Permissible, Boolean>>) map;
|
||||
|
||||
// make a new subscription map & inject it
|
||||
LPSubscriptionMap newMap = new LPSubscriptionMap(this.plugin, castedMap);
|
||||
LuckPermsSubscriptionMap newMap = new LuckPermsSubscriptionMap(this.plugin, castedMap);
|
||||
PERM_SUBS_FIELD.set(pluginManager, newMap);
|
||||
return newMap;
|
||||
}
|
||||
@ -110,8 +110,8 @@ public class InjectorSubscriptionMap implements Runnable {
|
||||
}
|
||||
|
||||
Object map = PERM_SUBS_FIELD.get(pluginManager);
|
||||
if (map instanceof LPSubscriptionMap) {
|
||||
LPSubscriptionMap lpMap = (LPSubscriptionMap) map;
|
||||
if (map instanceof LuckPermsSubscriptionMap) {
|
||||
LuckPermsSubscriptionMap lpMap = (LuckPermsSubscriptionMap) map;
|
||||
PERM_SUBS_FIELD.set(pluginManager, lpMap.detach());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -56,7 +56,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*
|
||||
* Injected by {@link InjectorDefaultsMap}.
|
||||
*/
|
||||
public final class LPDefaultsMap implements Map<Boolean, Set<Permission>> {
|
||||
public final class LuckPermsDefaultsMap implements Map<Boolean, Set<Permission>> {
|
||||
// keyset for all instances
|
||||
private static final Set<Boolean> KEY_SET = ImmutableSet.of(Boolean.TRUE, Boolean.FALSE);
|
||||
|
||||
@ -78,7 +78,7 @@ public final class LPDefaultsMap implements Map<Boolean, Set<Permission>> {
|
||||
Maps.immutableEntry(Boolean.FALSE, this.nonOpSet)
|
||||
);
|
||||
|
||||
public LPDefaultsMap(LPBukkitPlugin plugin, Map<Boolean, Set<Permission>> existingData) {
|
||||
public LuckPermsDefaultsMap(LPBukkitPlugin plugin, Map<Boolean, Set<Permission>> existingData) {
|
||||
this.plugin = plugin;
|
||||
this.opSet.addAll(existingData.getOrDefault(Boolean.TRUE, Collections.emptySet()));
|
||||
this.nonOpSet.addAll(existingData.getOrDefault(Boolean.FALSE, Collections.emptySet()));
|
||||
@ -142,10 +142,10 @@ public final class LPDefaultsMap implements Map<Boolean, Set<Permission>> {
|
||||
@Override
|
||||
protected @NonNull Map<String, Boolean> supply() {
|
||||
Map<String, Boolean> builder = new HashMap<>();
|
||||
for (Permission perm : LPDefaultsMap.this.get(this.op)) {
|
||||
for (Permission perm : LuckPermsDefaultsMap.this.get(this.op)) {
|
||||
String name = perm.getName().toLowerCase();
|
||||
builder.put(name, true);
|
||||
for (Map.Entry<String, Boolean> child : LPDefaultsMap.this.plugin.getPermissionMap().getChildPermissions(name, true).entrySet()) {
|
||||
for (Map.Entry<String, Boolean> child : LuckPermsDefaultsMap.this.plugin.getPermissionMap().getChildPermissions(name, true).entrySet()) {
|
||||
builder.putIfAbsent(child.getKey(), child.getValue());
|
||||
}
|
||||
}
|
@ -57,7 +57,7 @@ import java.util.function.Function;
|
||||
*
|
||||
* Injected by {@link InjectorPermissionMap}.
|
||||
*/
|
||||
public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
||||
public final class LuckPermsPermissionMap extends ForwardingMap<String, Permission> {
|
||||
|
||||
private static final Field PERMISSION_CHILDREN_FIELD;
|
||||
|
||||
@ -82,7 +82,7 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
||||
*/
|
||||
final LuckPermsPlugin plugin;
|
||||
|
||||
public LPPermissionMap(LuckPermsPlugin plugin, Map<String, Permission> existingData) {
|
||||
public LuckPermsPermissionMap(LuckPermsPlugin plugin, Map<String, Permission> existingData) {
|
||||
this.plugin = plugin;
|
||||
putAll(existingData);
|
||||
}
|
||||
@ -198,11 +198,11 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
||||
try {
|
||||
//noinspection unchecked
|
||||
Map<String, Boolean> children = (Map<String, Boolean>) PERMISSION_CHILDREN_FIELD.get(permission);
|
||||
while (children instanceof PermissionNotifyingChildrenMap) {
|
||||
children = ((PermissionNotifyingChildrenMap) children).delegate;
|
||||
while (children instanceof NotifyingChildrenMap) {
|
||||
children = ((NotifyingChildrenMap) children).delegate;
|
||||
}
|
||||
|
||||
PermissionNotifyingChildrenMap notifyingChildren = new PermissionNotifyingChildrenMap(children);
|
||||
NotifyingChildrenMap notifyingChildren = new NotifyingChildrenMap(children);
|
||||
PERMISSION_CHILDREN_FIELD.set(permission, notifyingChildren);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -218,8 +218,8 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
||||
try {
|
||||
//noinspection unchecked
|
||||
Map<String, Boolean> children = (Map<String, Boolean>) PERMISSION_CHILDREN_FIELD.get(permission);
|
||||
while (children instanceof PermissionNotifyingChildrenMap) {
|
||||
children = ((PermissionNotifyingChildrenMap) children).delegate;
|
||||
while (children instanceof NotifyingChildrenMap) {
|
||||
children = ((NotifyingChildrenMap) children).delegate;
|
||||
}
|
||||
PERMISSION_CHILDREN_FIELD.set(permission, children);
|
||||
} catch (Exception e) {
|
||||
@ -228,10 +228,10 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
||||
return permission;
|
||||
}
|
||||
|
||||
private final class PermissionNotifyingChildrenMap extends ForwardingMap<String, Boolean> {
|
||||
private final class NotifyingChildrenMap extends ForwardingMap<String, Boolean> {
|
||||
private final Map<String, Boolean> delegate;
|
||||
|
||||
PermissionNotifyingChildrenMap(Map<String, Boolean> delegate) {
|
||||
NotifyingChildrenMap(Map<String, Boolean> delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@ -243,27 +243,27 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
||||
@Override
|
||||
public Boolean put(@NonNull String key, @NonNull Boolean value) {
|
||||
Boolean ret = super.put(key, value);
|
||||
LPPermissionMap.this.update();
|
||||
LuckPermsPermissionMap.this.update();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(@NonNull Map<? extends String, ? extends Boolean> map) {
|
||||
super.putAll(map);
|
||||
LPPermissionMap.this.update();
|
||||
LuckPermsPermissionMap.this.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean remove(@NonNull Object object) {
|
||||
Boolean ret = super.remove(object);
|
||||
LPPermissionMap.this.update();
|
||||
LuckPermsPermissionMap.this.update();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
LPPermissionMap.this.update();
|
||||
LuckPermsPermissionMap.this.update();
|
||||
}
|
||||
}
|
||||
|
@ -66,12 +66,12 @@ import java.util.stream.Collectors;
|
||||
*
|
||||
* Injected by {@link InjectorSubscriptionMap}.
|
||||
*/
|
||||
public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Boolean>> {
|
||||
public final class LuckPermsSubscriptionMap extends HashMap<String, Map<Permissible, Boolean>> {
|
||||
|
||||
// the plugin instance
|
||||
final LPBukkitPlugin plugin;
|
||||
|
||||
public LPSubscriptionMap(LPBukkitPlugin plugin, Map<String, Map<Permissible, Boolean>> existingData) {
|
||||
public LuckPermsSubscriptionMap(LPBukkitPlugin plugin, Map<String, Map<Permissible, Boolean>> existingData) {
|
||||
super(existingData);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@ -133,17 +133,17 @@ public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Bo
|
||||
* @return a standard representation of this map
|
||||
*/
|
||||
public Map<String, Map<Permissible, Boolean>> detach() {
|
||||
Map<String, Map<Permissible, Boolean>> ret = new HashMap<>();
|
||||
Map<String, Map<Permissible, Boolean>> map = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, Map<Permissible, Boolean>> ent : entrySet()) {
|
||||
if (ent.getValue() instanceof LPSubscriptionValueMap) {
|
||||
ret.put(ent.getKey(), ((LPSubscriptionValueMap) ent.getValue()).backing);
|
||||
map.put(ent.getKey(), ((LPSubscriptionValueMap) ent.getValue()).backing);
|
||||
} else {
|
||||
ret.put(ent.getKey(), ent.getValue());
|
||||
map.put(ent.getKey(), ent.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,7 +219,7 @@ public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Bo
|
||||
@Override
|
||||
public @NonNull Set<Permissible> keySet() {
|
||||
// gather players (LPPermissibles)
|
||||
Set<Permissible> players = LPSubscriptionMap.this.plugin.getBootstrap().getServer().getOnlinePlayers().stream()
|
||||
Set<Permissible> players = LuckPermsSubscriptionMap.this.plugin.getBootstrap().getServer().getOnlinePlayers().stream()
|
||||
.filter(player -> player.hasPermission(this.permission) || player.isPermissionSet(this.permission))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
@ -230,9 +230,9 @@ public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Bo
|
||||
@Override
|
||||
public @NonNull Set<Entry<Permissible, Boolean>> entrySet() {
|
||||
return keySet().stream()
|
||||
.map(p -> {
|
||||
Boolean ret = get(p);
|
||||
return ret != null ? Maps.immutableEntry(p, ret) : null;
|
||||
.map(key -> {
|
||||
Boolean value = get(key);
|
||||
return value != null ? Maps.immutableEntry(key, value) : null;
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(ImmutableCollectors.toSet());
|
@ -26,7 +26,7 @@
|
||||
package me.lucko.luckperms.bukkit.listeners;
|
||||
|
||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||
import me.lucko.luckperms.bukkit.inject.permissible.LPPermissible;
|
||||
import me.lucko.luckperms.bukkit.inject.permissible.LuckPermsPermissible;
|
||||
import me.lucko.luckperms.bukkit.inject.permissible.PermissibleInjector;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
@ -187,7 +187,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
||||
// Care should be taken at this stage to ensure that async tasks which manipulate bukkit data check that the player is still online.
|
||||
try {
|
||||
// Make a new permissible for the user
|
||||
LPPermissible lpPermissible = new LPPermissible(player, user, this.plugin);
|
||||
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this.plugin);
|
||||
|
||||
// Inject into the player
|
||||
PermissibleInjector.inject(player, lpPermissible);
|
||||
|
@ -23,12 +23,12 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.bukkit.compat;
|
||||
package me.lucko.luckperms.bukkit.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public final class CraftBukkitUtil {
|
||||
private CraftBukkitUtil() {}
|
||||
public final class CraftBukkitImplementation {
|
||||
private CraftBukkitImplementation() {}
|
||||
|
||||
private static final String SERVER_PACKAGE_VERSION = getServerPackageVersion();
|
||||
private static final boolean CHAT_COMPATIBLE = !SERVER_PACKAGE_VERSION.startsWith(".v1_7_");
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.bukkit.compat;
|
||||
package me.lucko.luckperms.bukkit.util;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
@ -45,7 +45,7 @@ import java.util.function.Function;
|
||||
* to get a result using the players username.
|
||||
*
|
||||
* Whilst this meant the old plugins would still be supported, it made the whole
|
||||
* API a total mess. This class reverses this decision, and instead upgrades
|
||||
* API a total mess. This class reverses this action, and instead upgrades
|
||||
* requests to use UUIDs. This makes implementing Vault significantly easier for modern
|
||||
* plugins, and because requests are upgraded instead of being downgraded then upgraded,
|
||||
* much faster for plugins querying data.
|
||||
@ -88,10 +88,10 @@ public abstract class AbstractVaultChat extends Chat {
|
||||
// utility methods for parsing metadata values from strings
|
||||
|
||||
private static String strConvert(String s, String def) {
|
||||
if (s != null) {
|
||||
return s;
|
||||
if (s == null) {
|
||||
return def;
|
||||
}
|
||||
return def;
|
||||
return s;
|
||||
}
|
||||
|
||||
private static int intConvert(String s, int def) {
|
||||
@ -124,21 +124,15 @@ public abstract class AbstractVaultChat extends Chat {
|
||||
return true;
|
||||
} else if (s.equalsIgnoreCase("false")) {
|
||||
return false;
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
private String world(String world) {
|
||||
return this.worldMappingFunction.apply(world);
|
||||
}
|
||||
|
||||
private String world(Player player) {
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
return world(player.getWorld());
|
||||
}
|
||||
|
||||
private String world(World world) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
@ -146,6 +140,13 @@ public abstract class AbstractVaultChat extends Chat {
|
||||
return world(world.getName());
|
||||
}
|
||||
|
||||
private String world(Player player) {
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
return world(player.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getPlayerPrefix(String world, String player) {
|
||||
Objects.requireNonNull(player, "player");
|
||||
|
@ -46,7 +46,7 @@ import java.util.function.Function;
|
||||
* to get a result using the players username.
|
||||
*
|
||||
* Whilst this meant the old plugins would still be supported, it made the whole
|
||||
* API a total mess. This class reverses this decision, and instead upgrades
|
||||
* API a total mess. This class reverses this action, and instead upgrades
|
||||
* requests to use UUIDs. This makes implementing Vault significantly easier for modern
|
||||
* plugins, and because requests are upgraded instead of being downgraded then upgraded,
|
||||
* much faster for plugins querying data.
|
||||
@ -98,13 +98,6 @@ public abstract class AbstractVaultPermission extends Permission {
|
||||
return this.worldMappingFunction.apply(world);
|
||||
}
|
||||
|
||||
private String world(Player player) {
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
return world(player.getWorld());
|
||||
}
|
||||
|
||||
private String world(World world) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
@ -112,6 +105,13 @@ public abstract class AbstractVaultPermission extends Permission {
|
||||
return world(world.getName());
|
||||
}
|
||||
|
||||
private String world(Player player) {
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
return world(player.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean has(String world, String player, String permission) {
|
||||
Objects.requireNonNull(player, "player");
|
||||
|
@ -93,11 +93,11 @@ public class LuckPermsVaultChat extends AbstractVaultChat {
|
||||
PermissionHolder user = this.vaultPermission.lookupUser(uuid);
|
||||
QueryOptions queryOptions = this.vaultPermission.getQueryOptions(uuid, world);
|
||||
MetaCache metaData = user.getCachedData().getMetaData(queryOptions);
|
||||
String ret = metaData.getPrefix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||
String prefix = metaData.getPrefix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||
if (log()) {
|
||||
logMsg("#getUserChatPrefix: %s - %s - %s", user.getPlainDisplayName(), queryOptions.context(), ret);
|
||||
logMsg("#getUserChatPrefix: %s - %s - %s", user.getPlainDisplayName(), queryOptions.context(), prefix);
|
||||
}
|
||||
return Strings.nullToEmpty(ret);
|
||||
return Strings.nullToEmpty(prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -107,11 +107,11 @@ public class LuckPermsVaultChat extends AbstractVaultChat {
|
||||
PermissionHolder user = this.vaultPermission.lookupUser(uuid);
|
||||
QueryOptions queryOptions = this.vaultPermission.getQueryOptions(uuid, world);
|
||||
MetaCache metaData = user.getCachedData().getMetaData(queryOptions);
|
||||
String ret = metaData.getSuffix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||
String suffix = metaData.getSuffix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||
if (log()) {
|
||||
logMsg("#getUserChatSuffix: %s - %s - %s", user.getPlainDisplayName(), queryOptions.context(), ret);
|
||||
logMsg("#getUserChatSuffix: %s - %s - %s", user.getPlainDisplayName(), queryOptions.context(), suffix);
|
||||
}
|
||||
return Strings.nullToEmpty(ret);
|
||||
return Strings.nullToEmpty(suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -144,11 +144,11 @@ public class LuckPermsVaultChat extends AbstractVaultChat {
|
||||
PermissionHolder user = this.vaultPermission.lookupUser(uuid);
|
||||
QueryOptions queryOptions = this.vaultPermission.getQueryOptions(uuid, world);
|
||||
MetaCache metaData = user.getCachedData().getMetaData(queryOptions);
|
||||
String ret = metaData.getMetaValue(key, MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||
String value = metaData.getMetaValue(key, MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||
if (log()) {
|
||||
logMsg("#getUserMeta: %s - %s - %s - %s", user.getPlainDisplayName(), queryOptions.context(), key, ret);
|
||||
logMsg("#getUserMeta: %s - %s - %s - %s", user.getPlainDisplayName(), queryOptions.context(), key, value);
|
||||
}
|
||||
return ret;
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -172,11 +172,11 @@ public class LuckPermsVaultChat extends AbstractVaultChat {
|
||||
}
|
||||
QueryOptions queryOptions = this.vaultPermission.getQueryOptions(null, world);
|
||||
MetaCache metaData = group.getCachedData().getMetaData(queryOptions);
|
||||
String ret = metaData.getPrefix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||
String prefix = metaData.getPrefix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||
if (log()) {
|
||||
logMsg("#getGroupPrefix: %s - %s - %s", group.getName(), queryOptions.context(), ret);
|
||||
logMsg("#getGroupPrefix: %s - %s - %s", group.getName(), queryOptions.context(), prefix);
|
||||
}
|
||||
return Strings.nullToEmpty(ret);
|
||||
return Strings.nullToEmpty(prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -188,11 +188,11 @@ public class LuckPermsVaultChat extends AbstractVaultChat {
|
||||
}
|
||||
QueryOptions queryOptions = this.vaultPermission.getQueryOptions(null, world);
|
||||
MetaCache metaData = group.getCachedData().getMetaData(queryOptions);
|
||||
String ret = metaData.getSuffix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||
String suffix = metaData.getSuffix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||
if (log()) {
|
||||
logMsg("#getGroupSuffix: %s - %s - %s", group.getName(), queryOptions.context(), ret);
|
||||
logMsg("#getGroupSuffix: %s - %s - %s", group.getName(), queryOptions.context(), suffix);
|
||||
}
|
||||
return Strings.nullToEmpty(ret);
|
||||
return Strings.nullToEmpty(suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -225,11 +225,11 @@ public class LuckPermsVaultChat extends AbstractVaultChat {
|
||||
}
|
||||
QueryOptions queryOptions = this.vaultPermission.getQueryOptions(null, world);
|
||||
MetaCache metaData = group.getCachedData().getMetaData(queryOptions);
|
||||
String ret = metaData.getMetaValue(key, MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||
String value = metaData.getMetaValue(key, MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||
if (log()) {
|
||||
logMsg("#getGroupMeta: %s - %s - %s - %s", group.getName(), queryOptions.context(), key, ret);
|
||||
logMsg("#getGroupMeta: %s - %s - %s - %s", group.getName(), queryOptions.context(), key, value);
|
||||
}
|
||||
return ret;
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -262,7 +262,7 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission {
|
||||
PermissionHolder user = lookupUser(uuid);
|
||||
ContextSet contexts = getQueryOptions(uuid, world).context();
|
||||
|
||||
String[] ret = user.normalData().immutableInheritance().values().stream()
|
||||
String[] groups = user.normalData().immutableInheritance().values().stream()
|
||||
.filter(n -> n.getContexts().isSatisfiedBy(contexts))
|
||||
.map(n -> {
|
||||
Group group = this.plugin.getGroupManager().getIfLoaded(n.getGroupName());
|
||||
@ -274,10 +274,10 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission {
|
||||
.toArray(String[]::new);
|
||||
|
||||
if (log()) {
|
||||
logMsg("#userGetGroups: %s - %s - %s", user.getPlainDisplayName(), contexts, Arrays.toString(ret));
|
||||
logMsg("#userGetGroups: %s - %s - %s", user.getPlainDisplayName(), contexts, Arrays.toString(groups));
|
||||
}
|
||||
|
||||
return ret;
|
||||
return groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,46 +111,46 @@ public final class ArgumentPermissions {
|
||||
|
||||
if (targetUser.getUniqueId().equals(sender.getUniqueId())) {
|
||||
// the sender is trying to edit themselves
|
||||
Tristate ret = sender.getPermissionValue(base.getPermission() + ".modify.self");
|
||||
if (ret != Tristate.UNDEFINED) {
|
||||
return !ret.asBoolean();
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".modify.self");
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
return !state.asBoolean();
|
||||
} else {
|
||||
// fallback to the global perm if the one for the specific command is undefined
|
||||
Tristate globalRet = sender.getPermissionValue(USER_MODIFY_SELF);
|
||||
return !globalRet.asBoolean();
|
||||
Tristate globalState = sender.getPermissionValue(USER_MODIFY_SELF);
|
||||
return !globalState.asBoolean();
|
||||
}
|
||||
} else {
|
||||
// they're trying to edit another user
|
||||
Tristate ret = sender.getPermissionValue(base.getPermission() + ".modify.others");
|
||||
if (ret != Tristate.UNDEFINED) {
|
||||
return !ret.asBoolean();
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".modify.others");
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
return !state.asBoolean();
|
||||
} else {
|
||||
// fallback to the global perm if the one for the specific command is undefined
|
||||
Tristate globalRet = sender.getPermissionValue(USER_MODIFY_OTHERS);
|
||||
return !globalRet.asBoolean();
|
||||
Tristate globalState = sender.getPermissionValue(USER_MODIFY_OTHERS);
|
||||
return !globalState.asBoolean();
|
||||
}
|
||||
}
|
||||
} else if (target instanceof Group) {
|
||||
Group targetGroup = ((Group) target);
|
||||
|
||||
Tristate ret = sender.getPermissionValue(base.getPermission() + ".modify." + targetGroup.getName());
|
||||
if (ret != Tristate.UNDEFINED) {
|
||||
return !ret.asBoolean();
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".modify." + targetGroup.getName());
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
return !state.asBoolean();
|
||||
} else {
|
||||
// fallback to the global perm if the one for the specific command is undefined
|
||||
Tristate globalRet = sender.getPermissionValue(GROUP_MODIFY.apply(targetGroup.getName()));
|
||||
return !globalRet.asBoolean();
|
||||
Tristate globalState = sender.getPermissionValue(GROUP_MODIFY.apply(targetGroup.getName()));
|
||||
return !globalState.asBoolean();
|
||||
}
|
||||
} else if (target instanceof Track) {
|
||||
Track targetTrack = ((Track) target);
|
||||
|
||||
Tristate ret = sender.getPermissionValue(base.getPermission() + ".modify." + targetTrack.getName());
|
||||
if (ret != Tristate.UNDEFINED) {
|
||||
return !ret.asBoolean();
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".modify." + targetTrack.getName());
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
return !state.asBoolean();
|
||||
} else {
|
||||
// fallback to the global perm if the one for the specific command is undefined
|
||||
Tristate globalRet = sender.getPermissionValue(TRACK_MODIFY.apply(targetTrack.getName()));
|
||||
return !globalRet.asBoolean();
|
||||
Tristate globalState = sender.getPermissionValue(TRACK_MODIFY.apply(targetTrack.getName()));
|
||||
return !globalState.asBoolean();
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
@ -176,46 +176,46 @@ public final class ArgumentPermissions {
|
||||
|
||||
if (targetUser.getUniqueId().equals(sender.getUniqueId())) {
|
||||
// the sender is trying to view themselves
|
||||
Tristate ret = sender.getPermissionValue(base.getPermission() + ".view.self");
|
||||
if (ret != Tristate.UNDEFINED) {
|
||||
return !ret.asBoolean();
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".view.self");
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
return !state.asBoolean();
|
||||
} else {
|
||||
// fallback to the global perm if the one for the specific command is undefined
|
||||
Tristate globalRet = sender.getPermissionValue(USER_VIEW_SELF);
|
||||
return !globalRet.asBoolean();
|
||||
Tristate globalState = sender.getPermissionValue(USER_VIEW_SELF);
|
||||
return !globalState.asBoolean();
|
||||
}
|
||||
} else {
|
||||
// they're trying to view another user
|
||||
Tristate ret = sender.getPermissionValue(base.getPermission() + ".view.others");
|
||||
if (ret != Tristate.UNDEFINED) {
|
||||
return !ret.asBoolean();
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".view.others");
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
return !state.asBoolean();
|
||||
} else {
|
||||
// fallback to the global perm if the one for the specific command is undefined
|
||||
Tristate globalRet = sender.getPermissionValue(USER_VIEW_OTHERS);
|
||||
return !globalRet.asBoolean();
|
||||
Tristate globalState = sender.getPermissionValue(USER_VIEW_OTHERS);
|
||||
return !globalState.asBoolean();
|
||||
}
|
||||
}
|
||||
} else if (target instanceof Group) {
|
||||
Group targetGroup = ((Group) target);
|
||||
|
||||
Tristate ret = sender.getPermissionValue(base.getPermission() + ".view." + targetGroup.getName());
|
||||
if (ret != Tristate.UNDEFINED) {
|
||||
return !ret.asBoolean();
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".view." + targetGroup.getName());
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
return !state.asBoolean();
|
||||
} else {
|
||||
// fallback to the global perm if the one for the specific command is undefined
|
||||
Tristate globalRet = sender.getPermissionValue(GROUP_VIEW.apply(targetGroup.getName()));
|
||||
return !globalRet.asBoolean();
|
||||
Tristate globalState = sender.getPermissionValue(GROUP_VIEW.apply(targetGroup.getName()));
|
||||
return !globalState.asBoolean();
|
||||
}
|
||||
} else if (target instanceof Track) {
|
||||
Track targetTrack = ((Track) target);
|
||||
|
||||
Tristate ret = sender.getPermissionValue(base.getPermission() + ".view." + targetTrack.getName());
|
||||
if (ret != Tristate.UNDEFINED) {
|
||||
return !ret.asBoolean();
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".view." + targetTrack.getName());
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
return !state.asBoolean();
|
||||
} else {
|
||||
// fallback to the global perm if the one for the specific command is undefined
|
||||
Tristate globalRet = sender.getPermissionValue(TRACK_VIEW.apply(targetTrack.getName()));
|
||||
return !globalRet.asBoolean();
|
||||
Tristate globalState = sender.getPermissionValue(TRACK_VIEW.apply(targetTrack.getName()));
|
||||
return !globalState.asBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,26 +237,26 @@ public final class ArgumentPermissions {
|
||||
}
|
||||
|
||||
if (contextSet.isEmpty()) {
|
||||
Tristate ret = sender.getPermissionValue(base.getPermission() + ".usecontext.global");
|
||||
if (ret != Tristate.UNDEFINED) {
|
||||
return !ret.asBoolean();
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".usecontext.global");
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
return !state.asBoolean();
|
||||
} else {
|
||||
// fallback to the global perm if the one for the specific command is undefined
|
||||
Tristate globalRet = sender.getPermissionValue(CONTEXT_USE_GLOBAL);
|
||||
return !globalRet.asBoolean();
|
||||
Tristate globalState = sender.getPermissionValue(CONTEXT_USE_GLOBAL);
|
||||
return !globalState.asBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
for (Context context : contextSet) {
|
||||
Tristate ret = sender.getPermissionValue(base.getPermission() + ".usecontext." + context.getKey() + "." + context.getValue());
|
||||
if (ret != Tristate.UNDEFINED) {
|
||||
if (ret == Tristate.FALSE) {
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".usecontext." + context.getKey() + "." + context.getValue());
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
if (state == Tristate.FALSE) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// fallback to the global perm if the one for the specific command is undefined
|
||||
Tristate globalRet = sender.getPermissionValue(CONTEXT_USE.apply(context.getKey(), context.getValue()));
|
||||
if (globalRet == Tristate.FALSE) {
|
||||
Tristate globalState = sender.getPermissionValue(CONTEXT_USE.apply(context.getKey(), context.getValue()));
|
||||
if (globalState == Tristate.FALSE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -147,9 +147,9 @@ public class ArgumentParser {
|
||||
|
||||
String s = args.get(index);
|
||||
try {
|
||||
Optional<TemporaryNodeMergeStrategy> ret = Optional.of(parseTemporaryModifier(s));
|
||||
Optional<TemporaryNodeMergeStrategy> strategy = Optional.of(parseTemporaryModifier(s));
|
||||
args.remove(index);
|
||||
return ret;
|
||||
return strategy;
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
@ -91,10 +91,10 @@ public class MetaAddTempChatMeta extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
DataMutateResult.WithMergedNode ret = holder.setNode(DataType.NORMAL, this.type.builder(meta, priority).expiry(duration).withContext(context).build(), modifier);
|
||||
DataMutateResult.WithMergedNode result = holder.setNode(DataType.NORMAL, this.type.builder(meta, priority).expiry(duration).withContext(context).build(), modifier);
|
||||
|
||||
if (ret.getResult().wasSuccessful()) {
|
||||
duration = ret.getMergedNode().getExpiryDuration();
|
||||
if (result.getResult().wasSuccessful()) {
|
||||
duration = result.getMergedNode().getExpiryDuration();
|
||||
|
||||
TextComponent.Builder builder = Message.ADD_TEMP_CHATMETA_SUCCESS.asComponent(plugin.getLocaleManager(), holder.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, DurationFormatter.LONG.format(duration), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)).toBuilder();
|
||||
HoverEvent event = HoverEvent.showText(TextUtils.fromLegacy(
|
||||
|
@ -131,10 +131,10 @@ public class MetaSetTempChatMeta extends SharedSubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
DataMutateResult.WithMergedNode ret = holder.setNode(DataType.NORMAL, this.type.builder(meta, priority).expiry(duration).withContext(context).build(), modifier);
|
||||
DataMutateResult.WithMergedNode result = holder.setNode(DataType.NORMAL, this.type.builder(meta, priority).expiry(duration).withContext(context).build(), modifier);
|
||||
|
||||
if (ret.getResult().wasSuccessful()) {
|
||||
duration = ret.getMergedNode().getExpiryDuration();
|
||||
if (result.getResult().wasSuccessful()) {
|
||||
duration = result.getMergedNode().getExpiryDuration();
|
||||
|
||||
TextComponent.Builder builder = Message.ADD_TEMP_CHATMETA_SUCCESS.asComponent(plugin.getLocaleManager(), holder.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, DurationFormatter.LONG.format(duration), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)).toBuilder();
|
||||
HoverEvent event = HoverEvent.showText(TextUtils.fromLegacy(
|
||||
|
@ -91,10 +91,10 @@ public class ParentAddTemp extends SharedSubCommand {
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
||||
DataMutateResult.WithMergedNode ret = holder.setNode(DataType.NORMAL, Inheritance.builder(group.getName()).expiry(duration).withContext(context).build(), modifier);
|
||||
DataMutateResult.WithMergedNode result = holder.setNode(DataType.NORMAL, Inheritance.builder(group.getName()).expiry(duration).withContext(context).build(), modifier);
|
||||
|
||||
if (ret.getResult().wasSuccessful()) {
|
||||
duration = ret.getMergedNode().getExpiryDuration();
|
||||
if (result.getResult().wasSuccessful()) {
|
||||
duration = result.getMergedNode().getExpiryDuration();
|
||||
Message.SET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFormattedDisplayName(), group.getFormattedDisplayName(), DurationFormatter.LONG.format(duration), MessageUtils.contextSetToString(plugin.getLocaleManager(), context));
|
||||
|
||||
LoggedAction.build().source(sender).target(holder)
|
||||
|
@ -59,13 +59,13 @@ public class LogNotify extends SubCommand<Log> {
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<? extends Node> ret = user.normalData().immutable().get(ImmutableContextSetImpl.EMPTY).stream()
|
||||
Optional<? extends Node> node = user.normalData().immutable().get(ImmutableContextSetImpl.EMPTY).stream()
|
||||
.filter(n -> n.getKey().equalsIgnoreCase(IGNORE_NODE))
|
||||
.findFirst();
|
||||
|
||||
// if they don't have the perm, they're not ignoring
|
||||
// if set to false, ignore it, return false
|
||||
return ret.map(Node::getValue).orElse(false);
|
||||
return node.map(Node::getValue).orElse(false);
|
||||
}
|
||||
|
||||
private static void setIgnoring(LuckPermsPlugin plugin, UUID uuid, boolean state) {
|
||||
|
@ -86,9 +86,9 @@ public class ContextSetComparator implements Comparator<ImmutableContextSet> {
|
||||
Context ent1 = it1.next();
|
||||
Context ent2 = it2.next();
|
||||
|
||||
int ret = CONTEXT_COMPARATOR.compare(ent1, ent2);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
result = CONTEXT_COMPARATOR.compare(ent1, ent2);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,9 +103,9 @@ public class ContextSetComparator implements Comparator<ImmutableContextSet> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ret = FAST_STRING_COMPARATOR.compare(o1.getKey(), o2.getKey());
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
int i = FAST_STRING_COMPARATOR.compare(o1.getKey(), o2.getKey());
|
||||
if (i != 0) {
|
||||
return i;
|
||||
}
|
||||
|
||||
return FAST_STRING_COMPARATOR.compare(o1.getValue(), o2.getValue());
|
||||
|
@ -117,9 +117,9 @@ public final class NodeMap {
|
||||
}
|
||||
|
||||
public SortedSet<Node> asSortedSet() {
|
||||
SortedSet<Node> ret = new TreeSet<>(NodeWithContextComparator.reverse());
|
||||
copyTo(ret, QueryOptions.nonContextual());
|
||||
return ret;
|
||||
SortedSet<Node> set = new TreeSet<>(NodeWithContextComparator.reverse());
|
||||
copyTo(set, QueryOptions.nonContextual());
|
||||
return set;
|
||||
}
|
||||
|
||||
public LinkedHashSet<InheritanceNode> inheritanceAsSet() {
|
||||
@ -129,9 +129,9 @@ public final class NodeMap {
|
||||
}
|
||||
|
||||
public SortedSet<InheritanceNode> inheritanceAsSortedSet() {
|
||||
SortedSet<InheritanceNode> ret = new TreeSet<>(NodeWithContextComparator.reverse());
|
||||
copyInheritanceNodesTo(ret, QueryOptions.nonContextual());
|
||||
return ret;
|
||||
SortedSet<InheritanceNode> set = new TreeSet<>(NodeWithContextComparator.reverse());
|
||||
copyInheritanceNodesTo(set, QueryOptions.nonContextual());
|
||||
return set;
|
||||
}
|
||||
|
||||
private static boolean flagExcludeTest(Flag flag, String contextKey, QueryOptions filter, ImmutableContextSet contextSet) {
|
||||
@ -285,26 +285,26 @@ public final class NodeMap {
|
||||
}
|
||||
|
||||
boolean removeIf(Predicate<? super Node> predicate) {
|
||||
boolean ret = false;
|
||||
boolean success = false;
|
||||
for (SortedSet<Node> valueSet : this.map.values()) {
|
||||
if (valueSet.removeIf(predicate)) {
|
||||
ret = true;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
for (SortedSet<InheritanceNode> valueSet : this.inheritanceMap.values()) {
|
||||
valueSet.removeIf(predicate);
|
||||
}
|
||||
return ret;
|
||||
return success;
|
||||
}
|
||||
|
||||
boolean removeIf(ContextSet contextSet, Predicate<? super Node> predicate) {
|
||||
ImmutableContextSet context = contextSet.immutableCopy();
|
||||
|
||||
boolean ret = false;
|
||||
boolean success = false;
|
||||
|
||||
SortedSet<Node> nodesInContext = this.map.get(context);
|
||||
if (nodesInContext != null) {
|
||||
ret = nodesInContext.removeIf(predicate);
|
||||
success = nodesInContext.removeIf(predicate);
|
||||
}
|
||||
|
||||
SortedSet<InheritanceNode> inheritanceNodesInContext = this.inheritanceMap.get(context);
|
||||
@ -312,7 +312,7 @@ public final class NodeMap {
|
||||
inheritanceNodesInContext.removeIf(predicate);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return success;
|
||||
}
|
||||
|
||||
boolean auditTemporaryNodes(@Nullable Set<? super Node> removed) {
|
||||
|
@ -244,45 +244,45 @@ public abstract class PermissionHolder {
|
||||
}
|
||||
|
||||
public List<Node> getOwnNodes(QueryOptions queryOptions) {
|
||||
List<Node> ret = new ArrayList<>();
|
||||
List<Node> nodes = new ArrayList<>();
|
||||
|
||||
Comparator<DataType> comparator = queryOptions.option(DataQueryOrderFunction.KEY)
|
||||
.map(func -> func.getOrderComparator(getIdentifier()))
|
||||
.orElse(DataQueryOrder.TRANSIENT_FIRST);
|
||||
|
||||
for (DataType dataType : DataQueryOrder.order(comparator)) {
|
||||
getData(dataType).copyTo(ret, queryOptions);
|
||||
getData(dataType).copyTo(nodes, queryOptions);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return nodes;
|
||||
}
|
||||
|
||||
public SortedSet<Node> getOwnNodesSorted(QueryOptions queryOptions) {
|
||||
SortedSet<Node> ret = new TreeSet<>(NodeWithContextComparator.reverse());
|
||||
SortedSet<Node> nodes = new TreeSet<>(NodeWithContextComparator.reverse());
|
||||
|
||||
Comparator<DataType> comparator = queryOptions.option(DataQueryOrderFunction.KEY)
|
||||
.map(func -> func.getOrderComparator(getIdentifier()))
|
||||
.orElse(DataQueryOrder.TRANSIENT_FIRST);
|
||||
|
||||
for (DataType dataType : DataQueryOrder.order(comparator)) {
|
||||
getData(dataType).copyTo(ret, queryOptions);
|
||||
getData(dataType).copyTo(nodes, queryOptions);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return nodes;
|
||||
}
|
||||
|
||||
public List<InheritanceNode> getOwnInheritanceNodes(QueryOptions queryOptions) {
|
||||
List<InheritanceNode> ret = new ArrayList<>();
|
||||
List<InheritanceNode> nodes = new ArrayList<>();
|
||||
|
||||
Comparator<DataType> comparator = queryOptions.option(DataQueryOrderFunction.KEY)
|
||||
.map(func -> func.getOrderComparator(getIdentifier()))
|
||||
.orElse(DataQueryOrder.TRANSIENT_FIRST);
|
||||
|
||||
for (DataType dataType : DataQueryOrder.order(comparator)) {
|
||||
getData(dataType).copyInheritanceNodesTo(ret, queryOptions);
|
||||
getData(dataType).copyInheritanceNodesTo(nodes, queryOptions);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return nodes;
|
||||
}
|
||||
|
||||
private void accumulateInheritedNodesTo(Collection<Node> accumulator, QueryOptions queryOptions) {
|
||||
@ -299,15 +299,15 @@ public abstract class PermissionHolder {
|
||||
}
|
||||
|
||||
public List<Node> resolveInheritedNodes(QueryOptions queryOptions) {
|
||||
List<Node> ret = new ArrayList<>();
|
||||
accumulateInheritedNodesTo(ret, queryOptions);
|
||||
return ret;
|
||||
List<Node> nodes = new ArrayList<>();
|
||||
accumulateInheritedNodesTo(nodes, queryOptions);
|
||||
return nodes;
|
||||
}
|
||||
|
||||
public SortedSet<Node> resolveInheritedNodesSorted(QueryOptions queryOptions) {
|
||||
SortedSet<Node> ret = new TreeSet<>(NodeWithContextComparator.reverse());
|
||||
accumulateInheritedNodesTo(ret, queryOptions);
|
||||
return ret;
|
||||
SortedSet<Node> nodes = new TreeSet<>(NodeWithContextComparator.reverse());
|
||||
accumulateInheritedNodesTo(nodes, queryOptions);
|
||||
return nodes;
|
||||
}
|
||||
|
||||
public Map<String, Boolean> exportPermissions(QueryOptions queryOptions, boolean convertToLowercase, boolean resolveShorthand) {
|
||||
@ -316,12 +316,12 @@ public abstract class PermissionHolder {
|
||||
}
|
||||
|
||||
private static ImmutableMap<String, Boolean> processExportedPermissions(List<Node> entries, boolean convertToLowercase, boolean resolveShorthand) {
|
||||
Map<String, Boolean> perms = new HashMap<>(entries.size());
|
||||
Map<String, Boolean> map = new HashMap<>(entries.size());
|
||||
for (Node node : entries) {
|
||||
if (convertToLowercase) {
|
||||
perms.putIfAbsent(node.getKey().toLowerCase(), node.getValue());
|
||||
map.putIfAbsent(node.getKey().toLowerCase(), node.getValue());
|
||||
} else {
|
||||
perms.putIfAbsent(node.getKey(), node.getValue());
|
||||
map.putIfAbsent(node.getKey(), node.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@ -330,15 +330,15 @@ public abstract class PermissionHolder {
|
||||
Collection<String> shorthand = node.resolveShorthand();
|
||||
for (String s : shorthand) {
|
||||
if (convertToLowercase) {
|
||||
perms.putIfAbsent(s.toLowerCase(), node.getValue());
|
||||
map.putIfAbsent(s.toLowerCase(), node.getValue());
|
||||
} else {
|
||||
perms.putIfAbsent(s, node.getValue());
|
||||
map.putIfAbsent(s, node.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ImmutableMap.copyOf(perms);
|
||||
return ImmutableMap.copyOf(map);
|
||||
}
|
||||
|
||||
public MetaAccumulator accumulateMeta(MetaAccumulator accumulator, QueryOptions queryOptions) {
|
||||
|
@ -160,8 +160,8 @@ public class CombinedConfigurateStorage extends AbstractConfigurateStorage {
|
||||
@Override
|
||||
protected ConfigurationNode readFile(StorageLocation location, String name) throws IOException {
|
||||
ConfigurationNode root = getStorageLoader(location).getNode();
|
||||
ConfigurationNode ret = root.getNode(name);
|
||||
return ret.isVirtual() ? null : ret;
|
||||
ConfigurationNode node = root.getNode(name);
|
||||
return node.isVirtual() ? null : node;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -143,7 +143,7 @@ public class MongoStorage implements StorageImplementation {
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMeta() {
|
||||
Map<String, String> ret = new LinkedHashMap<>();
|
||||
Map<String, String> meta = new LinkedHashMap<>();
|
||||
boolean success = true;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
@ -155,13 +155,13 @@ public class MongoStorage implements StorageImplementation {
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
|
||||
if (success) {
|
||||
ret.put("Ping", "&a" + duration + "ms");
|
||||
ret.put("Connected", "true");
|
||||
meta.put("Ping", "&a" + duration + "ms");
|
||||
meta.put("Connected", "true");
|
||||
} else {
|
||||
ret.put("Connected", "false");
|
||||
meta.put("Connected", "false");
|
||||
}
|
||||
|
||||
return ret;
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,12 +106,12 @@ public class SplitStorage implements StorageImplementation {
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMeta() {
|
||||
Map<String, String> ret = new LinkedHashMap<>();
|
||||
ret.put("Types", this.types.toString());
|
||||
Map<String, String> meta = new LinkedHashMap<>();
|
||||
meta.put("Types", this.types.toString());
|
||||
for (StorageImplementation backing : this.implementations.values()) {
|
||||
ret.putAll(backing.getMeta());
|
||||
meta.putAll(backing.getMeta());
|
||||
}
|
||||
return ret;
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,7 +54,7 @@ abstract class FlatfileConnectionFactory implements ConnectionFactory {
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMeta() {
|
||||
Map<String, String> ret = new LinkedHashMap<>();
|
||||
Map<String, String> meta = new LinkedHashMap<>();
|
||||
|
||||
Path databaseFile = getWriteFile();
|
||||
if (Files.exists(databaseFile)) {
|
||||
@ -66,11 +66,11 @@ abstract class FlatfileConnectionFactory implements ConnectionFactory {
|
||||
}
|
||||
|
||||
double size = length / 1048576D;
|
||||
ret.put("File Size", DF.format(size) + "MB");
|
||||
meta.put("File Size", DF.format(size) + "MB");
|
||||
} else {
|
||||
ret.put("File Size", "0MB");
|
||||
meta.put("File Size", "0MB");
|
||||
}
|
||||
|
||||
return ret;
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public abstract class HikariConnectionFactory implements ConnectionFactory {
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMeta() {
|
||||
Map<String, String> ret = new LinkedHashMap<>();
|
||||
Map<String, String> meta = new LinkedHashMap<>();
|
||||
boolean success = true;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
@ -114,13 +114,13 @@ public abstract class HikariConnectionFactory implements ConnectionFactory {
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
|
||||
if (success) {
|
||||
ret.put("Ping", "&a" + duration + "ms");
|
||||
ret.put("Connected", "true");
|
||||
meta.put("Ping", "&a" + duration + "ms");
|
||||
meta.put("Connected", "true");
|
||||
} else {
|
||||
ret.put("Connected", "false");
|
||||
meta.put("Connected", "false");
|
||||
}
|
||||
|
||||
return ret;
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,15 +46,15 @@ import me.lucko.luckperms.nukkit.calculator.NukkitCalculatorFactory;
|
||||
import me.lucko.luckperms.nukkit.context.NukkitContextManager;
|
||||
import me.lucko.luckperms.nukkit.context.WorldCalculator;
|
||||
import me.lucko.luckperms.nukkit.inject.PermissionDefault;
|
||||
import me.lucko.luckperms.nukkit.inject.permissible.LPPermissible;
|
||||
import me.lucko.luckperms.nukkit.inject.permissible.LuckPermsPermissible;
|
||||
import me.lucko.luckperms.nukkit.inject.permissible.PermissibleInjector;
|
||||
import me.lucko.luckperms.nukkit.inject.permissible.PermissibleMonitoringInjector;
|
||||
import me.lucko.luckperms.nukkit.inject.server.InjectorDefaultsMap;
|
||||
import me.lucko.luckperms.nukkit.inject.server.InjectorPermissionMap;
|
||||
import me.lucko.luckperms.nukkit.inject.server.InjectorSubscriptionMap;
|
||||
import me.lucko.luckperms.nukkit.inject.server.LPDefaultsMap;
|
||||
import me.lucko.luckperms.nukkit.inject.server.LPPermissionMap;
|
||||
import me.lucko.luckperms.nukkit.inject.server.LPSubscriptionMap;
|
||||
import me.lucko.luckperms.nukkit.inject.server.LuckPermsDefaultsMap;
|
||||
import me.lucko.luckperms.nukkit.inject.server.LuckPermsPermissionMap;
|
||||
import me.lucko.luckperms.nukkit.inject.server.LuckPermsSubscriptionMap;
|
||||
import me.lucko.luckperms.nukkit.listeners.NukkitConnectionListener;
|
||||
import me.lucko.luckperms.nukkit.listeners.NukkitPlatformListener;
|
||||
|
||||
@ -88,9 +88,9 @@ public class LPNukkitPlugin extends AbstractLuckPermsPlugin {
|
||||
private StandardGroupManager groupManager;
|
||||
private StandardTrackManager trackManager;
|
||||
private NukkitContextManager contextManager;
|
||||
private LPSubscriptionMap subscriptionMap;
|
||||
private LPPermissionMap permissionMap;
|
||||
private LPDefaultsMap defaultPermissionMap;
|
||||
private LuckPermsSubscriptionMap subscriptionMap;
|
||||
private LuckPermsPermissionMap permissionMap;
|
||||
private LuckPermsDefaultsMap defaultPermissionMap;
|
||||
|
||||
public LPNukkitPlugin(LPNukkitBootstrap bootstrap) {
|
||||
this.bootstrap = bootstrap;
|
||||
@ -220,7 +220,7 @@ public class LPNukkitPlugin extends AbstractLuckPermsPlugin {
|
||||
if (user != null) {
|
||||
this.bootstrap.getScheduler().executeSync(() -> {
|
||||
try {
|
||||
LPPermissible lpPermissible = new LPPermissible(player, user, this);
|
||||
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this);
|
||||
PermissibleInjector.inject(player, lpPermissible);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
@ -341,27 +341,27 @@ public class LPNukkitPlugin extends AbstractLuckPermsPlugin {
|
||||
return this.contextManager;
|
||||
}
|
||||
|
||||
public LPSubscriptionMap getSubscriptionMap() {
|
||||
public LuckPermsSubscriptionMap getSubscriptionMap() {
|
||||
return this.subscriptionMap;
|
||||
}
|
||||
|
||||
public void setSubscriptionMap(LPSubscriptionMap subscriptionMap) {
|
||||
public void setSubscriptionMap(LuckPermsSubscriptionMap subscriptionMap) {
|
||||
this.subscriptionMap = subscriptionMap;
|
||||
}
|
||||
|
||||
public LPPermissionMap getPermissionMap() {
|
||||
public LuckPermsPermissionMap getPermissionMap() {
|
||||
return this.permissionMap;
|
||||
}
|
||||
|
||||
public void setPermissionMap(LPPermissionMap permissionMap) {
|
||||
public void setPermissionMap(LuckPermsPermissionMap permissionMap) {
|
||||
this.permissionMap = permissionMap;
|
||||
}
|
||||
|
||||
public LPDefaultsMap getDefaultPermissionMap() {
|
||||
public LuckPermsDefaultsMap getDefaultPermissionMap() {
|
||||
return this.defaultPermissionMap;
|
||||
}
|
||||
|
||||
public void setDefaultPermissionMap(LPDefaultsMap defaultPermissionMap) {
|
||||
public void setDefaultPermissionMap(LuckPermsDefaultsMap defaultPermissionMap) {
|
||||
this.defaultPermissionMap = defaultPermissionMap;
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,8 @@ public class NukkitConfigAdapter implements ConfigurationAdapter {
|
||||
|
||||
@Override
|
||||
public List<String> getStringList(String path, List<String> def) {
|
||||
List<String> ret = this.configuration.getStringList(path);
|
||||
return ret == null ? def : ret;
|
||||
List<String> list = this.configuration.getStringList(path);
|
||||
return list == null ? def : list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,7 +73,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* This class is **thread safe**. This means that when LuckPerms is installed on the server,
|
||||
* is is safe to call Player#hasPermission asynchronously.
|
||||
*/
|
||||
public class LPPermissible extends PermissibleBase {
|
||||
public class LuckPermsPermissible extends PermissibleBase {
|
||||
|
||||
private static final Field ATTACHMENTS_FIELD;
|
||||
|
||||
@ -106,9 +106,9 @@ public class LPPermissible extends PermissibleBase {
|
||||
|
||||
// the attachments hooked onto the permissible.
|
||||
// this collection is only modified by the attachments themselves
|
||||
final Set<LPPermissionAttachment> lpAttachments = ConcurrentHashMap.newKeySet();
|
||||
final Set<LuckPermsPermissionAttachment> hookedAttachments = ConcurrentHashMap.newKeySet();
|
||||
|
||||
public LPPermissible(Player player, User user, LPNukkitPlugin plugin) {
|
||||
public LuckPermsPermissible(Player player, User user, LPNukkitPlugin plugin) {
|
||||
super(player);
|
||||
this.user = Objects.requireNonNull(user, "user");
|
||||
this.player = Objects.requireNonNull(player, "player");
|
||||
@ -204,7 +204,7 @@ public class LPPermissible extends PermissibleBase {
|
||||
*/
|
||||
void convertAndAddAttachments(Collection<PermissionAttachment> attachments) {
|
||||
for (PermissionAttachment attachment : attachments) {
|
||||
new LPPermissionAttachment(this, attachment).hook();
|
||||
new LuckPermsPermissionAttachment(this, attachment).hook();
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,14 +220,14 @@ public class LPPermissible extends PermissibleBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public LPPermissionAttachment addAttachment(Plugin plugin) {
|
||||
public LuckPermsPermissionAttachment addAttachment(Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new NullPointerException("plugin");
|
||||
}
|
||||
|
||||
LPPermissionAttachment ret = new LPPermissionAttachment(this, plugin);
|
||||
ret.hook();
|
||||
return ret;
|
||||
LuckPermsPermissionAttachment attachment = new LuckPermsPermissionAttachment(this, plugin);
|
||||
attachment.hook();
|
||||
return attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -239,9 +239,9 @@ public class LPPermissible extends PermissibleBase {
|
||||
return addAttachment(plugin);
|
||||
}
|
||||
|
||||
PermissionAttachment ret = addAttachment(plugin);
|
||||
ret.setPermission(permission, true);
|
||||
return ret;
|
||||
PermissionAttachment attachment = addAttachment(plugin);
|
||||
attachment.setPermission(permission, true);
|
||||
return attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -256,9 +256,9 @@ public class LPPermissible extends PermissibleBase {
|
||||
return addAttachment(plugin, permission);
|
||||
}
|
||||
|
||||
PermissionAttachment ret = addAttachment(plugin);
|
||||
ret.setPermission(permission, value);
|
||||
return ret;
|
||||
PermissionAttachment attachment = addAttachment(plugin);
|
||||
attachment.setPermission(permission, value);
|
||||
return attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -267,25 +267,25 @@ public class LPPermissible extends PermissibleBase {
|
||||
throw new NullPointerException("attachment");
|
||||
}
|
||||
|
||||
LPPermissionAttachment a;
|
||||
LuckPermsPermissionAttachment luckPermsAttachment;
|
||||
|
||||
if (!(attachment instanceof LPPermissionAttachment)) {
|
||||
if (!(attachment instanceof LuckPermsPermissionAttachment)) {
|
||||
// try to find a match
|
||||
LPPermissionAttachment match = this.lpAttachments.stream().filter(at -> at.getSource() == attachment).findFirst().orElse(null);
|
||||
LuckPermsPermissionAttachment match = this.hookedAttachments.stream().filter(at -> at.getSource() == attachment).findFirst().orElse(null);
|
||||
if (match != null) {
|
||||
a = match;
|
||||
luckPermsAttachment = match;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Given attachment is not a LPPermissionAttachment.");
|
||||
}
|
||||
} else {
|
||||
a = (LPPermissionAttachment) attachment;
|
||||
luckPermsAttachment = (LuckPermsPermissionAttachment) attachment;
|
||||
}
|
||||
|
||||
if (a.getPermissible() != this) {
|
||||
if (luckPermsAttachment.getPermissible() != this) {
|
||||
throw new IllegalArgumentException("Attachment does not belong to this permissible.");
|
||||
}
|
||||
|
||||
a.remove();
|
||||
luckPermsAttachment.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -303,7 +303,7 @@ public class LPPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public void clearPermissions() {
|
||||
this.lpAttachments.forEach(LPPermissionAttachment::remove);
|
||||
this.hookedAttachments.forEach(LuckPermsPermissionAttachment::remove);
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
@ -343,11 +343,11 @@ public class LPPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public boolean add(PermissionAttachment attachment) {
|
||||
if (LPPermissible.this.lpAttachments.stream().anyMatch(at -> at.getSource() == attachment)) {
|
||||
if (LuckPermsPermissible.this.hookedAttachments.stream().anyMatch(at -> at.getSource() == attachment)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
new LPPermissionAttachment(LPPermissible.this, attachment).hook();
|
||||
new LuckPermsPermissionAttachment(LuckPermsPermissible.this, attachment).hook();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -376,22 +376,22 @@ public class LPPermissible extends PermissibleBase {
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
PermissionAttachment attachment = (PermissionAttachment) o;
|
||||
return LPPermissible.this.lpAttachments.stream().anyMatch(at -> at.getSource() == attachment);
|
||||
return LuckPermsPermissible.this.hookedAttachments.stream().anyMatch(at -> at.getSource() == attachment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<PermissionAttachment> iterator() {
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LPPermissible.this.lpAttachments).iterator();
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LuckPermsPermissible.this.hookedAttachments).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Object[] toArray() {
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LPPermissible.this.lpAttachments).toArray();
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LuckPermsPermissible.this.hookedAttachments).toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull <T> T[] toArray(@NonNull T[] a) {
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LPPermissible.this.lpAttachments).toArray(a);
|
||||
return ImmutableList.<PermissionAttachment>copyOf(LuckPermsPermissible.this.hookedAttachments).toArray(a);
|
||||
}
|
||||
|
||||
@Override public int size() { throw new UnsupportedOperationException(); }
|
@ -57,9 +57,9 @@ import java.util.Set;
|
||||
*
|
||||
* Applies all permissions directly to the backing user instance via transient nodes.
|
||||
*/
|
||||
public class LPPermissionAttachment extends PermissionAttachment {
|
||||
public class LuckPermsPermissionAttachment extends PermissionAttachment {
|
||||
|
||||
public static final NodeMetadataKey<LPPermissionAttachment> TRANSIENT_SOURCE_KEY = NodeMetadataKey.of("transientsource", LPPermissionAttachment.class);
|
||||
public static final NodeMetadataKey<LuckPermsPermissionAttachment> TRANSIENT_SOURCE_KEY = NodeMetadataKey.of("transientsource", LuckPermsPermissionAttachment.class);
|
||||
|
||||
/**
|
||||
* The field in PermissionAttachment where the attachments applied permissions
|
||||
@ -79,7 +79,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
/**
|
||||
* The parent LPPermissible
|
||||
*/
|
||||
private final LPPermissible permissible;
|
||||
private final LuckPermsPermissible permissible;
|
||||
|
||||
/**
|
||||
* The plugin which "owns" this attachment, may be null
|
||||
@ -106,7 +106,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
*/
|
||||
private PermissionAttachment source;
|
||||
|
||||
public LPPermissionAttachment(LPPermissible permissible, Plugin owner) {
|
||||
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, Plugin owner) {
|
||||
super(DummyPlugin.INSTANCE, null);
|
||||
this.permissible = permissible;
|
||||
this.owner = owner;
|
||||
@ -114,7 +114,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
injectFakeMap();
|
||||
}
|
||||
|
||||
public LPPermissionAttachment(LPPermissible permissible, PermissionAttachment source) {
|
||||
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, PermissionAttachment source) {
|
||||
super(DummyPlugin.INSTANCE, null);
|
||||
this.permissible = permissible;
|
||||
this.owner = source.getPlugin();
|
||||
@ -146,7 +146,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
}
|
||||
}
|
||||
|
||||
public LPPermissible getPermissible() {
|
||||
public LuckPermsPermissible getPermissible() {
|
||||
return this.permissible;
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
*/
|
||||
public void hook() {
|
||||
this.hooked = true;
|
||||
this.permissible.lpAttachments.add(this);
|
||||
this.permissible.hookedAttachments.add(this);
|
||||
for (Map.Entry<String, Boolean> entry : this.perms.entrySet()) {
|
||||
if (entry.getKey() == null || entry.getKey().isEmpty()) {
|
||||
continue;
|
||||
@ -231,7 +231,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
|
||||
// unhook from the permissible
|
||||
this.hooked = false;
|
||||
this.permissible.lpAttachments.remove(this);
|
||||
this.permissible.hookedAttachments.remove(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -345,7 +345,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
@Override
|
||||
public Boolean put(String key, Boolean value) {
|
||||
// grab the previous result, so we can still satisfy the method signature of Map
|
||||
Boolean previous = LPPermissionAttachment.this.perms.get(key);
|
||||
Boolean previous = LuckPermsPermissionAttachment.this.perms.get(key);
|
||||
|
||||
// proxy the call back through the PermissionAttachment instance
|
||||
setPermission(key, value);
|
||||
@ -364,7 +364,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
String permission = ((String) key);
|
||||
|
||||
// grab the previous result, so we can still satisfy the method signature of Map
|
||||
Boolean previous = LPPermissionAttachment.this.perms.get(permission);
|
||||
Boolean previous = LuckPermsPermissionAttachment.this.perms.get(permission);
|
||||
|
||||
// proxy the call back through the PermissionAttachment instance
|
||||
unsetPermission(permission, true);
|
||||
@ -383,71 +383,71 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
||||
@Override
|
||||
public void clear() {
|
||||
// remove the permissions which have already been applied
|
||||
if (LPPermissionAttachment.this.hooked) {
|
||||
if (LuckPermsPermissionAttachment.this.hooked) {
|
||||
clearInternal();
|
||||
}
|
||||
|
||||
// clear the backing map
|
||||
LPPermissionAttachment.this.perms.clear();
|
||||
LuckPermsPermissionAttachment.this.perms.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
// return the size of the permissions map - probably the most accurate value we have
|
||||
return LPPermissionAttachment.this.perms.size();
|
||||
return LuckPermsPermissionAttachment.this.perms.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
// return if the permissions map is empty - again probably the most accurate thing
|
||||
// we can return
|
||||
return LPPermissionAttachment.this.perms.isEmpty();
|
||||
return LuckPermsPermissionAttachment.this.perms.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
// just proxy
|
||||
return LPPermissionAttachment.this.perms.containsKey(key);
|
||||
return LuckPermsPermissionAttachment.this.perms.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
// just proxy
|
||||
return LPPermissionAttachment.this.perms.containsValue(value);
|
||||
return LuckPermsPermissionAttachment.this.perms.containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean get(Object key) {
|
||||
// just proxy
|
||||
return LPPermissionAttachment.this.perms.get(key);
|
||||
return LuckPermsPermissionAttachment.this.perms.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> keySet() {
|
||||
// just proxy
|
||||
return Collections.unmodifiableSet(LPPermissionAttachment.this.perms.keySet());
|
||||
return Collections.unmodifiableSet(LuckPermsPermissionAttachment.this.perms.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Boolean> values() {
|
||||
// just proxy
|
||||
return Collections.unmodifiableCollection(LPPermissionAttachment.this.perms.values());
|
||||
return Collections.unmodifiableCollection(LuckPermsPermissionAttachment.this.perms.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Entry<String, Boolean>> entrySet() {
|
||||
// just proxy
|
||||
return Collections.unmodifiableSet(LPPermissionAttachment.this.perms.entrySet());
|
||||
return Collections.unmodifiableSet(LuckPermsPermissionAttachment.this.perms.entrySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof Map<?, ?> && LPPermissionAttachment.this.perms.equals(obj);
|
||||
return obj instanceof Map<?, ?> && LuckPermsPermissionAttachment.this.perms.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return LPPermissionAttachment.this.perms.hashCode();
|
||||
return LuckPermsPermissionAttachment.this.perms.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ import java.lang.reflect.Field;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Injects a {@link LPPermissible} into a {@link Player}.
|
||||
* Injects a {@link LuckPermsPermissible} into a {@link Player}.
|
||||
*
|
||||
* This allows LuckPerms to directly intercept permission checks and take over all handling of
|
||||
* checks made by plugins.
|
||||
@ -71,19 +71,19 @@ public final class PermissibleInjector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects a {@link LPPermissible} into a {@link Player}.
|
||||
* Injects a {@link LuckPermsPermissible} into a {@link Player}.
|
||||
*
|
||||
* @param player the player to inject into
|
||||
* @param newPermissible the permissible to inject
|
||||
* @throws Exception propagates any exceptions which were thrown during injection
|
||||
*/
|
||||
public static void inject(Player player, LPPermissible newPermissible) throws Exception {
|
||||
public static void inject(Player player, LuckPermsPermissible newPermissible) throws Exception {
|
||||
|
||||
// get the existing PermissibleBase held by the player
|
||||
PermissibleBase oldPermissible = (PermissibleBase) PLAYER_PERMISSIBLE_FIELD.get(player);
|
||||
|
||||
// seems we have already injected into this player.
|
||||
if (oldPermissible instanceof LPPermissible) {
|
||||
if (oldPermissible instanceof LuckPermsPermissible) {
|
||||
throw new IllegalStateException("LPPermissible already injected into player " + player.toString());
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ public final class PermissibleInjector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninjects a {@link LPPermissible} from a {@link Player}.
|
||||
* Uninjects a {@link LuckPermsPermissible} from a {@link Player}.
|
||||
*
|
||||
* @param player the player to uninject from
|
||||
* @param dummy if the replacement permissible should be a dummy.
|
||||
@ -117,8 +117,8 @@ public final class PermissibleInjector {
|
||||
PermissibleBase permissible = (PermissibleBase) PLAYER_PERMISSIBLE_FIELD.get(player);
|
||||
|
||||
// only uninject if the permissible was a luckperms one.
|
||||
if (permissible instanceof LPPermissible) {
|
||||
LPPermissible lpPermissible = ((LPPermissible) permissible);
|
||||
if (permissible instanceof LuckPermsPermissible) {
|
||||
LuckPermsPermissible lpPermissible = ((LuckPermsPermissible) permissible);
|
||||
|
||||
// clear all permissions
|
||||
lpPermissible.clearPermissions();
|
||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Injects a {@link LPDefaultsMap} info the {@link PluginManager}.
|
||||
* Injects a {@link LuckPermsDefaultsMap} info the {@link PluginManager}.
|
||||
*/
|
||||
public class InjectorDefaultsMap implements Runnable {
|
||||
private static final Field OP_DEFAULT_PERMISSIONS_FIELD;
|
||||
@ -74,9 +74,9 @@ public class InjectorDefaultsMap implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LPDefaultsMap ret = inject();
|
||||
if (ret != null) {
|
||||
this.plugin.setDefaultPermissionMap(ret);
|
||||
LuckPermsDefaultsMap defaultsMap = inject();
|
||||
if (defaultsMap != null) {
|
||||
this.plugin.setDefaultPermissionMap(defaultsMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Default Permission map.");
|
||||
@ -84,7 +84,7 @@ public class InjectorDefaultsMap implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private LPDefaultsMap inject() throws Exception {
|
||||
private LuckPermsDefaultsMap inject() throws Exception {
|
||||
Objects.requireNonNull(OP_DEFAULT_PERMISSIONS_FIELD, "OP_DEFAULT_PERMISSIONS_FIELD");
|
||||
Objects.requireNonNull(NON_OP_DEFAULT_PERMISSIONS_FIELD, "NON_OP_DEFAULT_PERMISSIONS_FIELD");
|
||||
|
||||
@ -93,8 +93,8 @@ public class InjectorDefaultsMap implements Runnable {
|
||||
Object opMap = OP_DEFAULT_PERMISSIONS_FIELD.get(pluginManager);
|
||||
Object nonOpMap = NON_OP_DEFAULT_PERMISSIONS_FIELD.get(pluginManager);
|
||||
|
||||
if (opMap instanceof LPDefaultsMap.DefaultPermissionSet && ((LPDefaultsMap.DefaultPermissionSet) opMap).parent.plugin == this.plugin) {
|
||||
if (nonOpMap instanceof LPDefaultsMap.DefaultPermissionSet && ((LPDefaultsMap.DefaultPermissionSet) nonOpMap).parent.plugin == this.plugin) {
|
||||
if (opMap instanceof LuckPermsDefaultsMap.DefaultPermissionSet && ((LuckPermsDefaultsMap.DefaultPermissionSet) opMap).parent.plugin == this.plugin) {
|
||||
if (nonOpMap instanceof LuckPermsDefaultsMap.DefaultPermissionSet && ((LuckPermsDefaultsMap.DefaultPermissionSet) nonOpMap).parent.plugin == this.plugin) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ public class InjectorDefaultsMap implements Runnable {
|
||||
Map<String, Permission> castedNonOpMap = (Map<String, Permission>) nonOpMap;
|
||||
|
||||
// make a new map & inject it
|
||||
LPDefaultsMap newMap = new LPDefaultsMap(this.plugin, ImmutableMap.of(true, castedOpMap, false, castedNonOpMap));
|
||||
LuckPermsDefaultsMap newMap = new LuckPermsDefaultsMap(this.plugin, ImmutableMap.of(true, castedOpMap, false, castedNonOpMap));
|
||||
OP_DEFAULT_PERMISSIONS_FIELD.set(pluginManager, newMap.getOpPermissions());
|
||||
NON_OP_DEFAULT_PERMISSIONS_FIELD.set(pluginManager, newMap.getNonOpPermissions());
|
||||
return newMap;
|
||||
@ -119,15 +119,15 @@ public class InjectorDefaultsMap implements Runnable {
|
||||
PluginManager pluginManager = Server.getInstance().getPluginManager();
|
||||
{
|
||||
Object map = OP_DEFAULT_PERMISSIONS_FIELD.get(pluginManager);
|
||||
if (map instanceof LPDefaultsMap.DefaultPermissionSet) {
|
||||
LPDefaultsMap.DefaultPermissionSet lpMap = (LPDefaultsMap.DefaultPermissionSet) map;
|
||||
if (map instanceof LuckPermsDefaultsMap.DefaultPermissionSet) {
|
||||
LuckPermsDefaultsMap.DefaultPermissionSet lpMap = (LuckPermsDefaultsMap.DefaultPermissionSet) map;
|
||||
OP_DEFAULT_PERMISSIONS_FIELD.set(pluginManager, new HashMap<>(lpMap));
|
||||
}
|
||||
}
|
||||
{
|
||||
Object map = NON_OP_DEFAULT_PERMISSIONS_FIELD.get(pluginManager);
|
||||
if (map instanceof LPDefaultsMap.DefaultPermissionSet) {
|
||||
LPDefaultsMap.DefaultPermissionSet lpMap = (LPDefaultsMap.DefaultPermissionSet) map;
|
||||
if (map instanceof LuckPermsDefaultsMap.DefaultPermissionSet) {
|
||||
LuckPermsDefaultsMap.DefaultPermissionSet lpMap = (LuckPermsDefaultsMap.DefaultPermissionSet) map;
|
||||
NON_OP_DEFAULT_PERMISSIONS_FIELD.set(pluginManager, new HashMap<>(lpMap));
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Injects a {@link LPPermissionMap} into the {@link PluginManager}.
|
||||
* Injects a {@link LuckPermsPermissionMap} into the {@link PluginManager}.
|
||||
*/
|
||||
public class InjectorPermissionMap implements Runnable {
|
||||
private static final Field PERMISSIONS_FIELD;
|
||||
@ -62,9 +62,9 @@ public class InjectorPermissionMap implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LPPermissionMap ret = inject();
|
||||
if (ret != null) {
|
||||
this.plugin.setPermissionMap(ret);
|
||||
LuckPermsPermissionMap permissionMap = inject();
|
||||
if (permissionMap != null) {
|
||||
this.plugin.setPermissionMap(permissionMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Permission map.");
|
||||
@ -72,12 +72,12 @@ public class InjectorPermissionMap implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private LPPermissionMap inject() throws Exception {
|
||||
private LuckPermsPermissionMap inject() throws Exception {
|
||||
Objects.requireNonNull(PERMISSIONS_FIELD, "PERMISSIONS_FIELD");
|
||||
PluginManager pluginManager = this.plugin.getBootstrap().getServer().getPluginManager();
|
||||
|
||||
Object map = PERMISSIONS_FIELD.get(pluginManager);
|
||||
if (map instanceof LPPermissionMap && ((LPPermissionMap) map).plugin == this.plugin) {
|
||||
if (map instanceof LuckPermsPermissionMap && ((LuckPermsPermissionMap) map).plugin == this.plugin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ public class InjectorPermissionMap implements Runnable {
|
||||
Map<String, Permission> castedMap = (Map<String, Permission>) map;
|
||||
|
||||
// make a new map & inject it
|
||||
LPPermissionMap newMap = new LPPermissionMap(this.plugin, castedMap);
|
||||
LuckPermsPermissionMap newMap = new LuckPermsPermissionMap(this.plugin, castedMap);
|
||||
PERMISSIONS_FIELD.set(pluginManager, newMap);
|
||||
return newMap;
|
||||
}
|
||||
@ -96,8 +96,8 @@ public class InjectorPermissionMap implements Runnable {
|
||||
PluginManager pluginManager = Server.getInstance().getPluginManager();
|
||||
|
||||
Object map = PERMISSIONS_FIELD.get(pluginManager);
|
||||
if (map instanceof LPPermissionMap) {
|
||||
LPPermissionMap lpMap = (LPPermissionMap) map;
|
||||
if (map instanceof LuckPermsPermissionMap) {
|
||||
LuckPermsPermissionMap lpMap = (LuckPermsPermissionMap) map;
|
||||
PERMISSIONS_FIELD.set(pluginManager, new HashMap<>(lpMap));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -37,7 +37,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Injects a {@link LPSubscriptionMap} into the {@link PluginManager}.
|
||||
* Injects a {@link LuckPermsSubscriptionMap} into the {@link PluginManager}.
|
||||
*/
|
||||
public class InjectorSubscriptionMap implements Runnable {
|
||||
private static final Field PERM_SUBS_FIELD;
|
||||
@ -62,9 +62,9 @@ public class InjectorSubscriptionMap implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LPSubscriptionMap ret = inject();
|
||||
if (ret != null) {
|
||||
this.plugin.setSubscriptionMap(ret);
|
||||
LuckPermsSubscriptionMap subscriptionMap = inject();
|
||||
if (subscriptionMap != null) {
|
||||
this.plugin.setSubscriptionMap(subscriptionMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.plugin.getLogger().severe("Exception occurred whilst injecting LuckPerms Permission Subscription map.");
|
||||
@ -72,24 +72,24 @@ public class InjectorSubscriptionMap implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private LPSubscriptionMap inject() throws Exception {
|
||||
private LuckPermsSubscriptionMap inject() throws Exception {
|
||||
Objects.requireNonNull(PERM_SUBS_FIELD, "PERM_SUBS_FIELD");
|
||||
PluginManager pluginManager = this.plugin.getBootstrap().getServer().getPluginManager();
|
||||
|
||||
Object map = PERM_SUBS_FIELD.get(pluginManager);
|
||||
if (map instanceof LPSubscriptionMap) {
|
||||
if (((LPSubscriptionMap) map).plugin == this.plugin) {
|
||||
if (map instanceof LuckPermsSubscriptionMap) {
|
||||
if (((LuckPermsSubscriptionMap) map).plugin == this.plugin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
map = ((LPSubscriptionMap) map).detach();
|
||||
map = ((LuckPermsSubscriptionMap) map).detach();
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
Map<String, Set<Permissible>> castedMap = (Map<String, Set<Permissible>>) map;
|
||||
|
||||
// make a new subscription map & inject it
|
||||
LPSubscriptionMap newMap = new LPSubscriptionMap(this.plugin, castedMap);
|
||||
LuckPermsSubscriptionMap newMap = new LuckPermsSubscriptionMap(this.plugin, castedMap);
|
||||
PERM_SUBS_FIELD.set(pluginManager, newMap);
|
||||
return newMap;
|
||||
}
|
||||
@ -100,8 +100,8 @@ public class InjectorSubscriptionMap implements Runnable {
|
||||
PluginManager pluginManager = Server.getInstance().getPluginManager();
|
||||
|
||||
Object map = PERM_SUBS_FIELD.get(pluginManager);
|
||||
if (map instanceof LPSubscriptionMap) {
|
||||
LPSubscriptionMap lpMap = (LPSubscriptionMap) map;
|
||||
if (map instanceof LuckPermsSubscriptionMap) {
|
||||
LuckPermsSubscriptionMap lpMap = (LuckPermsSubscriptionMap) map;
|
||||
PERM_SUBS_FIELD.set(pluginManager, lpMap.detach());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -52,7 +52,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*
|
||||
* Injected by {@link InjectorDefaultsMap}.
|
||||
*/
|
||||
public final class LPDefaultsMap {
|
||||
public final class LuckPermsDefaultsMap {
|
||||
|
||||
// the plugin
|
||||
final LPNukkitPlugin plugin;
|
||||
@ -65,7 +65,7 @@ public final class LPDefaultsMap {
|
||||
private final DefaultsCache opCache = new DefaultsCache(true);
|
||||
private final DefaultsCache nonOpCache = new DefaultsCache(false);
|
||||
|
||||
public LPDefaultsMap(LPNukkitPlugin plugin, Map<Boolean, Map<String, Permission>> existingData) {
|
||||
public LuckPermsDefaultsMap(LPNukkitPlugin plugin, Map<Boolean, Map<String, Permission>> existingData) {
|
||||
this.plugin = plugin;
|
||||
this.opSet.putAll(existingData.getOrDefault(Boolean.TRUE, Collections.emptyMap()));
|
||||
this.nonOpSet.putAll(existingData.getOrDefault(Boolean.FALSE, Collections.emptyMap()));
|
||||
@ -106,7 +106,7 @@ public final class LPDefaultsMap {
|
||||
}
|
||||
|
||||
final class DefaultPermissionSet extends ForwardingMap<String, Permission> {
|
||||
final LPDefaultsMap parent = LPDefaultsMap.this;
|
||||
final LuckPermsDefaultsMap parent = LuckPermsDefaultsMap.this;
|
||||
|
||||
private final Map<String, Permission> delegate = new ConcurrentHashMap<>();
|
||||
private final boolean op;
|
||||
@ -158,10 +158,10 @@ public final class LPDefaultsMap {
|
||||
@Override
|
||||
protected @NonNull Map<String, Boolean> supply() {
|
||||
Map<String, Boolean> builder = new HashMap<>();
|
||||
for (Permission perm : LPDefaultsMap.this.get(this.op).values()) {
|
||||
for (Permission perm : LuckPermsDefaultsMap.this.get(this.op).values()) {
|
||||
String name = perm.getName().toLowerCase();
|
||||
builder.put(name, true);
|
||||
for (Map.Entry<String, Boolean> child : LPDefaultsMap.this.plugin.getPermissionMap().getChildPermissions(name, true).entrySet()) {
|
||||
for (Map.Entry<String, Boolean> child : LuckPermsDefaultsMap.this.plugin.getPermissionMap().getChildPermissions(name, true).entrySet()) {
|
||||
builder.putIfAbsent(child.getKey(), child.getValue());
|
||||
}
|
||||
}
|
@ -57,7 +57,7 @@ import java.util.function.Function;
|
||||
*
|
||||
* Injected by {@link InjectorPermissionMap}.
|
||||
*/
|
||||
public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
||||
public final class LuckPermsPermissionMap extends ForwardingMap<String, Permission> {
|
||||
|
||||
private static final Field PERMISSION_CHILDREN_FIELD;
|
||||
|
||||
@ -82,7 +82,7 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
||||
*/
|
||||
final LuckPermsPlugin plugin;
|
||||
|
||||
public LPPermissionMap(LuckPermsPlugin plugin, Map<String, Permission> existingData) {
|
||||
public LuckPermsPermissionMap(LuckPermsPlugin plugin, Map<String, Permission> existingData) {
|
||||
this.plugin = plugin;
|
||||
putAll(existingData);
|
||||
}
|
||||
@ -243,27 +243,27 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
||||
@Override
|
||||
public Boolean put(@NonNull String key, @NonNull Boolean value) {
|
||||
Boolean ret = super.put(key, value);
|
||||
LPPermissionMap.this.update();
|
||||
LuckPermsPermissionMap.this.update();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(@NonNull Map<? extends String, ? extends Boolean> map) {
|
||||
super.putAll(map);
|
||||
LPPermissionMap.this.update();
|
||||
LuckPermsPermissionMap.this.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean remove(@NonNull Object object) {
|
||||
Boolean ret = super.remove(object);
|
||||
LPPermissionMap.this.update();
|
||||
LuckPermsPermissionMap.this.update();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
LPPermissionMap.this.update();
|
||||
LuckPermsPermissionMap.this.update();
|
||||
}
|
||||
}
|
||||
|
@ -64,12 +64,12 @@ import java.util.stream.Collectors;
|
||||
*
|
||||
* Injected by {@link InjectorSubscriptionMap}.
|
||||
*/
|
||||
public final class LPSubscriptionMap extends HashMap<String, Set<Permissible>> {
|
||||
public final class LuckPermsSubscriptionMap extends HashMap<String, Set<Permissible>> {
|
||||
|
||||
// the plugin instance
|
||||
final LPNukkitPlugin plugin;
|
||||
|
||||
public LPSubscriptionMap(LPNukkitPlugin plugin, Map<String, Set<Permissible>> existingData) {
|
||||
public LuckPermsSubscriptionMap(LPNukkitPlugin plugin, Map<String, Set<Permissible>> existingData) {
|
||||
super(existingData);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@ -131,19 +131,19 @@ public final class LPSubscriptionMap extends HashMap<String, Set<Permissible>> {
|
||||
* @return a standard representation of this map
|
||||
*/
|
||||
public Map<String, Set<Permissible>> detach() {
|
||||
Map<String, Set<Permissible>> ret = new HashMap<>();
|
||||
Map<String, Set<Permissible>> map = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, Set<Permissible>> ent : entrySet()) {
|
||||
if (ent.getValue() instanceof LPSubscriptionValueSet) {
|
||||
Set<Permissible> backing = ((LPSubscriptionValueSet) ent.getValue()).backing;
|
||||
Set<Permissible> copy; (copy = Collections.newSetFromMap(new WeakHashMap<>(backing.size()))).addAll(backing);
|
||||
ret.put(ent.getKey(), copy);
|
||||
map.put(ent.getKey(), copy);
|
||||
} else {
|
||||
ret.put(ent.getKey(), ent.getValue());
|
||||
map.put(ent.getKey(), ent.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,7 +175,7 @@ public final class LPSubscriptionMap extends HashMap<String, Set<Permissible>> {
|
||||
|
||||
private Sets.SetView<Permissible> getContentView() {
|
||||
// gather players (LPPermissibles)
|
||||
Set<Permissible> players = LPSubscriptionMap.this.plugin.getBootstrap().getServer().getOnlinePlayers().values().stream()
|
||||
Set<Permissible> players = LuckPermsSubscriptionMap.this.plugin.getBootstrap().getServer().getOnlinePlayers().values().stream()
|
||||
.filter(player -> player.hasPermission(this.permission) || player.isPermissionSet(this.permission))
|
||||
.collect(Collectors.toSet());
|
||||
|
@ -30,7 +30,7 @@ import me.lucko.luckperms.common.locale.message.Message;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
|
||||
import me.lucko.luckperms.nukkit.LPNukkitPlugin;
|
||||
import me.lucko.luckperms.nukkit.inject.permissible.LPPermissible;
|
||||
import me.lucko.luckperms.nukkit.inject.permissible.LuckPermsPermissible;
|
||||
import me.lucko.luckperms.nukkit.inject.permissible.PermissibleInjector;
|
||||
|
||||
import cn.nukkit.Player;
|
||||
@ -151,7 +151,7 @@ public class NukkitConnectionListener extends AbstractConnectionListener impleme
|
||||
// Care should be taken at this stage to ensure that async tasks which manipulate nukkit data check that the player is still online.
|
||||
try {
|
||||
// Make a new permissible for the user
|
||||
LPPermissible lpPermissible = new LPPermissible(player, user, this.plugin);
|
||||
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this.plugin);
|
||||
|
||||
// Inject into the player
|
||||
PermissibleInjector.inject(player, lpPermissible);
|
||||
|
@ -78,9 +78,9 @@ public final class SubjectReferenceFactory {
|
||||
|
||||
public LPSubjectReference obtain(LPSubject subject) {
|
||||
Objects.requireNonNull(subject, "subject");
|
||||
LPSubjectReference ret = obtain(subject.getParentCollection().getIdentifier(), subject.getIdentifier());
|
||||
((CachedSubjectReference) ret).fillCache(subject);
|
||||
return ret;
|
||||
LPSubjectReference reference = obtain(subject.getParentCollection().getIdentifier(), subject.getIdentifier());
|
||||
((CachedSubjectReference) reference).fillCache(subject);
|
||||
return reference;
|
||||
}
|
||||
|
||||
public LPSubjectReference obtain(Subject subject) {
|
||||
|
@ -103,7 +103,7 @@ public class SpongeCommandExecutor extends CommandManager implements CommandCall
|
||||
.filter(e -> e instanceof Player)
|
||||
.map(e -> ((Player) e))
|
||||
.findFirst()
|
||||
.ifPresent(ret -> it.set(ret.getUniqueId().toString()));
|
||||
.ifPresent(player -> it.set(player.getUniqueId().toString()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// ignored
|
||||
}
|
||||
|
@ -74,14 +74,14 @@ public class SpongeSenderFactory extends SenderFactory<CommandSource> {
|
||||
|
||||
@Override
|
||||
protected Tristate getPermissionValue(CommandSource source, String node) {
|
||||
Tristate ret = CompatibilityUtil.convertTristate(source.getPermissionValue(source.getActiveContexts(), node));
|
||||
Tristate result = CompatibilityUtil.convertTristate(source.getPermissionValue(source.getActiveContexts(), node));
|
||||
|
||||
// check the permdefault
|
||||
if (ret == Tristate.UNDEFINED && source.hasPermission(node)) {
|
||||
ret = Tristate.TRUE;
|
||||
if (result == Tristate.UNDEFINED && source.hasPermission(node)) {
|
||||
result = Tristate.TRUE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,15 +166,15 @@ public class SpongeGroupManager extends AbstractGroupManager<SpongeGroup> implem
|
||||
@Override
|
||||
public CompletableFuture<ImmutableCollection<LPSubject>> loadSubjects(Set<String> identifiers) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ImmutableSet.Builder<LPSubject> ret = ImmutableSet.builder();
|
||||
ImmutableSet.Builder<LPSubject> subjects = ImmutableSet.builder();
|
||||
for (String id : identifiers) {
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(id)) {
|
||||
continue;
|
||||
}
|
||||
ret.add(loadSubject(id.toLowerCase()).join());
|
||||
subjects.add(loadSubject(id.toLowerCase()).join());
|
||||
}
|
||||
|
||||
return ret.build();
|
||||
return subjects.build();
|
||||
}, this.plugin.getBootstrap().getScheduler().async());
|
||||
}
|
||||
|
||||
@ -191,32 +191,32 @@ public class SpongeGroupManager extends AbstractGroupManager<SpongeGroup> implem
|
||||
@Override
|
||||
public CompletableFuture<ImmutableMap<LPSubjectReference, Boolean>> getAllWithPermission(String permission) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ImmutableMap.Builder<LPSubjectReference, Boolean> ret = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<LPSubjectReference, Boolean> builder = ImmutableMap.builder();
|
||||
|
||||
List<HeldNode<String>> lookup = this.plugin.getStorage().getGroupsWithPermission(Constraint.of(StandardComparison.EQUAL, permission)).join();
|
||||
for (HeldNode<String> holder : lookup) {
|
||||
if (holder.getNode().getContexts().equals(ImmutableContextSetImpl.EMPTY)) {
|
||||
ret.put(getService().getReferenceFactory().obtain(getIdentifier(), holder.getHolder()), holder.getNode().getValue());
|
||||
builder.put(getService().getReferenceFactory().obtain(getIdentifier(), holder.getHolder()), holder.getNode().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return ret.build();
|
||||
return builder.build();
|
||||
}, this.plugin.getBootstrap().getScheduler().async());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<ImmutableMap<LPSubjectReference, Boolean>> getAllWithPermission(ImmutableContextSet contexts, String permission) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ImmutableMap.Builder<LPSubjectReference, Boolean> ret = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<LPSubjectReference, Boolean> builder = ImmutableMap.builder();
|
||||
|
||||
List<HeldNode<String>> lookup = this.plugin.getStorage().getGroupsWithPermission(Constraint.of(StandardComparison.EQUAL, permission)).join();
|
||||
for (HeldNode<String> holder : lookup) {
|
||||
if (holder.getNode().getContexts().equals(contexts)) {
|
||||
ret.put(getService().getReferenceFactory().obtain(getIdentifier(), holder.getHolder()), holder.getNode().getValue());
|
||||
builder.put(getService().getReferenceFactory().obtain(getIdentifier(), holder.getHolder()), holder.getNode().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return ret.build();
|
||||
return builder.build();
|
||||
}, this.plugin.getBootstrap().getScheduler().async());
|
||||
}
|
||||
|
||||
|
@ -177,16 +177,16 @@ public class SpongeUserManager extends AbstractUserManager<SpongeUser> implement
|
||||
@Override
|
||||
public CompletableFuture<ImmutableCollection<LPSubject>> loadSubjects(Set<String> identifiers) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ImmutableSet.Builder<LPSubject> ret = ImmutableSet.builder();
|
||||
ImmutableSet.Builder<LPSubject> subjects = ImmutableSet.builder();
|
||||
for (String id : identifiers) {
|
||||
UUID uuid = Uuids.parse(id);
|
||||
if (uuid == null) {
|
||||
continue;
|
||||
}
|
||||
ret.add(loadSubject(uuid.toString()).join());
|
||||
subjects.add(loadSubject(uuid.toString()).join());
|
||||
}
|
||||
|
||||
return ret.build();
|
||||
return subjects.build();
|
||||
}, this.plugin.getBootstrap().getScheduler().async());
|
||||
}
|
||||
|
||||
@ -210,32 +210,32 @@ public class SpongeUserManager extends AbstractUserManager<SpongeUser> implement
|
||||
@Override
|
||||
public CompletableFuture<ImmutableMap<LPSubjectReference, Boolean>> getAllWithPermission(String permission) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ImmutableMap.Builder<LPSubjectReference, Boolean> ret = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<LPSubjectReference, Boolean> builder = ImmutableMap.builder();
|
||||
|
||||
List<HeldNode<UUID>> lookup = this.plugin.getStorage().getUsersWithPermission(Constraint.of(StandardComparison.EQUAL, permission)).join();
|
||||
for (HeldNode<UUID> holder : lookup) {
|
||||
if (holder.getNode().getContexts().equals(ImmutableContextSetImpl.EMPTY)) {
|
||||
ret.put(getService().getReferenceFactory().obtain(getIdentifier(), holder.getHolder().toString()), holder.getNode().getValue());
|
||||
builder.put(getService().getReferenceFactory().obtain(getIdentifier(), holder.getHolder().toString()), holder.getNode().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return ret.build();
|
||||
return builder.build();
|
||||
}, this.plugin.getBootstrap().getScheduler().async());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<ImmutableMap<LPSubjectReference, Boolean>> getAllWithPermission(ImmutableContextSet contexts, String permission) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ImmutableMap.Builder<LPSubjectReference, Boolean> ret = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<LPSubjectReference, Boolean> builder = ImmutableMap.builder();
|
||||
|
||||
List<HeldNode<UUID>> lookup = this.plugin.getStorage().getUsersWithPermission(Constraint.of(StandardComparison.EQUAL, permission)).join();
|
||||
for (HeldNode<UUID> holder : lookup) {
|
||||
if (holder.getNode().getContexts().equals(contexts)) {
|
||||
ret.put(getService().getReferenceFactory().obtain(getIdentifier(), holder.getHolder().toString()), holder.getNode().getValue());
|
||||
builder.put(getService().getReferenceFactory().obtain(getIdentifier(), holder.getHolder().toString()), holder.getNode().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return ret.build();
|
||||
return builder.build();
|
||||
}, this.plugin.getBootstrap().getScheduler().async());
|
||||
}
|
||||
|
||||
|
@ -97,15 +97,15 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
|
||||
@Override
|
||||
public ImmutableMap<ImmutableContextSet, ImmutableMap<String, Boolean>> getAllPermissions() {
|
||||
ImmutableMap.Builder<ImmutableContextSet, ImmutableMap<String, Boolean>> ret = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<ImmutableContextSet, ImmutableMap<String, Boolean>> permissions = ImmutableMap.builder();
|
||||
for (Map.Entry<ImmutableContextSet, ? extends Collection<? extends Node>> entry : this.holder.getData(this.type).immutable().asMap().entrySet()) {
|
||||
ImmutableMap.Builder<String, Boolean> builder = ImmutableMap.builder();
|
||||
for (Node n : entry.getValue()) {
|
||||
builder.put(n.getKey(), n.getValue());
|
||||
}
|
||||
ret.put(entry.getKey(), builder.build());
|
||||
permissions.put(entry.getKey(), builder.build());
|
||||
}
|
||||
return ret.build();
|
||||
return permissions.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -158,15 +158,15 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
|
||||
@Override
|
||||
public ImmutableMap<ImmutableContextSet, ImmutableList<LPSubjectReference>> getAllParents() {
|
||||
ImmutableMap.Builder<ImmutableContextSet, ImmutableList<LPSubjectReference>> ret = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<ImmutableContextSet, ImmutableList<LPSubjectReference>> parents = ImmutableMap.builder();
|
||||
for (Map.Entry<ImmutableContextSet, ? extends Collection<? extends InheritanceNode>> entry : this.holder.getData(this.type).immutableInheritance().asMap().entrySet()) {
|
||||
ImmutableList.Builder<LPSubjectReference> builder = ImmutableList.builder();
|
||||
for (InheritanceNode n : entry.getValue()) {
|
||||
builder.add(this.service.getGroupSubjects().loadSubject(n.getGroupName()).join().toReference());
|
||||
}
|
||||
ret.put(entry.getKey(), builder.build());
|
||||
parents.put(entry.getKey(), builder.build());
|
||||
}
|
||||
return ret.build();
|
||||
return parents.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -240,11 +240,11 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
|
||||
@Override
|
||||
public ImmutableMap<ImmutableContextSet, ImmutableMap<String, String>> getAllOptions() {
|
||||
ImmutableMap.Builder<ImmutableContextSet, ImmutableMap<String, String>> ret = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<ImmutableContextSet, ImmutableMap<String, String>> options = ImmutableMap.builder();
|
||||
for (Map.Entry<ImmutableContextSet, ? extends Collection<? extends Node>> entry : this.holder.getData(this.type).immutable().asMap().entrySet()) {
|
||||
ret.put(entry.getKey(), nodesToOptions(entry.getValue()));
|
||||
options.put(entry.getKey(), nodesToOptions(entry.getValue()));
|
||||
}
|
||||
return ret.build();
|
||||
return options.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -143,11 +143,11 @@ public class PersistedCollection implements LPSubjectCollection {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<ImmutableCollection<LPSubject>> loadSubjects(Set<String> identifiers) {
|
||||
ImmutableSet.Builder<LPSubject> ret = ImmutableSet.builder();
|
||||
ImmutableSet.Builder<LPSubject> subjects = ImmutableSet.builder();
|
||||
for (String id : identifiers) {
|
||||
ret.add(Objects.requireNonNull(this.subjects.get(id.toLowerCase())));
|
||||
subjects.add(Objects.requireNonNull(this.subjects.get(id.toLowerCase())));
|
||||
}
|
||||
return CompletableFuture.completedFuture(ret.build());
|
||||
return CompletableFuture.completedFuture(subjects.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user