mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +01:00
misc cleanup
This commit is contained in:
parent
35d1057673
commit
df99ef4481
@ -194,14 +194,13 @@ public class Contexts {
|
|||||||
final Contexts other = (Contexts) o;
|
final Contexts other = (Contexts) o;
|
||||||
final Object this$context = this.getContexts();
|
final Object this$context = this.getContexts();
|
||||||
final Object other$context = other.getContexts();
|
final Object other$context = other.getContexts();
|
||||||
if (this$context == null ? other$context != null : !this$context.equals(other$context)) return false;
|
return (this$context == null ? other$context == null : this$context.equals(other$context)) &&
|
||||||
if (this.isOp() != other.isOp()) return false;
|
this.isOp() == other.isOp() &&
|
||||||
if (this.isIncludeGlobal() != other.isIncludeGlobal()) return false;
|
this.isIncludeGlobal() == other.isIncludeGlobal() &&
|
||||||
if (this.isIncludeGlobalWorld() != other.isIncludeGlobalWorld()) return false;
|
this.isIncludeGlobalWorld() == other.isIncludeGlobalWorld() &&
|
||||||
if (this.isApplyGroups() != other.isApplyGroups()) return false;
|
this.isApplyGroups() == other.isApplyGroups() &&
|
||||||
if (this.isApplyGlobalGroups() != other.isApplyGlobalGroups()) return false;
|
this.isApplyGlobalGroups() == other.isApplyGlobalGroups() &&
|
||||||
if (this.isApplyGlobalWorldGroups() != other.isApplyGlobalWorldGroups()) return false;
|
this.isApplyGlobalWorldGroups() == other.isApplyGlobalWorldGroups();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,13 +171,13 @@ public class LogEntry implements Comparable<LogEntry> {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof LogEntry)) return false;
|
if (!(o instanceof LogEntry)) return false;
|
||||||
final LogEntry other = (LogEntry) o;
|
final LogEntry other = (LogEntry) o;
|
||||||
if (this.getTimestamp() != other.getTimestamp()) return false;
|
return this.getTimestamp() == other.getTimestamp() &&
|
||||||
if (this.getActor() == null ? other.getActor() != null : !this.getActor().equals(other.getActor())) return false;
|
(this.getActor() == null ? other.getActor() == null : this.getActor().equals(other.getActor())) &&
|
||||||
if (this.getActorName() == null ? other.getActorName() != null : !this.getActorName().equals(other.getActorName())) return false;
|
(this.getActorName() == null ? other.getActorName() == null : this.getActorName().equals(other.getActorName())) &&
|
||||||
if (this.getType() != other.getType()) return false;
|
this.getType() == other.getType() &&
|
||||||
if (this.getActed() == null ? other.getActed() != null : !this.getActed().equals(other.getActed())) return false;
|
(this.getActed() == null ? other.getActed() == null : this.getActed().equals(other.getActed())) &&
|
||||||
if (this.getActedName() == null ? other.getActedName() != null : !this.getActedName().equals(other.getActedName())) return false;
|
(this.getActedName() == null ? other.getActedName() == null : this.getActedName().equals(other.getActedName())) &&
|
||||||
return this.getAction() == null ? other.getAction() == null : this.getAction().equals(other.getAction());
|
(this.getAction() == null ? other.getAction() == null : this.getAction().equals(other.getAction()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -149,8 +149,7 @@ public class MetaUtils {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
holder.setPermission(metaNode.build());
|
holder.setPermission(metaNode.build());
|
||||||
} catch (ObjectAlreadyHasException ignored) {
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -233,8 +232,7 @@ public class MetaUtils {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
holder.setPermission(node.build());
|
holder.setPermission(node.build());
|
||||||
} catch (ObjectAlreadyHasException ignored) {
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,6 +40,6 @@ public enum CreationCause {
|
|||||||
/**
|
/**
|
||||||
* The creation was caused by a LuckPerms internal
|
* The creation was caused by a LuckPerms internal
|
||||||
*/
|
*/
|
||||||
INTERNAL;
|
INTERNAL
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,6 @@ public enum DeletionCause {
|
|||||||
/**
|
/**
|
||||||
* The deletion was caused by a LuckPerms internal
|
* The deletion was caused by a LuckPerms internal
|
||||||
*/
|
*/
|
||||||
INTERNAL;
|
INTERNAL
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,6 @@ public enum TrackAction {
|
|||||||
/**
|
/**
|
||||||
* The user was demoted down a track
|
* The user was demoted down a track
|
||||||
*/
|
*/
|
||||||
DEMOTION;
|
DEMOTION
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -146,9 +146,7 @@ public class LuckPermsPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
String trackName = identifier.substring("on_track_".length());
|
String trackName = identifier.substring("on_track_".length());
|
||||||
|
|
||||||
Optional<Track> track = api.getTrackSafe(trackName);
|
Optional<Track> track = api.getTrackSafe(trackName);
|
||||||
if (!track.isPresent()) return "";
|
return track.map(t -> formatBoolean(t.containsGroup(user.getPrimaryGroup()))).orElse("");
|
||||||
|
|
||||||
return formatBoolean(track.get().containsGroup(user.getPrimaryGroup()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (identifier.startsWith("expiry_time_") && identifier.length() > "expiry_time_".length()) {
|
if (identifier.startsWith("expiry_time_") && identifier.length() > "expiry_time_".length()) {
|
||||||
|
@ -288,9 +288,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// replace the temporary executor when the Bukkit one starts
|
// replace the temporary executor when the Bukkit one starts
|
||||||
getServer().getScheduler().runTaskAsynchronously(this, () -> {
|
getServer().getScheduler().runTaskAsynchronously(this, () -> scheduler.setUseBukkitAsync(true));
|
||||||
scheduler.setUseBukkitAsync(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Load any online users (in the case of a reload)
|
// Load any online users (in the case of a reload)
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
|
@ -64,12 +64,11 @@ public class BungeeMessagingService extends AbstractMessagingService implements
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Collection<? extends Player> players = plugin.getServer().getOnlinePlayers();
|
Collection<? extends Player> players = plugin.getServer().getOnlinePlayers();
|
||||||
if (players.isEmpty()) {
|
Player p = Iterables.getFirst(players, null);
|
||||||
|
if (p == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player p = Iterables.getFirst(players, null);
|
|
||||||
|
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
out.writeUTF(message);
|
out.writeUTF(message);
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
import static me.lucko.luckperms.common.constants.Permission.MIGRATION;
|
import static me.lucko.luckperms.common.constants.Permission.MIGRATION;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public class MigrationPowerfulPerms extends SubCommand<Object> {
|
public class MigrationPowerfulPerms extends SubCommand<Object> {
|
||||||
private static Method getPlayerPermissionsMethod = null;
|
private static Method getPlayerPermissionsMethod = null;
|
||||||
private static Method getPlayerGroupsMethod = null;
|
private static Method getPlayerGroupsMethod = null;
|
||||||
|
@ -38,6 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
/**
|
/**
|
||||||
* Injects a {@link LPPermissible} into a {@link Player}
|
* Injects a {@link LPPermissible} into a {@link Player}
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class Injector {
|
public class Injector {
|
||||||
private static final Map<UUID, LPPermissible> INJECTED_PERMISSIBLES = new ConcurrentHashMap<>();
|
private static final Map<UUID, LPPermissible> INJECTED_PERMISSIBLES = new ConcurrentHashMap<>();
|
||||||
|
@ -111,7 +111,7 @@ public class CommandManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic on command method to be called from the command executor object of the platform
|
* Generic on command method to be called from the command executor object of the platform
|
||||||
* Unlike {@link #onCommand(Sender, String, List)}, this method is called in a new thread
|
* Unlike {@link #execute(Sender, String, List)}, this method is called in a new thread
|
||||||
* @param sender who sent the command
|
* @param sender who sent the command
|
||||||
* @param label the command label used
|
* @param label the command label used
|
||||||
* @param args the arguments provided
|
* @param args the arguments provided
|
||||||
|
@ -175,6 +175,7 @@ public abstract class MainCommand<T> extends BaseCommand<Void, T> {
|
|||||||
return getSubCommands().stream().filter(sc -> sc.isAuthorized(sender)).count() != 0;
|
return getSubCommands().stream().filter(sc -> sc.isAuthorized(sender)).count() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public Optional<List<Command<T, ?>>> getChildren() {
|
public Optional<List<Command<T, ?>>> getChildren() {
|
||||||
|
@ -79,8 +79,7 @@ public class ParentSet extends SharedSubCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
holder.setInheritGroup(group);
|
holder.setInheritGroup(group);
|
||||||
} catch (ObjectAlreadyHasException ignored) {
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
}
|
|
||||||
|
|
||||||
if (holder instanceof User) {
|
if (holder instanceof User) {
|
||||||
((User) holder).setPrimaryGroup(group.getName());
|
((User) holder).setPrimaryGroup(group.getName());
|
||||||
@ -107,8 +106,7 @@ public class ParentSet extends SharedSubCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
holder.setInheritGroup(group, server, world);
|
holder.setInheritGroup(group, server, world);
|
||||||
} catch (ObjectAlreadyHasException ignored) {
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
}
|
|
||||||
|
|
||||||
Message.SET_PARENT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server, world);
|
Message.SET_PARENT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server, world);
|
||||||
break;
|
break;
|
||||||
|
@ -97,7 +97,7 @@ public class LogRecent extends SubCommand<Log> {
|
|||||||
|
|
||||||
// User and possibly page
|
// User and possibly page
|
||||||
final String s = args.get(0);
|
final String s = args.get(0);
|
||||||
UUID u = null;
|
UUID u;
|
||||||
|
|
||||||
u = Util.parseUuid(s);
|
u = Util.parseUuid(s);
|
||||||
if (u == null) {
|
if (u == null) {
|
||||||
|
@ -101,7 +101,7 @@ public class MigrationMainCommand extends MainCommand<Object> {
|
|||||||
super("Migration", "Migration commands", "/%s migration", 1, null);
|
super("Migration", "Migration commands", "/%s migration", 1, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "DeprecatedIsStillUsed"})
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public synchronized Optional<List<Command<Object, ?>>> getChildren() {
|
public synchronized Optional<List<Command<Object, ?>>> getChildren() {
|
||||||
|
@ -27,10 +27,12 @@ import lombok.experimental.UtilityClass;
|
|||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -49,11 +51,18 @@ public class Patterns {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private static final LoadingCache<Map.Entry<String, String>, String> DELIMITER_CACHE = CacheBuilder.newBuilder()
|
||||||
|
.build(new CacheLoader<Map.Entry<String, String>, String>() {
|
||||||
|
@Override
|
||||||
|
public String load(Map.Entry<String, String> e) {
|
||||||
|
return "(?<!" + Pattern.quote(e.getKey()) + ")" + Pattern.quote(e.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
public static final Pattern COMMAND_SEPARATOR = Pattern.compile(" (?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
|
public static final Pattern COMMAND_SEPARATOR = Pattern.compile(" (?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
|
||||||
public static final Pattern NON_ALPHA_NUMERIC = Pattern.compile("[\\/\\$\\.\\- ]");
|
public static final Pattern NON_ALPHA_NUMERIC = Pattern.compile("[\\/\\$\\.\\- ]");
|
||||||
public static final Pattern NON_ALPHA_NUMERIC_SPACE = Pattern.compile("[\\/\\$\\.\\-]");
|
public static final Pattern NON_ALPHA_NUMERIC_SPACE = Pattern.compile("[\\/\\$\\.\\-]");
|
||||||
public static final Pattern NON_USERNAME = Pattern.compile("[^A-Za-z0-9_ ]");
|
public static final Pattern NON_USERNAME = Pattern.compile("[^A-Za-z0-9_ ]");
|
||||||
public static final Pattern SHORTHAND_NODE = Pattern.compile("\\.\\([^.]+\\)");
|
|
||||||
public static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('§') + "[0-9A-FK-OR]");
|
public static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('§') + "[0-9A-FK-OR]");
|
||||||
public static final Pattern NODE_CONTEXTS = Pattern.compile("\\(.+\\).*");
|
public static final Pattern NODE_CONTEXTS = Pattern.compile("\\(.+\\).*");
|
||||||
|
|
||||||
@ -67,7 +76,7 @@ public class Patterns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String buildDelimitedMatcher(String delim, String esc) {
|
public static String buildDelimitedMatcher(String delim, String esc) {
|
||||||
return "(?<!" + Pattern.quote(esc) + ")" + Pattern.quote(delim);
|
return DELIMITER_CACHE.getUnchecked(Maps.immutableEntry(delim, esc));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Pattern compileDelimitedMatcher(String delim, String esc) {
|
public static Pattern compileDelimitedMatcher(String delim, String esc) {
|
||||||
|
@ -242,4 +242,60 @@ public class NodeFactory {
|
|||||||
public static boolean isSuffixNode(String s) {
|
public static boolean isSuffixNode(String s) {
|
||||||
return isChatMetaNode("suffix", s);
|
return isChatMetaNode("suffix", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Node make(String node) {
|
||||||
|
return newBuilder(node).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, boolean value) {
|
||||||
|
return newBuilder(node).setValue(value).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, boolean value, String server) {
|
||||||
|
return newBuilder(node).setValue(value).setServer(server).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, boolean value, String server, String world) {
|
||||||
|
return newBuilder(node).setValue(value).setServer(server).setWorld(world).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, String server) {
|
||||||
|
return newBuilder(node).setServer(server).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, String server, String world) {
|
||||||
|
return newBuilder(node).setServer(server).setWorld(world).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, boolean value, boolean temporary) {
|
||||||
|
return newBuilder(node).setValue(value).setExpiry(temporary ? 10L : 0L).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, boolean value, String server, boolean temporary) {
|
||||||
|
return newBuilder(node).setValue(value).setServer(server).setExpiry(temporary ? 10L : 0L).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, boolean value, String server, String world, boolean temporary) {
|
||||||
|
return newBuilder(node).setValue(value).setServer(server).setWorld(world).setExpiry(temporary ? 10L : 0L).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, String server, boolean temporary) {
|
||||||
|
return newBuilder(node).setServer(server).setExpiry(temporary ? 10L : 0L).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, String server, String world, boolean temporary) {
|
||||||
|
return newBuilder(node).setServer(server).setWorld(world).setExpiry(temporary ? 10L : 0L).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, boolean value, long expireAt) {
|
||||||
|
return newBuilder(node).setValue(value).setExpiry(expireAt).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, boolean value, String server, long expireAt) {
|
||||||
|
return newBuilder(node).setValue(value).setServer(server).setExpiry(expireAt).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node make(String node, boolean value, String server, String world, long expireAt) {
|
||||||
|
return newBuilder(node).setValue(value).setServer(server).setWorld(world).setExpiry(expireAt).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,15 +136,18 @@ public class ImmutableNode implements Node {
|
|||||||
private final String permission;
|
private final String permission;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private Boolean value;
|
private final Boolean value;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private boolean override;
|
private boolean override;
|
||||||
|
|
||||||
private String server = null;
|
// nullable
|
||||||
private String world = null;
|
private final String server;
|
||||||
|
// nullable
|
||||||
|
private final String world;
|
||||||
|
|
||||||
private long expireAt = 0L;
|
// 0L for no expiry
|
||||||
|
private final long expireAt;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final ImmutableContextSet contexts;
|
private final ImmutableContextSet contexts;
|
||||||
@ -153,6 +156,11 @@ public class ImmutableNode implements Node {
|
|||||||
private final ImmutableContextSet fullContexts;
|
private final ImmutableContextSet fullContexts;
|
||||||
|
|
||||||
// Cached state
|
// Cached state
|
||||||
|
|
||||||
|
// these save on lots of instance creation when comparing nodes
|
||||||
|
private final Optional<String> optServer;
|
||||||
|
private final Optional<String> optWorld;
|
||||||
|
|
||||||
private final boolean isGroup;
|
private final boolean isGroup;
|
||||||
private String groupName;
|
private String groupName;
|
||||||
|
|
||||||
@ -248,6 +256,8 @@ public class ImmutableNode implements Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.fullContexts = fullContexts.makeImmutable();
|
this.fullContexts = fullContexts.makeImmutable();
|
||||||
|
this.optServer = Optional.ofNullable(this.server);
|
||||||
|
this.optWorld = Optional.ofNullable(this.world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -262,12 +272,12 @@ public class ImmutableNode implements Node {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<String> getServer() {
|
public Optional<String> getServer() {
|
||||||
return Optional.ofNullable(server);
|
return optServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<String> getWorld() {
|
public Optional<String> getWorld() {
|
||||||
return Optional.ofNullable(world);
|
return optWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -532,11 +542,7 @@ public class ImmutableNode implements Node {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!other.getContexts().equals(this.getContexts())) {
|
return other.getContexts().equals(this.getContexts());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -569,11 +575,7 @@ public class ImmutableNode implements Node {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!other.getContexts().equals(this.getContexts())) {
|
return other.getContexts().equals(this.getContexts());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -602,11 +604,7 @@ public class ImmutableNode implements Node {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!other.getContexts().equals(this.getContexts())) {
|
return other.getContexts().equals(this.getContexts());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,7 +49,6 @@ import me.lucko.luckperms.common.caching.holder.GetAllNodesRequest;
|
|||||||
import me.lucko.luckperms.common.commands.utils.Util;
|
import me.lucko.luckperms.common.commands.utils.Util;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.core.InheritanceInfo;
|
import me.lucko.luckperms.common.core.InheritanceInfo;
|
||||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
|
||||||
import me.lucko.luckperms.common.core.NodeFactory;
|
import me.lucko.luckperms.common.core.NodeFactory;
|
||||||
import me.lucko.luckperms.common.core.PriorityComparator;
|
import me.lucko.luckperms.common.core.PriorityComparator;
|
||||||
import me.lucko.luckperms.common.core.TemporaryModifier;
|
import me.lucko.luckperms.common.core.TemporaryModifier;
|
||||||
@ -227,14 +226,14 @@ public abstract class PermissionHolder {
|
|||||||
Set<Node> enduring = getNodes();
|
Set<Node> enduring = getNodes();
|
||||||
if (!enduring.isEmpty()) {
|
if (!enduring.isEmpty()) {
|
||||||
combined.addAll(enduring.stream()
|
combined.addAll(enduring.stream()
|
||||||
.map(n -> makeLocal(n, getObjectName()))
|
.map(n -> ImmutableLocalizedNode.of(n, getObjectName()))
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Set<Node> tran = getTransientNodes();
|
Set<Node> tran = getTransientNodes();
|
||||||
if (!tran.isEmpty()) {
|
if (!tran.isEmpty()) {
|
||||||
combined.addAll(tran.stream()
|
combined.addAll(tran.stream()
|
||||||
.map(n -> makeLocal(n, getObjectName()))
|
.map(n -> ImmutableLocalizedNode.of(n, getObjectName()))
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -386,7 +385,7 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
public void setNodes(Map<String, Boolean> nodes) {
|
public void setNodes(Map<String, Boolean> nodes) {
|
||||||
Set<Node> set = nodes.entrySet().stream()
|
Set<Node> set = nodes.entrySet().stream()
|
||||||
.map(e -> makeNode(e.getKey(), e.getValue()))
|
.map(e -> NodeFactory.fromSerialisedNode(e.getKey(), e.getValue()))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
setNodes(set);
|
setNodes(set);
|
||||||
@ -606,39 +605,39 @@ public abstract class PermissionHolder {
|
|||||||
* Check if the holder has a permission node
|
* Check if the holder has a permission node
|
||||||
*
|
*
|
||||||
* @param node the node to check
|
* @param node the node to check
|
||||||
* @param t whether to check transient nodes
|
* @param checkTransient whether to check transient nodes
|
||||||
* @return a tristate
|
* @return a tristate
|
||||||
*/
|
*/
|
||||||
public Tristate hasPermission(Node node, boolean t) {
|
public Tristate hasPermission(Node node, boolean checkTransient) {
|
||||||
return getAlmostEquals(node, t).map(Node::getTristate).orElse(Tristate.UNDEFINED);
|
return getAlmostEquals(node, checkTransient).map(Node::getTristate).orElse(Tristate.UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tristate hasPermission(Node node) {
|
public Tristate hasPermission(Node node) {
|
||||||
return hasPermission(node, false);
|
return hasPermission(node, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String node, boolean b) {
|
public boolean hasPermission(String node, boolean value) {
|
||||||
return hasPermission(buildNode(node).setValue(b).build()).asBoolean() == b;
|
return hasPermission(NodeFactory.make(node, value)).asBoolean() == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String node, boolean b, String server) {
|
public boolean hasPermission(String node, boolean value, String server) {
|
||||||
return hasPermission(buildNode(node).setValue(b).setServer(server).build()).asBoolean() == b;
|
return hasPermission(NodeFactory.make(node, value, server)).asBoolean() == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String node, boolean b, String server, String world) {
|
public boolean hasPermission(String node, boolean value, String server, String world) {
|
||||||
return hasPermission(buildNode(node).setValue(b).setServer(server).setWorld(world).build()).asBoolean() == b;
|
return hasPermission(NodeFactory.make(node, value, server, world)).asBoolean() == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String node, boolean b, boolean temporary) {
|
public boolean hasPermission(String node, boolean value, boolean temporary) {
|
||||||
return hasPermission(buildNode(node).setValue(b).setExpiry(temporary ? 10L : 0L).build()).asBoolean() == b;
|
return hasPermission(NodeFactory.make(node, value, temporary)).asBoolean() == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String node, boolean b, String server, boolean temporary) {
|
public boolean hasPermission(String node, boolean value, String server, boolean temporary) {
|
||||||
return hasPermission(buildNode(node).setValue(b).setServer(server).setExpiry(temporary ? 10L : 0L).build()).asBoolean() == b;
|
return hasPermission(NodeFactory.make(node, value, server, temporary)).asBoolean() == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String node, boolean b, String server, String world, boolean temporary) {
|
public boolean hasPermission(String node, boolean value, String server, String world, boolean temporary) {
|
||||||
return hasPermission(buildNode(node).setValue(b).setServer(server).setWorld(world).setExpiry(temporary ? 10L : 0L).build()).asBoolean() == b;
|
return hasPermission(NodeFactory.make(node, value, server, world, temporary)).asBoolean() == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -667,28 +666,28 @@ public abstract class PermissionHolder {
|
|||||||
return inheritsPermissionInfo(node).getResult();
|
return inheritsPermissionInfo(node).getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inheritsPermission(String node, boolean b) {
|
public boolean inheritsPermission(String node, boolean value) {
|
||||||
return inheritsPermission(buildNode(node).setValue(b).build()).asBoolean() == b;
|
return inheritsPermission(NodeFactory.make(node, value)).asBoolean() == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inheritsPermission(String node, boolean b, String server) {
|
public boolean inheritsPermission(String node, boolean value, String server) {
|
||||||
return inheritsPermission(buildNode(node).setValue(b).setServer(server).build()).asBoolean() == b;
|
return inheritsPermission(NodeFactory.make(node, value, server)).asBoolean() == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inheritsPermission(String node, boolean b, String server, String world) {
|
public boolean inheritsPermission(String node, boolean value, String server, String world) {
|
||||||
return inheritsPermission(buildNode(node).setValue(b).setServer(server).setWorld(world).build()).asBoolean() == b;
|
return inheritsPermission(NodeFactory.make(node, value, server, world)).asBoolean() == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inheritsPermission(String node, boolean b, boolean temporary) {
|
public boolean inheritsPermission(String node, boolean value, boolean temporary) {
|
||||||
return inheritsPermission(buildNode(node).setValue(b).setExpiry(temporary ? 10L : 0L).build()).asBoolean() == b;
|
return inheritsPermission(NodeFactory.make(node, value, temporary)).asBoolean() == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inheritsPermission(String node, boolean b, String server, boolean temporary) {
|
public boolean inheritsPermission(String node, boolean value, String server, boolean temporary) {
|
||||||
return inheritsPermission(buildNode(node).setValue(b).setServer(server).setExpiry(temporary ? 10L : 0L).build()).asBoolean() == b;
|
return inheritsPermission(NodeFactory.make(node, value, server, temporary)).asBoolean() == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inheritsPermission(String node, boolean b, String server, String world, boolean temporary) {
|
public boolean inheritsPermission(String node, boolean value, String server, String world, boolean temporary) {
|
||||||
return inheritsPermission(buildNode(node).setValue(b).setServer(server).setWorld(world).setExpiry(temporary ? 10L : 0L).build()).asBoolean() == b;
|
return inheritsPermission(NodeFactory.make(node, value, server, world, temporary)).asBoolean() == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -825,27 +824,27 @@ public abstract class PermissionHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPermission(String node, boolean value) throws ObjectAlreadyHasException {
|
public void setPermission(String node, boolean value) throws ObjectAlreadyHasException {
|
||||||
setPermission(buildNode(node).setValue(value).build());
|
setPermission(NodeFactory.make(node, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPermission(String node, boolean value, String server) throws ObjectAlreadyHasException {
|
public void setPermission(String node, boolean value, String server) throws ObjectAlreadyHasException {
|
||||||
setPermission(buildNode(node).setValue(value).setServer(server).build());
|
setPermission(NodeFactory.make(node, value, server));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPermission(String node, boolean value, String server, String world) throws ObjectAlreadyHasException {
|
public void setPermission(String node, boolean value, String server, String world) throws ObjectAlreadyHasException {
|
||||||
setPermission(buildNode(node).setValue(value).setServer(server).setWorld(world).build());
|
setPermission(NodeFactory.make(node, value, server, world));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPermission(String node, boolean value, long expireAt) throws ObjectAlreadyHasException {
|
public void setPermission(String node, boolean value, long expireAt) throws ObjectAlreadyHasException {
|
||||||
setPermission(buildNode(node).setValue(value).setExpiry(expireAt).build());
|
setPermission(NodeFactory.make(node, value, expireAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPermission(String node, boolean value, String server, long expireAt) throws ObjectAlreadyHasException {
|
public void setPermission(String node, boolean value, String server, long expireAt) throws ObjectAlreadyHasException {
|
||||||
setPermission(buildNode(node).setValue(value).setServer(server).setExpiry(expireAt).build());
|
setPermission(NodeFactory.make(node, value, server, expireAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPermission(String node, boolean value, String server, String world, long expireAt) throws ObjectAlreadyHasException {
|
public void setPermission(String node, boolean value, String server, String world, long expireAt) throws ObjectAlreadyHasException {
|
||||||
setPermission(buildNode(node).setValue(value).setServer(server).setWorld(world).setExpiry(expireAt).build());
|
setPermission(NodeFactory.make(node, value, server, world, expireAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -905,27 +904,27 @@ public abstract class PermissionHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void unsetPermission(String node, boolean temporary) throws ObjectLacksException {
|
public void unsetPermission(String node, boolean temporary) throws ObjectLacksException {
|
||||||
unsetPermission(buildNode(node).setExpiry(temporary ? 10L : 0L).build());
|
unsetPermission(NodeFactory.make(node, temporary));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unsetPermission(String node) throws ObjectLacksException {
|
public void unsetPermission(String node) throws ObjectLacksException {
|
||||||
unsetPermission(buildNode(node).build());
|
unsetPermission(NodeFactory.make(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unsetPermission(String node, String server) throws ObjectLacksException {
|
public void unsetPermission(String node, String server) throws ObjectLacksException {
|
||||||
unsetPermission(buildNode(node).setServer(server).build());
|
unsetPermission(NodeFactory.make(node, server));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unsetPermission(String node, String server, String world) throws ObjectLacksException {
|
public void unsetPermission(String node, String server, String world) throws ObjectLacksException {
|
||||||
unsetPermission(buildNode(node).setServer(server).setWorld(world).build());
|
unsetPermission(NodeFactory.make(node, server, world));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unsetPermission(String node, String server, boolean temporary) throws ObjectLacksException {
|
public void unsetPermission(String node, String server, boolean temporary) throws ObjectLacksException {
|
||||||
unsetPermission(buildNode(node).setServer(server).setExpiry(temporary ? 10L : 0L).build());
|
unsetPermission(NodeFactory.make(node, server, temporary));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unsetPermission(String node, String server, String world, boolean temporary) throws ObjectLacksException {
|
public void unsetPermission(String node, String server, String world, boolean temporary) throws ObjectLacksException {
|
||||||
unsetPermission(buildNode(node).setServer(server).setWorld(world).setExpiry(temporary ? 10L : 0L).build());
|
unsetPermission(NodeFactory.make(node, server, world, temporary));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inheritsGroup(Group group) {
|
public boolean inheritsGroup(Group group) {
|
||||||
@ -1315,16 +1314,4 @@ public abstract class PermissionHolder {
|
|||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Node.Builder buildNode(String permission) {
|
|
||||||
return new NodeBuilder(permission);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ImmutableLocalizedNode makeLocal(Node node, String location) {
|
|
||||||
return ImmutableLocalizedNode.of(node, location);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Node makeNode(String s, Boolean b) {
|
|
||||||
return NodeFactory.fromSerialisedNode(s, b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,6 @@ import lombok.ToString;
|
|||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.common.core.NodeFactory;
|
import me.lucko.luckperms.common.core.NodeFactory;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
|
||||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -91,17 +89,11 @@ public class Rule {
|
|||||||
|
|
||||||
// The holder meets all of the requirements of this rule.
|
// The holder meets all of the requirements of this rule.
|
||||||
for (String s : toTake) {
|
for (String s : toTake) {
|
||||||
try {
|
user.unsetPermissionUnchecked(NodeFactory.fromSerialisedNode(s, true));
|
||||||
user.unsetPermission(NodeFactory.fromSerialisedNode(s, true));
|
|
||||||
} catch (ObjectLacksException ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String s : toGive) {
|
for (String s : toGive) {
|
||||||
try {
|
user.setPermissionUnchecked(NodeFactory.fromSerialisedNode(s, true));
|
||||||
user.setPermission(NodeFactory.fromSerialisedNode(s, true));
|
|
||||||
} catch (ObjectAlreadyHasException ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setPrimaryGroup != null) {
|
if (setPrimaryGroup != null) {
|
||||||
|
@ -66,6 +66,7 @@ public class LuckPermsEventHandler<T extends LuckPermsEvent> implements EventHan
|
|||||||
return callCount.get();
|
return callCount.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked") // we know that this method will never be called if the class doesn't match eventClass
|
||||||
void handle(LuckPermsEvent event) {
|
void handle(LuckPermsEvent event) {
|
||||||
try {
|
try {
|
||||||
T t = (T) event;
|
T t = (T) event;
|
||||||
|
@ -92,11 +92,8 @@ public class GenericUserManager extends AbstractManager<UserIdentifier, User> im
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.getPrimaryGroup().equalsIgnoreCase("default")) {
|
// Not in the default primary group
|
||||||
return true; // Not in the default primary group
|
return !user.getPrimaryGroup().equalsIgnoreCase("default");
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final LuckPermsPlugin plugin;
|
private final LuckPermsPlugin plugin;
|
||||||
|
@ -78,7 +78,7 @@ public abstract class BufferedRequest<T> {
|
|||||||
private final long delayMillis;
|
private final long delayMillis;
|
||||||
private final Supplier<R> supplier;
|
private final Supplier<R> supplier;
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
private final CompletableFuture<R> future = new CompletableFuture<R>();
|
private final CompletableFuture<R> future = new CompletableFuture<>();
|
||||||
@Getter
|
@Getter
|
||||||
private boolean usable = true;
|
private boolean usable = true;
|
||||||
private long executionTime;
|
private long executionTime;
|
||||||
|
@ -38,10 +38,12 @@ public class Predicates {
|
|||||||
private static final Predicate FALSE = o -> false;
|
private static final Predicate FALSE = o -> false;
|
||||||
private static final Predicate TRUE = o -> true;
|
private static final Predicate TRUE = o -> true;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Predicate<T> alwaysFalse() {
|
public static <T> Predicate<T> alwaysFalse() {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Predicate<T> alwaysTrue() {
|
public static <T> Predicate<T> alwaysTrue() {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -65,11 +65,11 @@ public class BungeeMessagingService extends AbstractMessagingService implements
|
|||||||
protected void sendMessage(String channel, String message) {
|
protected void sendMessage(String channel, String message) {
|
||||||
plugin.getSpongeScheduler().createTaskBuilder().interval(10, TimeUnit.SECONDS).execute(task -> {
|
plugin.getSpongeScheduler().createTaskBuilder().interval(10, TimeUnit.SECONDS).execute(task -> {
|
||||||
Collection<Player> players = plugin.getGame().getServer().getOnlinePlayers();
|
Collection<Player> players = plugin.getGame().getServer().getOnlinePlayers();
|
||||||
if (players.isEmpty()) {
|
Player p = Iterables.getFirst(players, null);
|
||||||
|
if (p == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player p = Iterables.getFirst(players, null);
|
|
||||||
this.channel.sendTo(p, buf -> buf.writeUTF(message));
|
this.channel.sendTo(p, buf -> buf.writeUTF(message));
|
||||||
|
|
||||||
task.cancel();
|
task.cancel();
|
||||||
|
Loading…
Reference in New Issue
Block a user