mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-23 19:16:37 +01:00
Misc refactoring and tidying up
This commit is contained in:
parent
ab009ed110
commit
cb9e0899fc
@ -48,47 +48,47 @@ public interface NodeType<T extends Node> {
|
||||
/**
|
||||
* Node type for {@link PermissionNode}.
|
||||
*/
|
||||
NodeType<PermissionNode> PERMISSION = new SimpleNodeType<>("PERMISSION", n -> n instanceof PermissionNode, n -> ((PermissionNode) n));
|
||||
NodeType<PermissionNode> PERMISSION = new SimpleNodeType<>("PERMISSION", n -> n instanceof PermissionNode, n -> (PermissionNode) n);
|
||||
|
||||
/**
|
||||
* Node type for {@link RegexPermissionNode}.
|
||||
*/
|
||||
NodeType<RegexPermissionNode> REGEX_PERMISSION = new SimpleNodeType<>("REGEX_PERMISSION", n -> n instanceof RegexPermissionNode, n -> ((RegexPermissionNode) n));
|
||||
NodeType<RegexPermissionNode> REGEX_PERMISSION = new SimpleNodeType<>("REGEX_PERMISSION", n -> n instanceof RegexPermissionNode, n -> (RegexPermissionNode) n);
|
||||
|
||||
/**
|
||||
* Node type for {@link InheritanceNode}.
|
||||
*/
|
||||
NodeType<InheritanceNode> INHERITANCE = new SimpleNodeType<>("INHERITANCE", n -> n instanceof InheritanceNode, n -> ((InheritanceNode) n));
|
||||
NodeType<InheritanceNode> INHERITANCE = new SimpleNodeType<>("INHERITANCE", n -> n instanceof InheritanceNode, n -> (InheritanceNode) n);
|
||||
|
||||
/**
|
||||
* Node type for {@link PrefixNode}.
|
||||
*/
|
||||
NodeType<PrefixNode> PREFIX = new SimpleNodeType<>("PREFIX", n -> n instanceof PrefixNode, n -> ((PrefixNode) n));
|
||||
NodeType<PrefixNode> PREFIX = new SimpleNodeType<>("PREFIX", n -> n instanceof PrefixNode, n -> (PrefixNode) n);
|
||||
|
||||
/**
|
||||
* Node type for {@link SuffixNode}.
|
||||
*/
|
||||
NodeType<SuffixNode> SUFFIX = new SimpleNodeType<>("SUFFIX", n -> n instanceof SuffixNode, n -> ((SuffixNode) n));
|
||||
NodeType<SuffixNode> SUFFIX = new SimpleNodeType<>("SUFFIX", n -> n instanceof SuffixNode, n -> (SuffixNode) n);
|
||||
|
||||
/**
|
||||
* Node type for {@link MetaNode}.
|
||||
*/
|
||||
NodeType<MetaNode> META = new SimpleNodeType<>("META", n -> n instanceof MetaNode, n -> ((MetaNode) n));
|
||||
NodeType<MetaNode> META = new SimpleNodeType<>("META", n -> n instanceof MetaNode, n -> (MetaNode) n);
|
||||
|
||||
/**
|
||||
* Node type for {@link WeightNode}.
|
||||
*/
|
||||
NodeType<WeightNode> WEIGHT = new SimpleNodeType<>("WEIGHT", n -> n instanceof WeightNode, n -> ((WeightNode) n));
|
||||
NodeType<WeightNode> WEIGHT = new SimpleNodeType<>("WEIGHT", n -> n instanceof WeightNode, n -> (WeightNode) n);
|
||||
|
||||
/**
|
||||
* Node type for {@link DisplayNameNode}.
|
||||
*/
|
||||
NodeType<DisplayNameNode> DISPLAY_NAME = new SimpleNodeType<>("DISPLAY_NAME", n -> n instanceof DisplayNameNode, n -> ((DisplayNameNode) n));
|
||||
NodeType<DisplayNameNode> DISPLAY_NAME = new SimpleNodeType<>("DISPLAY_NAME", n -> n instanceof DisplayNameNode, n -> (DisplayNameNode) n);
|
||||
|
||||
/**
|
||||
* Node type for {@link ChatMetaNode}.
|
||||
*/
|
||||
NodeType<ChatMetaNode<?, ?>> CHAT_META = new SimpleNodeType<>("CHAT_META", n -> n instanceof ChatMetaNode<?, ?>, n -> ((ChatMetaNode<?, ?>) n));
|
||||
NodeType<ChatMetaNode<?, ?>> CHAT_META = new SimpleNodeType<>("CHAT_META", n -> n instanceof ChatMetaNode<?, ?>, n -> (ChatMetaNode<?, ?>) n);
|
||||
|
||||
/**
|
||||
* Node type for {@link ChatMetaNode} or {@link MetaNode}.
|
||||
|
@ -140,7 +140,7 @@ public class BukkitCommandExecutor extends CommandManager implements TabExecutor
|
||||
try {
|
||||
matchedPlayers = this.plugin.getBootstrap().getServer().selectEntities(sender, arg).stream()
|
||||
.filter(e -> e instanceof Player)
|
||||
.map(e -> ((Player) e))
|
||||
.map(e -> (Player) e)
|
||||
.collect(Collectors.toList());
|
||||
} catch (IllegalArgumentException e) {
|
||||
this.plugin.getLogger().warn("Error parsing selector '" + arg + "' for " + sender + " executing " + args, e);
|
||||
|
@ -67,7 +67,7 @@ public class DefaultsProcessor implements PermissionProcessor {
|
||||
Permission defPerm = this.plugin.getPermissionMap().get(permission);
|
||||
if (defPerm != null) {
|
||||
PermissionDefault def = defPerm.getDefault();
|
||||
if (def == PermissionDefault.FALSE || (this.isOp && def == PermissionDefault.NOT_OP)) {
|
||||
if (def == PermissionDefault.FALSE || this.isOp && def == PermissionDefault.NOT_OP) {
|
||||
return PERMISSION_MAP_RESULT_FACTORY.result(Tristate.FALSE, "permission map (overriding wildcard): " + prev.cause());
|
||||
}
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
|
||||
return null;
|
||||
}
|
||||
|
||||
String permission = ((String) key);
|
||||
String permission = (String) key;
|
||||
|
||||
// grab the previous result, so we can still satisfy the method signature of Map
|
||||
Boolean previous = LuckPermsPermissionAttachment.this.perms.get(permission);
|
||||
|
@ -127,7 +127,7 @@ public final class PermissibleInjector {
|
||||
|
||||
// only uninject if the permissible was a luckperms one.
|
||||
if (permissible instanceof LuckPermsPermissible) {
|
||||
LuckPermsPermissible lpPermissible = ((LuckPermsPermissible) permissible);
|
||||
LuckPermsPermissible lpPermissible = (LuckPermsPermissible) permissible;
|
||||
|
||||
// clear all permissions
|
||||
lpPermissible.clearPermissions();
|
||||
|
@ -133,7 +133,7 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
||||
|
||||
@Override
|
||||
public boolean remove(Object key, Object value) {
|
||||
return key != null && value != null && super.remove(key, uninject(((Permission) value)));
|
||||
return key != null && value != null && super.remove(key, uninject((Permission) value));
|
||||
}
|
||||
|
||||
// check for null
|
||||
|
@ -95,7 +95,7 @@ public final class LuckPermsSubscriptionMap extends HashMap<String, Map<Permissi
|
||||
return null;
|
||||
}
|
||||
|
||||
String permission = ((String) key);
|
||||
String permission = (String) key;
|
||||
|
||||
LPSubscriptionValueMap result = (LPSubscriptionValueMap) super.get(key);
|
||||
if (result == null) {
|
||||
|
@ -58,7 +58,7 @@ public class BungeePermissionCheckListener implements Listener {
|
||||
Objects.requireNonNull(e.getPermission(), "permission");
|
||||
Objects.requireNonNull(e.getSender(), "sender");
|
||||
|
||||
ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
|
||||
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
||||
|
||||
User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
|
||||
if (user == null) {
|
||||
@ -87,7 +87,7 @@ public class BungeePermissionCheckListener implements Listener {
|
||||
Objects.requireNonNull(e.getPermission(), "permission");
|
||||
Objects.requireNonNull(e.getSender(), "sender");
|
||||
|
||||
ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
|
||||
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
||||
|
||||
User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
|
||||
if (user == null) {
|
||||
|
@ -69,7 +69,7 @@ public class LogDispatcher {
|
||||
this.plugin.getOnlineSenders()
|
||||
.filter(CommandPermission.LOG_NOTIFY::isAuthorized)
|
||||
.filter(s -> {
|
||||
boolean shouldCancel = LogNotify.isIgnoring(this.plugin, s.getUniqueId()) || (sender != null && s.getUniqueId().equals(sender.getUniqueId()));
|
||||
boolean shouldCancel = LogNotify.isIgnoring(this.plugin, s.getUniqueId()) || sender != null && s.getUniqueId().equals(sender.getUniqueId());
|
||||
return !this.plugin.getEventDispatcher().dispatchLogNotify(shouldCancel, entry, origin, s);
|
||||
})
|
||||
.forEach(s -> Message.LOG.send(s, entry));
|
||||
|
@ -241,7 +241,7 @@ public class Importer implements Runnable {
|
||||
}
|
||||
|
||||
private void sendProgress(int processedCount, int total) {
|
||||
int percent = (processedCount * 100) / total;
|
||||
int percent = processedCount * 100 / total;
|
||||
this.notify.forEach(s -> Message.IMPORT_PROGRESS.send(s, percent, processedCount, total));
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public abstract class ExpiringCache<T> implements Supplier<T> {
|
||||
nanos = now + this.durationNanos;
|
||||
// In the very unlikely event that nanos is 0, set it to 1;
|
||||
// no one will notice 1 ns of tardiness.
|
||||
this.expirationNanos = (nanos == 0) ? 1 : nanos;
|
||||
this.expirationNanos = nanos == 0 ? 1 : nanos;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ public abstract class UsageTracked {
|
||||
}
|
||||
|
||||
public boolean usedSince(long duration) {
|
||||
return this.lastUsed > (System.currentTimeMillis() - duration);
|
||||
return this.lastUsed > System.currentTimeMillis() - duration;
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class WildcardProcessor extends AbstractPermissionProcessor implements Pe
|
||||
}
|
||||
|
||||
public static boolean isWildcardPermission(String permission) {
|
||||
return isRootWildcard(permission) || (permission.endsWith(WILDCARD_SUFFIX) && permission.length() > 2);
|
||||
return isRootWildcard(permission) || permission.endsWith(WILDCARD_SUFFIX) && permission.length() > 2;
|
||||
}
|
||||
|
||||
private Map<String, TristateResult> wildcardPermissions = Collections.emptyMap();
|
||||
|
@ -150,7 +150,7 @@ public class CommandManager {
|
||||
applyConvenienceAliases(arguments, true);
|
||||
|
||||
// Handle no arguments
|
||||
if (arguments.isEmpty() || (arguments.size() == 1 && arguments.get(0).trim().isEmpty())) {
|
||||
if (arguments.isEmpty() || arguments.size() == 1 && arguments.get(0).trim().isEmpty()) {
|
||||
sender.sendMessage(Message.prefixed(Component.text()
|
||||
.color(NamedTextColor.DARK_GREEN)
|
||||
.append(Component.text("Running "))
|
||||
|
@ -107,7 +107,7 @@ public final class ArgumentPermissions {
|
||||
}
|
||||
|
||||
if (target instanceof User) {
|
||||
User targetUser = ((User) target);
|
||||
User targetUser = (User) target;
|
||||
|
||||
if (targetUser.getUniqueId().equals(sender.getUniqueId())) {
|
||||
// the sender is trying to edit themselves
|
||||
@ -131,7 +131,7 @@ public final class ArgumentPermissions {
|
||||
}
|
||||
}
|
||||
} else if (target instanceof Group) {
|
||||
Group targetGroup = ((Group) target);
|
||||
Group targetGroup = (Group) target;
|
||||
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".modify." + targetGroup.getName());
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
@ -142,7 +142,7 @@ public final class ArgumentPermissions {
|
||||
return !globalState.asBoolean();
|
||||
}
|
||||
} else if (target instanceof Track) {
|
||||
Track targetTrack = ((Track) target);
|
||||
Track targetTrack = (Track) target;
|
||||
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".modify." + targetTrack.getName());
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
@ -172,7 +172,7 @@ public final class ArgumentPermissions {
|
||||
}
|
||||
|
||||
if (target instanceof User) {
|
||||
User targetUser = ((User) target);
|
||||
User targetUser = (User) target;
|
||||
|
||||
if (targetUser.getUniqueId().equals(sender.getUniqueId())) {
|
||||
// the sender is trying to view themselves
|
||||
@ -196,7 +196,7 @@ public final class ArgumentPermissions {
|
||||
}
|
||||
}
|
||||
} else if (target instanceof Group) {
|
||||
Group targetGroup = ((Group) target);
|
||||
Group targetGroup = (Group) target;
|
||||
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".view." + targetGroup.getName());
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
@ -207,7 +207,7 @@ public final class ArgumentPermissions {
|
||||
return !globalState.asBoolean();
|
||||
}
|
||||
} else if (target instanceof Track) {
|
||||
Track targetTrack = ((Track) target);
|
||||
Track targetTrack = (Track) target;
|
||||
|
||||
Tristate state = sender.getPermissionValue(base.getPermission() + ".view." + targetTrack.getName());
|
||||
if (state != Tristate.UNDEFINED) {
|
||||
|
@ -110,7 +110,7 @@ public enum CommandSpec {
|
||||
|
||||
USER_INFO,
|
||||
USER_SWITCHPRIMARYGROUP(
|
||||
(arg("group", true))
|
||||
arg("group", true)
|
||||
),
|
||||
USER_PROMOTE(
|
||||
arg("track", false),
|
||||
|
@ -82,7 +82,7 @@ public class TabCompleter {
|
||||
String partial;
|
||||
|
||||
// nothing entered yet
|
||||
if (args.isEmpty() || (partial = args.get((lastIndex = args.size() - 1))).trim().isEmpty()) {
|
||||
if (args.isEmpty() || (partial = args.get(lastIndex = args.size() - 1)).trim().isEmpty()) {
|
||||
return getCompletions(lastIndex, "");
|
||||
}
|
||||
|
||||
|
@ -126,10 +126,10 @@ public final class StorageAssistant {
|
||||
|
||||
public static void save(PermissionHolder holder, Sender sender, LuckPermsPlugin plugin) {
|
||||
if (holder.getType() == HolderType.USER) {
|
||||
User user = ((User) holder);
|
||||
User user = (User) holder;
|
||||
save(user, sender, plugin);
|
||||
} else if (holder.getType() == HolderType.GROUP) {
|
||||
Group group = ((Group) holder);
|
||||
Group group = (Group) holder;
|
||||
save(group, sender, plugin);
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -80,7 +80,7 @@ public class MetaInfo extends GenericChildCommand {
|
||||
SuffixNode sn = (SuffixNode) node;
|
||||
suffixes.add(Maps.immutableEntry(sn.getPriority(), sn));
|
||||
} else if (node instanceof MetaNode) {
|
||||
meta.add(((MetaNode) node));
|
||||
meta.add((MetaNode) node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class ParentClearTrack extends GenericChildCommand {
|
||||
target.removeIf(DataType.NORMAL, context.isEmpty() ? null : context, NodeType.INHERITANCE.predicate(n -> track.containsGroup(n.getGroupName())), false);
|
||||
|
||||
if (target.getType() == HolderType.USER) {
|
||||
plugin.getUserManager().giveDefaultIfNeeded(((User) target));
|
||||
plugin.getUserManager().giveDefaultIfNeeded((User) target);
|
||||
}
|
||||
|
||||
int changed = before - target.normalData().size();
|
||||
|
@ -101,7 +101,7 @@ public class ParentRemove extends GenericChildCommand {
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
if (target.getType() == HolderType.USER) {
|
||||
plugin.getUserManager().giveDefaultIfNeeded(((User) target));
|
||||
plugin.getUserManager().giveDefaultIfNeeded((User) target);
|
||||
}
|
||||
|
||||
StorageAssistant.save(target, sender, plugin);
|
||||
|
@ -84,7 +84,7 @@ public class ParentSetTrack extends GenericChildCommand {
|
||||
String groupName;
|
||||
if (index > 0) {
|
||||
List<String> trackGroups = track.getGroups();
|
||||
if ((index - 1) >= trackGroups.size()) {
|
||||
if (index - 1 >= trackGroups.size()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, String.valueOf(index));
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class UserSwitchPrimaryGroup extends GenericChildCommand {
|
||||
// cast to user
|
||||
// although this command is build as a sharedsubcommand,
|
||||
// it is only added to the listings for users.
|
||||
User user = ((User) target);
|
||||
User user = (User) target;
|
||||
|
||||
if (ArgumentPermissions.checkModifyPerms(plugin, sender, permission, user)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
|
@ -225,7 +225,7 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements
|
||||
public @NonNull BuilderImpl addAll(@NonNull ContextSet contextSet) {
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
if (contextSet instanceof AbstractContextSet) {
|
||||
AbstractContextSet other = ((AbstractContextSet) contextSet);
|
||||
AbstractContextSet other = (AbstractContextSet) contextSet;
|
||||
if (!other.isEmpty()) {
|
||||
builder().putAll(other.backing());
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M
|
||||
public void addAll(@NonNull ContextSet contextSet) {
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
if (contextSet instanceof AbstractContextSet) {
|
||||
AbstractContextSet other = ((AbstractContextSet) contextSet);
|
||||
AbstractContextSet other = (AbstractContextSet) contextSet;
|
||||
other.copyTo(this.map);
|
||||
} else {
|
||||
addAll(contextSet.toSet());
|
||||
|
@ -163,7 +163,7 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
||||
//noinspection unchecked
|
||||
return super.subscribers().values().stream()
|
||||
.filter(s -> s instanceof EventSubscription && ((EventSubscription<?>) s).getEventClass().isAssignableFrom(eventClass))
|
||||
.map(s -> ((EventSubscription<T>) s))
|
||||
.map(s -> (EventSubscription<T>) s)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ public enum TraversalAlgorithm {
|
||||
NodeAndSuccessors node = this.stack.getFirst();
|
||||
boolean firstVisit = this.visited.add(node.node);
|
||||
boolean lastVisit = !node.successorIterator.hasNext();
|
||||
boolean produceNode = (firstVisit && this.order == Order.PRE_ORDER) || (lastVisit && this.order == Order.POST_ORDER);
|
||||
boolean produceNode = firstVisit && this.order == Order.PRE_ORDER || lastVisit && this.order == Order.POST_ORDER;
|
||||
if (lastVisit) {
|
||||
this.stack.pop();
|
||||
} else {
|
||||
|
@ -41,7 +41,7 @@ public class InheritanceComparator implements Comparator<PermissionHolder> {
|
||||
|
||||
public static Comparator<? super PermissionHolder> getFor(PermissionHolder origin) {
|
||||
if (origin.getType() == HolderType.USER) {
|
||||
return new InheritanceComparator(((User) origin)).reversed();
|
||||
return new InheritanceComparator((User) origin).reversed();
|
||||
}
|
||||
return NULL_ORIGIN;
|
||||
}
|
||||
|
@ -2797,7 +2797,7 @@ public interface Message {
|
||||
// "&aInstalling language {}..."
|
||||
.key("luckperms.command.translations.installing-specific")
|
||||
.color(GREEN)
|
||||
.args(text((name)))
|
||||
.args(text(name))
|
||||
);
|
||||
|
||||
Args0 TRANSLATIONS_INSTALL_COMPLETE = () -> prefixed(translatable()
|
||||
|
@ -138,7 +138,7 @@ public abstract class AbstractNode<N extends ScopedNode<N, B>, B extends NodeBui
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof Node)) return false;
|
||||
return NodeEquality.KEY_VALUE_EXPIRY_CONTEXTS.equals(this, ((AbstractNode<?, ?>) o));
|
||||
return NodeEquality.KEY_VALUE_EXPIRY_CONTEXTS.equals(this, (AbstractNode<?, ?>) o);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,7 +52,7 @@ public final class NodeCommandFactory {
|
||||
// value
|
||||
sb.append(((InheritanceNode) node).getGroupName());
|
||||
|
||||
} else if (node.getValue() && (node instanceof ChatMetaNode<?, ?>)) {
|
||||
} else if (node.getValue() && node instanceof ChatMetaNode<?, ?>) {
|
||||
ChatMetaNode<?, ?> chatNode = (ChatMetaNode<?, ?>) node;
|
||||
|
||||
// command
|
||||
|
@ -45,7 +45,7 @@ public enum ShorthandParser {
|
||||
@Override
|
||||
public Iterator<String> extract(String input) throws NumberFormatException {
|
||||
int index = input.indexOf(RANGE_SEPARATOR);
|
||||
if (index == -1 || index == 0 || index == (input.length() - 1)) {
|
||||
if (index == -1 || index == 0 || index == input.length() - 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ final class FlagUtils {
|
||||
/* bitwise utility methods */
|
||||
|
||||
static boolean read(byte b, Flag setting) {
|
||||
return ((b >> setting.ordinal()) & 1) == 1;
|
||||
return (b >> setting.ordinal() & 1) == 1;
|
||||
}
|
||||
|
||||
static byte toByte(Set<Flag> settings) {
|
||||
@ -54,7 +54,7 @@ final class FlagUtils {
|
||||
private static byte toByte0(Set<Flag> settings) {
|
||||
byte b = 0;
|
||||
for (Flag setting : settings) {
|
||||
b |= (1 << setting.ordinal());
|
||||
b |= 1 << setting.ordinal();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public final class SqlRowId {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o || (o instanceof SqlRowId && this.rowId == ((SqlRowId) o).rowId);
|
||||
return this == o || o instanceof SqlRowId && this.rowId == ((SqlRowId) o).rowId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,7 +68,7 @@ public class H2ConnectionFactory extends FlatfileConnectionFactory {
|
||||
return (Connection) this.connectionConstructor.newInstance("jdbc:h2:" + file.toString(), new Properties());
|
||||
} catch (ReflectiveOperationException e) {
|
||||
if (e.getCause() instanceof SQLException) {
|
||||
throw ((SQLException) e.getCause());
|
||||
throw (SQLException) e.getCause();
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class SqliteConnectionFactory extends FlatfileConnectionFactory {
|
||||
return (Connection) this.connectionConstructor.newInstance("jdbc:sqlite:" + file.toString(), file.toString(), new Properties());
|
||||
} catch (ReflectiveOperationException e) {
|
||||
if (e.getCause() instanceof SQLException) {
|
||||
throw ((SQLException) e.getCause());
|
||||
throw (SQLException) e.getCause();
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -118,6 +118,6 @@ public class ImmutableTreeNode implements Comparable<ImmutableTreeNode> {
|
||||
|
||||
@Override
|
||||
public int compareTo(@NonNull ImmutableTreeNode o) {
|
||||
return (this.children != null) == o.getChildren().isPresent() ? 0 : (this.children != null ? 1 : -1);
|
||||
return (this.children != null) == o.getChildren().isPresent() ? 0 : this.children != null ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class TreeView {
|
||||
|
||||
// work out the prefix to apply
|
||||
// since the view is relative, we need to prepend this to all permissions
|
||||
String prefix = this.rootPosition.equals(".") ? "" : (this.rootPosition + ".");
|
||||
String prefix = this.rootPosition.equals(".") ? "" : this.rootPosition + ".";
|
||||
JsonObject jsonTree = this.view.toJson(prefix);
|
||||
|
||||
JObject metadata = new JObject()
|
||||
|
@ -56,7 +56,7 @@ public class Paginated<T> {
|
||||
throw new IllegalArgumentException("pageNo cannot be less than 1: " + pageNo);
|
||||
}
|
||||
|
||||
int first = ((pageNo - 1) * pageSize);
|
||||
int first = (pageNo - 1) * pageSize;
|
||||
if (this.content.size() <= first) {
|
||||
throw new IllegalStateException("Content does not contain that many elements. (requested page: " + pageNo +
|
||||
", page size: " + pageSize + ", page first index: " + first + ", content size: " + this.content.size() + ")");
|
||||
|
@ -256,7 +256,7 @@ public class BooleanExpressionCompiler {
|
||||
case '!':
|
||||
return ConstantToken.NOT;
|
||||
default:
|
||||
throw new LexerException("Unknown token: " + ((char) token) + "(" + token + ")");
|
||||
throw new LexerException("Unknown token: " + (char) token + "(" + token + ")");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new LexerException(e);
|
||||
|
@ -32,7 +32,7 @@ import net.minecraft.server.world.ServerWorld;
|
||||
|
||||
// TODO: Use Fabric API alternative when merged.
|
||||
public interface PlayerChangeWorldCallback {
|
||||
Event<PlayerChangeWorldCallback> EVENT = EventFactory.createArrayBacked(PlayerChangeWorldCallback.class, (callbacks) -> (originalWorld, destination, player) -> {
|
||||
Event<PlayerChangeWorldCallback> EVENT = EventFactory.createArrayBacked(PlayerChangeWorldCallback.class, callbacks -> (originalWorld, destination, player) -> {
|
||||
for (PlayerChangeWorldCallback callback : callbacks) {
|
||||
callback.onChangeWorld(originalWorld, destination, player);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public abstract class ServerPlayerEntityMixin implements MixinUser {
|
||||
@Override
|
||||
public QueryOptionsCache<ServerPlayerEntity> getQueryOptionsCache(FabricContextManager contextManager) {
|
||||
if (this.luckperms$queryOptions == null) {
|
||||
this.luckperms$queryOptions = contextManager.newQueryOptionsCache(((ServerPlayerEntity) (Object) this));
|
||||
this.luckperms$queryOptions = contextManager.newQueryOptionsCache((ServerPlayerEntity) (Object) this);
|
||||
}
|
||||
return this.luckperms$queryOptions;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class DefaultsProcessor implements PermissionProcessor {
|
||||
if (canOverrideWildcard(prev)) {
|
||||
PermissionDefault def = PermissionDefault.fromPermission(this.plugin.getPermissionMap().get(permission));
|
||||
if (def != null) {
|
||||
if (def == PermissionDefault.FALSE || (this.isOp && def == PermissionDefault.NOT_OP)) {
|
||||
if (def == PermissionDefault.FALSE || this.isOp && def == PermissionDefault.NOT_OP) {
|
||||
return PERMISSION_MAP_RESULT_FACTORY.result(Tristate.FALSE, "permission map (overriding wildcard): " + prev.cause());
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment {
|
||||
return null;
|
||||
}
|
||||
|
||||
String permission = ((String) key);
|
||||
String permission = (String) key;
|
||||
|
||||
// grab the previous result, so we can still satisfy the method signature of Map
|
||||
Boolean previous = LuckPermsPermissionAttachment.this.perms.get(permission);
|
||||
|
@ -117,7 +117,7 @@ public final class PermissibleInjector {
|
||||
|
||||
// only uninject if the permissible was a luckperms one.
|
||||
if (permissible instanceof LuckPermsPermissible) {
|
||||
LuckPermsPermissible lpPermissible = ((LuckPermsPermissible) permissible);
|
||||
LuckPermsPermissible lpPermissible = (LuckPermsPermissible) permissible;
|
||||
|
||||
// clear all permissions
|
||||
lpPermissible.clearPermissions();
|
||||
|
@ -133,7 +133,7 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
||||
|
||||
@Override
|
||||
public boolean remove(Object key, Object value) {
|
||||
return key != null && value != null && super.remove(key, uninject(((Permission) value)));
|
||||
return key != null && value != null && super.remove(key, uninject((Permission) value));
|
||||
}
|
||||
|
||||
// check for null
|
||||
|
@ -93,7 +93,7 @@ public final class LuckPermsSubscriptionMap extends HashMap<String, Set<Permissi
|
||||
return null;
|
||||
}
|
||||
|
||||
String permission = ((String) key);
|
||||
String permission = (String) key;
|
||||
|
||||
LPSubscriptionValueSet result = (LPSubscriptionValueSet) super.get(key);
|
||||
if (result == null) {
|
||||
|
@ -99,7 +99,7 @@ final class CachedSubjectReference implements LPSubjectReference {
|
||||
}
|
||||
|
||||
private LPSubject tryCache() {
|
||||
if ((System.currentTimeMillis() - this.lastLookup) < CACHE_TIME) {
|
||||
if (System.currentTimeMillis() - this.lastLookup < CACHE_TIME) {
|
||||
if (this.cache != null) {
|
||||
return this.cache.get();
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public final class SubjectReferenceFactory {
|
||||
public LPSubjectReference obtain(SubjectReference reference) {
|
||||
Objects.requireNonNull(reference, "reference");
|
||||
if (reference instanceof LPSubjectReference) {
|
||||
return ((LPSubjectReference) reference);
|
||||
return (LPSubjectReference) reference;
|
||||
} else {
|
||||
return obtain(reference.getCollectionIdentifier(), reference.getSubjectIdentifier());
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class SpongeCommandExecutor extends CommandManager implements CommandCall
|
||||
try {
|
||||
matchedPlayers = Selector.parse(arg).resolve(source).stream()
|
||||
.filter(e -> e instanceof Player)
|
||||
.map(e -> ((Player) e))
|
||||
.map(e -> (Player) e)
|
||||
.collect(Collectors.toList());
|
||||
} catch (IllegalArgumentException e) {
|
||||
this.plugin.getLogger().warn("Error parsing selector '" + arg + "' for " + source + " executing " + args, e);
|
||||
|
@ -45,7 +45,7 @@ public class SpongePlatformListener {
|
||||
if (source == null) return;
|
||||
|
||||
final String name = e.getCommand().toLowerCase();
|
||||
if (((name.equals("op") || name.equals("minecraft:op")) && source.hasPermission("minecraft.command.op")) || ((name.equals("deop") || name.equals("minecraft:deop")) && source.hasPermission("minecraft.command.deop"))) {
|
||||
if ((name.equals("op") || name.equals("minecraft:op")) && source.hasPermission("minecraft.command.op") || (name.equals("deop") || name.equals("minecraft:deop")) && source.hasPermission("minecraft.command.deop")) {
|
||||
Message.OP_DISABLED_SPONGE.send(this.plugin.getSenderFactory().wrap(source));
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class SubjectInheritanceGraph implements Graph<CalculatedSubject> {
|
||||
return subject.getCombinedParents(this.queryOptions).stream()
|
||||
.map(ref -> ref.resolveLp().join())
|
||||
.filter(p -> p instanceof CalculatedSubject)
|
||||
.map(p -> ((CalculatedSubject) p))
|
||||
.map(p -> (CalculatedSubject) p)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -371,10 +371,10 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
}
|
||||
|
||||
if (t.getType() == HolderType.USER) {
|
||||
User user = ((User) t);
|
||||
User user = (User) t;
|
||||
return this.service.getPlugin().getStorage().saveUser(user);
|
||||
} else {
|
||||
Group group = ((Group) t);
|
||||
Group group = (Group) t;
|
||||
return this.service.getPlugin().getStorage().saveGroup(group);
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class SubjectDataContainer {
|
||||
return new JsonArray();
|
||||
}
|
||||
Preconditions.checkArgument(element instanceof JsonArray);
|
||||
return ((JsonArray) element);
|
||||
return (JsonArray) element;
|
||||
}
|
||||
|
||||
private SubjectDataContainer(LPPermissionService service, JsonObject root) {
|
||||
|
Loading…
Reference in New Issue
Block a user