misc cleanup

This commit is contained in:
Luck 2017-02-26 12:43:35 +00:00
parent 35d1057673
commit df99ef4481
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
26 changed files with 170 additions and 135 deletions

View File

@ -194,14 +194,13 @@ public class Contexts {
final Contexts other = (Contexts) o;
final Object this$context = this.getContexts();
final Object other$context = other.getContexts();
if (this$context == null ? other$context != null : !this$context.equals(other$context)) return false;
if (this.isOp() != other.isOp()) return false;
if (this.isIncludeGlobal() != other.isIncludeGlobal()) return false;
if (this.isIncludeGlobalWorld() != other.isIncludeGlobalWorld()) return false;
if (this.isApplyGroups() != other.isApplyGroups()) return false;
if (this.isApplyGlobalGroups() != other.isApplyGlobalGroups()) return false;
if (this.isApplyGlobalWorldGroups() != other.isApplyGlobalWorldGroups()) return false;
return true;
return (this$context == null ? other$context == null : this$context.equals(other$context)) &&
this.isOp() == other.isOp() &&
this.isIncludeGlobal() == other.isIncludeGlobal() &&
this.isIncludeGlobalWorld() == other.isIncludeGlobalWorld() &&
this.isApplyGroups() == other.isApplyGroups() &&
this.isApplyGlobalGroups() == other.isApplyGlobalGroups() &&
this.isApplyGlobalWorldGroups() == other.isApplyGlobalWorldGroups();
}
/**

View File

@ -171,13 +171,13 @@ public class LogEntry implements Comparable<LogEntry> {
if (o == this) return true;
if (!(o instanceof LogEntry)) return false;
final LogEntry other = (LogEntry) o;
if (this.getTimestamp() != other.getTimestamp()) return false;
if (this.getActor() == null ? other.getActor() != null : !this.getActor().equals(other.getActor())) return false;
if (this.getActorName() == null ? other.getActorName() != null : !this.getActorName().equals(other.getActorName())) return false;
if (this.getType() != other.getType()) return false;
if (this.getActed() == null ? other.getActed() != null : !this.getActed().equals(other.getActed())) return false;
if (this.getActedName() == null ? other.getActedName() != null : !this.getActedName().equals(other.getActedName())) return false;
return this.getAction() == null ? other.getAction() == null : this.getAction().equals(other.getAction());
return this.getTimestamp() == other.getTimestamp() &&
(this.getActor() == null ? other.getActor() == null : this.getActor().equals(other.getActor())) &&
(this.getActorName() == null ? other.getActorName() == null : this.getActorName().equals(other.getActorName())) &&
this.getType() == other.getType() &&
(this.getActed() == null ? other.getActed() == null : this.getActed().equals(other.getActed())) &&
(this.getActedName() == null ? other.getActedName() == null : this.getActedName().equals(other.getActedName())) &&
(this.getAction() == null ? other.getAction() == null : this.getAction().equals(other.getAction()));
}
@Override

View File

@ -149,8 +149,7 @@ public class MetaUtils {
try {
holder.setPermission(metaNode.build());
} catch (ObjectAlreadyHasException ignored) {
}
} catch (ObjectAlreadyHasException ignored) {}
}
/**
@ -233,8 +232,7 @@ public class MetaUtils {
try {
holder.setPermission(node.build());
} catch (ObjectAlreadyHasException ignored) {
}
} catch (ObjectAlreadyHasException ignored) {}
}
/**

View File

@ -40,6 +40,6 @@ public enum CreationCause {
/**
* The creation was caused by a LuckPerms internal
*/
INTERNAL;
INTERNAL
}

View File

@ -40,6 +40,6 @@ public enum DeletionCause {
/**
* The deletion was caused by a LuckPerms internal
*/
INTERNAL;
INTERNAL
}

View File

@ -35,6 +35,6 @@ public enum TrackAction {
/**
* The user was demoted down a track
*/
DEMOTION;
DEMOTION
}

View File

@ -146,9 +146,7 @@ public class LuckPermsPlaceholderExpansion extends PlaceholderExpansion {
String trackName = identifier.substring("on_track_".length());
Optional<Track> track = api.getTrackSafe(trackName);
if (!track.isPresent()) return "";
return formatBoolean(track.get().containsGroup(user.getPrimaryGroup()));
return track.map(t -> formatBoolean(t.containsGroup(user.getPrimaryGroup()))).orElse("");
}
if (identifier.startsWith("expiry_time_") && identifier.length() > "expiry_time_".length()) {

View File

@ -288,9 +288,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
}
// replace the temporary executor when the Bukkit one starts
getServer().getScheduler().runTaskAsynchronously(this, () -> {
scheduler.setUseBukkitAsync(true);
});
getServer().getScheduler().runTaskAsynchronously(this, () -> scheduler.setUseBukkitAsync(true));
// Load any online users (in the case of a reload)
for (Player player : getServer().getOnlinePlayers()) {

View File

@ -64,12 +64,11 @@ public class BungeeMessagingService extends AbstractMessagingService implements
@Override
public void run() {
Collection<? extends Player> players = plugin.getServer().getOnlinePlayers();
if (players.isEmpty()) {
Player p = Iterables.getFirst(players, null);
if (p == null) {
return;
}
Player p = Iterables.getFirst(players, null);
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(message);

View File

@ -66,6 +66,7 @@ import java.util.function.Consumer;
import static me.lucko.luckperms.common.constants.Permission.MIGRATION;
@SuppressWarnings("unchecked")
public class MigrationPowerfulPerms extends SubCommand<Object> {
private static Method getPlayerPermissionsMethod = null;
private static Method getPlayerGroupsMethod = null;

View File

@ -38,6 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* Injects a {@link LPPermissible} into a {@link Player}
*/
@SuppressWarnings("unchecked")
@UtilityClass
public class Injector {
private static final Map<UUID, LPPermissible> INJECTED_PERMISSIBLES = new ConcurrentHashMap<>();

View File

@ -111,8 +111,8 @@ public class CommandManager {
/**
* 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
* @param sender who sent the command
* Unlike {@link #execute(Sender, String, List)}, this method is called in a new thread
* @param sender who sent the command
* @param label the command label used
* @param args the arguments provided
*/

View File

@ -175,6 +175,7 @@ public abstract class MainCommand<T> extends BaseCommand<Void, T> {
return getSubCommands().stream().filter(sc -> sc.isAuthorized(sender)).count() != 0;
}
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
@Override
public Optional<List<Command<T, ?>>> getChildren() {

View File

@ -79,8 +79,7 @@ public class ParentSet extends SharedSubCommand {
try {
holder.setInheritGroup(group);
} catch (ObjectAlreadyHasException ignored) {
}
} catch (ObjectAlreadyHasException ignored) {}
if (holder instanceof User) {
((User) holder).setPrimaryGroup(group.getName());
@ -107,8 +106,7 @@ public class ParentSet extends SharedSubCommand {
try {
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);
break;

View File

@ -97,7 +97,7 @@ public class LogRecent extends SubCommand<Log> {
// User and possibly page
final String s = args.get(0);
UUID u = null;
UUID u;
u = Util.parseUuid(s);
if (u == null) {

View File

@ -101,7 +101,7 @@ public class MigrationMainCommand extends MainCommand<Object> {
super("Migration", "Migration commands", "/%s migration", 1, null);
}
@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "DeprecatedIsStillUsed"})
@Deprecated
@Override
public synchronized Optional<List<Command<Object, ?>>> getChildren() {

View File

@ -27,10 +27,12 @@ import lombok.experimental.UtilityClass;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
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.ListenableFuture;
import com.google.common.util.concurrent.UncheckedExecutionException;
import java.util.Map;
import java.util.concurrent.ExecutionException;
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 NON_ALPHA_NUMERIC = 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 SHORTHAND_NODE = Pattern.compile("\\.\\([^.]+\\)");
public static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('§') + "[0-9A-FK-OR]");
public static final Pattern NODE_CONTEXTS = Pattern.compile("\\(.+\\).*");
@ -67,7 +76,7 @@ public class Patterns {
}
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) {

View File

@ -242,4 +242,60 @@ public class NodeFactory {
public static boolean isSuffixNode(String 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();
}
}

View File

@ -136,15 +136,18 @@ public class ImmutableNode implements Node {
private final String permission;
@Getter
private Boolean value;
private final Boolean value;
@Getter
private boolean override;
private String server = null;
private String world = null;
// nullable
private final String server;
// nullable
private final String world;
private long expireAt = 0L;
// 0L for no expiry
private final long expireAt;
@Getter
private final ImmutableContextSet contexts;
@ -153,6 +156,11 @@ public class ImmutableNode implements Node {
private final ImmutableContextSet fullContexts;
// 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 String groupName;
@ -248,6 +256,8 @@ public class ImmutableNode implements Node {
}
this.fullContexts = fullContexts.makeImmutable();
this.optServer = Optional.ofNullable(this.server);
this.optWorld = Optional.ofNullable(this.world);
}
@Override
@ -262,12 +272,12 @@ public class ImmutableNode implements Node {
@Override
public Optional<String> getServer() {
return Optional.ofNullable(server);
return optServer;
}
@Override
public Optional<String> getWorld() {
return Optional.ofNullable(world);
return optWorld;
}
@Override
@ -532,11 +542,7 @@ public class ImmutableNode implements Node {
return false;
}
if (!other.getContexts().equals(this.getContexts())) {
return false;
}
return true;
return other.getContexts().equals(this.getContexts());
}
@Override
@ -569,11 +575,7 @@ public class ImmutableNode implements Node {
return false;
}
if (!other.getContexts().equals(this.getContexts())) {
return false;
}
return true;
return other.getContexts().equals(this.getContexts());
}
@Override
@ -602,11 +604,7 @@ public class ImmutableNode implements Node {
return false;
}
if (!other.getContexts().equals(this.getContexts())) {
return false;
}
return true;
return other.getContexts().equals(this.getContexts());
}
@Override

View File

@ -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.config.ConfigKeys;
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.PriorityComparator;
import me.lucko.luckperms.common.core.TemporaryModifier;
@ -227,14 +226,14 @@ public abstract class PermissionHolder {
Set<Node> enduring = getNodes();
if (!enduring.isEmpty()) {
combined.addAll(enduring.stream()
.map(n -> makeLocal(n, getObjectName()))
.map(n -> ImmutableLocalizedNode.of(n, getObjectName()))
.collect(Collectors.toList())
);
}
Set<Node> tran = getTransientNodes();
if (!tran.isEmpty()) {
combined.addAll(tran.stream()
.map(n -> makeLocal(n, getObjectName()))
.map(n -> ImmutableLocalizedNode.of(n, getObjectName()))
.collect(Collectors.toList())
);
}
@ -386,7 +385,7 @@ public abstract class PermissionHolder {
public void setNodes(Map<String, Boolean> nodes) {
Set<Node> set = nodes.entrySet().stream()
.map(e -> makeNode(e.getKey(), e.getValue()))
.map(e -> NodeFactory.fromSerialisedNode(e.getKey(), e.getValue()))
.collect(Collectors.toSet());
setNodes(set);
@ -606,39 +605,39 @@ public abstract class PermissionHolder {
* Check if the holder has a permission node
*
* @param node the node to check
* @param t whether to check transient nodes
* @param checkTransient whether to check transient nodes
* @return a tristate
*/
public Tristate hasPermission(Node node, boolean t) {
return getAlmostEquals(node, t).map(Node::getTristate).orElse(Tristate.UNDEFINED);
public Tristate hasPermission(Node node, boolean checkTransient) {
return getAlmostEquals(node, checkTransient).map(Node::getTristate).orElse(Tristate.UNDEFINED);
}
public Tristate hasPermission(Node node) {
return hasPermission(node, false);
}
public boolean hasPermission(String node, boolean b) {
return hasPermission(buildNode(node).setValue(b).build()).asBoolean() == b;
public boolean hasPermission(String node, boolean value) {
return hasPermission(NodeFactory.make(node, value)).asBoolean() == value;
}
public boolean hasPermission(String node, boolean b, String server) {
return hasPermission(buildNode(node).setValue(b).setServer(server).build()).asBoolean() == b;
public boolean hasPermission(String node, boolean value, String server) {
return hasPermission(NodeFactory.make(node, value, server)).asBoolean() == value;
}
public boolean hasPermission(String node, boolean b, String server, String world) {
return hasPermission(buildNode(node).setValue(b).setServer(server).setWorld(world).build()).asBoolean() == b;
public boolean hasPermission(String node, boolean value, String server, String world) {
return hasPermission(NodeFactory.make(node, value, server, world)).asBoolean() == value;
}
public boolean hasPermission(String node, boolean b, boolean temporary) {
return hasPermission(buildNode(node).setValue(b).setExpiry(temporary ? 10L : 0L).build()).asBoolean() == b;
public boolean hasPermission(String node, boolean value, boolean temporary) {
return hasPermission(NodeFactory.make(node, value, temporary)).asBoolean() == value;
}
public boolean hasPermission(String node, boolean b, String server, boolean temporary) {
return hasPermission(buildNode(node).setValue(b).setServer(server).setExpiry(temporary ? 10L : 0L).build()).asBoolean() == b;
public boolean hasPermission(String node, boolean value, String server, boolean temporary) {
return hasPermission(NodeFactory.make(node, value, server, temporary)).asBoolean() == value;
}
public boolean hasPermission(String node, boolean b, String server, String world, boolean temporary) {
return hasPermission(buildNode(node).setValue(b).setServer(server).setWorld(world).setExpiry(temporary ? 10L : 0L).build()).asBoolean() == b;
public boolean hasPermission(String node, boolean value, String server, String world, boolean temporary) {
return hasPermission(NodeFactory.make(node, value, server, world, temporary)).asBoolean() == value;
}
/**
@ -667,28 +666,28 @@ public abstract class PermissionHolder {
return inheritsPermissionInfo(node).getResult();
}
public boolean inheritsPermission(String node, boolean b) {
return inheritsPermission(buildNode(node).setValue(b).build()).asBoolean() == b;
public boolean inheritsPermission(String node, boolean value) {
return inheritsPermission(NodeFactory.make(node, value)).asBoolean() == value;
}
public boolean inheritsPermission(String node, boolean b, String server) {
return inheritsPermission(buildNode(node).setValue(b).setServer(server).build()).asBoolean() == b;
public boolean inheritsPermission(String node, boolean value, String server) {
return inheritsPermission(NodeFactory.make(node, value, server)).asBoolean() == value;
}
public boolean inheritsPermission(String node, boolean b, String server, String world) {
return inheritsPermission(buildNode(node).setValue(b).setServer(server).setWorld(world).build()).asBoolean() == b;
public boolean inheritsPermission(String node, boolean value, String server, String world) {
return inheritsPermission(NodeFactory.make(node, value, server, world)).asBoolean() == value;
}
public boolean inheritsPermission(String node, boolean b, boolean temporary) {
return inheritsPermission(buildNode(node).setValue(b).setExpiry(temporary ? 10L : 0L).build()).asBoolean() == b;
public boolean inheritsPermission(String node, boolean value, boolean temporary) {
return inheritsPermission(NodeFactory.make(node, value, temporary)).asBoolean() == value;
}
public boolean inheritsPermission(String node, boolean b, String server, boolean temporary) {
return inheritsPermission(buildNode(node).setValue(b).setServer(server).setExpiry(temporary ? 10L : 0L).build()).asBoolean() == b;
public boolean inheritsPermission(String node, boolean value, String server, boolean temporary) {
return inheritsPermission(NodeFactory.make(node, value, server, temporary)).asBoolean() == value;
}
public boolean inheritsPermission(String node, boolean b, String server, String world, boolean temporary) {
return inheritsPermission(buildNode(node).setValue(b).setServer(server).setWorld(world).setExpiry(temporary ? 10L : 0L).build()).asBoolean() == b;
public boolean inheritsPermission(String node, boolean value, String server, String world, boolean temporary) {
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 {
setPermission(buildNode(node).setValue(value).build());
setPermission(NodeFactory.make(node, value));
}
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 {
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 {
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 {
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 {
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 {
unsetPermission(buildNode(node).setExpiry(temporary ? 10L : 0L).build());
unsetPermission(NodeFactory.make(node, temporary));
}
public void unsetPermission(String node) throws ObjectLacksException {
unsetPermission(buildNode(node).build());
unsetPermission(NodeFactory.make(node));
}
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 {
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 {
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 {
unsetPermission(buildNode(node).setServer(server).setWorld(world).setExpiry(temporary ? 10L : 0L).build());
unsetPermission(NodeFactory.make(node, server, world, temporary));
}
public boolean inheritsGroup(Group group) {
@ -1315,16 +1314,4 @@ public abstract class PermissionHolder {
}
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);
}
}

View File

@ -29,8 +29,6 @@ import lombok.ToString;
import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException;
import java.util.List;
@ -91,17 +89,11 @@ public class Rule {
// The holder meets all of the requirements of this rule.
for (String s : toTake) {
try {
user.unsetPermission(NodeFactory.fromSerialisedNode(s, true));
} catch (ObjectLacksException ignored) {
}
user.unsetPermissionUnchecked(NodeFactory.fromSerialisedNode(s, true));
}
for (String s : toGive) {
try {
user.setPermission(NodeFactory.fromSerialisedNode(s, true));
} catch (ObjectAlreadyHasException ignored) {
}
user.setPermissionUnchecked(NodeFactory.fromSerialisedNode(s, true));
}
if (setPrimaryGroup != null) {

View File

@ -66,6 +66,7 @@ public class LuckPermsEventHandler<T extends LuckPermsEvent> implements EventHan
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) {
try {
T t = (T) event;

View File

@ -92,11 +92,8 @@ public class GenericUserManager extends AbstractManager<UserIdentifier, User> im
}
}
if (!user.getPrimaryGroup().equalsIgnoreCase("default")) {
return true; // Not in the default primary group
}
return false;
// Not in the default primary group
return !user.getPrimaryGroup().equalsIgnoreCase("default");
}
private final LuckPermsPlugin plugin;

View File

@ -78,7 +78,7 @@ public abstract class BufferedRequest<T> {
private final long delayMillis;
private final Supplier<R> supplier;
private final ReentrantLock lock = new ReentrantLock();
private final CompletableFuture<R> future = new CompletableFuture<R>();
private final CompletableFuture<R> future = new CompletableFuture<>();
@Getter
private boolean usable = true;
private long executionTime;

View File

@ -38,10 +38,12 @@ public class Predicates {
private static final Predicate FALSE = o -> false;
private static final Predicate TRUE = o -> true;
@SuppressWarnings("unchecked")
public static <T> Predicate<T> alwaysFalse() {
return FALSE;
}
@SuppressWarnings("unchecked")
public static <T> Predicate<T> alwaysTrue() {
return TRUE;
}

View File

@ -65,11 +65,11 @@ public class BungeeMessagingService extends AbstractMessagingService implements
protected void sendMessage(String channel, String message) {
plugin.getSpongeScheduler().createTaskBuilder().interval(10, TimeUnit.SECONDS).execute(task -> {
Collection<Player> players = plugin.getGame().getServer().getOnlinePlayers();
if (players.isEmpty()) {
Player p = Iterables.getFirst(players, null);
if (p == null) {
return;
}
Player p = Iterables.getFirst(players, null);
this.channel.sendTo(p, buf -> buf.writeUTF(message));
task.cancel();