Move from findbugs jsr305 to checker-qual
This commit is contained in:
@@ -37,6 +37,8 @@ import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -46,8 +48,6 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* An implementation of {@link LogEntry} and {@link LogEntry.Builder},
|
||||
* with helper methods for populating and using the entry using internal
|
||||
@@ -96,15 +96,13 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
return this.timestamp;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UUID getActor() {
|
||||
public @NonNull UUID getActor() {
|
||||
return this.actor;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getActorName() {
|
||||
public @NonNull String getActorName() {
|
||||
return this.actorName;
|
||||
}
|
||||
|
||||
@@ -115,21 +113,18 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
return this.actorName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Type getType() {
|
||||
public @NonNull Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<UUID> getActed() {
|
||||
public @NonNull Optional<UUID> getActed() {
|
||||
return Optional.ofNullable(this.acted);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getActedName() {
|
||||
public @NonNull String getActedName() {
|
||||
return this.actedName;
|
||||
}
|
||||
|
||||
@@ -142,14 +137,13 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
return String.valueOf(this.actedName);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getAction() {
|
||||
public @NonNull String getAction() {
|
||||
return this.action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@Nonnull LogEntry other) {
|
||||
public int compareTo(@NonNull LogEntry other) {
|
||||
Objects.requireNonNull(other, "other");
|
||||
return COMPARATOR.compare(this, other);
|
||||
}
|
||||
@@ -216,51 +210,44 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
private String actedName = null;
|
||||
private String action = null;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Builder setTimestamp(long timestamp) {
|
||||
public @NonNull Builder setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Builder setActor(@Nonnull UUID actor) {
|
||||
public @NonNull Builder setActor(@NonNull UUID actor) {
|
||||
this.actor = Objects.requireNonNull(actor, "actor");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Builder setActorName(@Nonnull String actorName) {
|
||||
public @NonNull Builder setActorName(@NonNull String actorName) {
|
||||
this.actorName = Objects.requireNonNull(actorName, "actorName");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Builder setType(@Nonnull Type type) {
|
||||
public @NonNull Builder setType(@NonNull Type type) {
|
||||
this.type = Objects.requireNonNull(type, "type");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Builder setActed(UUID acted) {
|
||||
public @NonNull Builder setActed(UUID acted) {
|
||||
this.acted = acted; // nullable
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Builder setActedName(@Nonnull String actedName) {
|
||||
public @NonNull Builder setActedName(@NonNull String actedName) {
|
||||
this.actedName = Objects.requireNonNull(actedName, "actedName");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Builder setAction(@Nonnull String action) {
|
||||
public @NonNull Builder setAction(@NonNull String action) {
|
||||
this.action = Objects.requireNonNull(action, "action");
|
||||
return this;
|
||||
}
|
||||
@@ -348,9 +335,8 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ExtendedLogEntry build() {
|
||||
public @NonNull ExtendedLogEntry build() {
|
||||
if (this.timestamp == 0L) {
|
||||
timestamp(System.currentTimeMillis() / 1000L);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ package me.lucko.luckperms.common.api;
|
||||
|
||||
import me.lucko.luckperms.api.DemotionResult;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Utility class for creating instances of {@link DemotionResult}.
|
||||
*/
|
||||
@@ -76,21 +76,18 @@ public final class DemotionResults {
|
||||
this(status, null, null);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Status getStatus() {
|
||||
public @NonNull Status getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getGroupFrom() {
|
||||
public @NonNull Optional<String> getGroupFrom() {
|
||||
return Optional.ofNullable(this.groupFrom);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getGroupTo() {
|
||||
public @NonNull Optional<String> getGroupTo() {
|
||||
return Optional.ofNullable(this.groupTo);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,11 +54,11 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.messaging.LuckPermsMessagingService;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Implements the LuckPerms API using the plugin instance
|
||||
*/
|
||||
@@ -86,93 +86,81 @@ public class LuckPermsApiProvider implements LuckPermsApi {
|
||||
this.metaStackFactory = new ApiMetaStackFactory(plugin);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public PlatformInfo getPlatformInfo() {
|
||||
public @NonNull PlatformInfo getPlatformInfo() {
|
||||
return this.platformInfo;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UserManager getUserManager() {
|
||||
public @NonNull UserManager getUserManager() {
|
||||
return this.userManager;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public GroupManager getGroupManager() {
|
||||
public @NonNull GroupManager getGroupManager() {
|
||||
return this.groupManager;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TrackManager getTrackManager() {
|
||||
public @NonNull TrackManager getTrackManager() {
|
||||
return this.trackManager;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> runUpdateTask() {
|
||||
public @NonNull CompletableFuture<Void> runUpdateTask() {
|
||||
return this.plugin.getSyncTaskBuffer().request();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EventBus getEventBus() {
|
||||
public @NonNull EventBus getEventBus() {
|
||||
return this.plugin.getEventFactory().getEventBus();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LPConfiguration getConfiguration() {
|
||||
public @NonNull LPConfiguration getConfiguration() {
|
||||
return this.plugin.getConfiguration().getDelegate();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Storage getStorage() {
|
||||
public @NonNull Storage getStorage() {
|
||||
return this.plugin.getStorage().getApiDelegate();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<MessagingService> getMessagingService() {
|
||||
public @NonNull Optional<MessagingService> getMessagingService() {
|
||||
return this.plugin.getMessagingService().map(ApiMessagingService::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMessengerProvider(@Nonnull MessengerProvider messengerProvider) {
|
||||
public void registerMessengerProvider(@NonNull MessengerProvider messengerProvider) {
|
||||
if (this.plugin.getConfiguration().get(ConfigKeys.MESSAGING_SERVICE).equals("custom")) {
|
||||
this.plugin.setMessagingService(new LuckPermsMessagingService(this.plugin, messengerProvider));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionLogger getActionLogger() {
|
||||
public @NonNull ActionLogger getActionLogger() {
|
||||
return this.actionLogger;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public UuidCache getUuidCache() {
|
||||
@Override
|
||||
public @NonNull UuidCache getUuidCache() {
|
||||
return NoopUuidCache.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContextManager getContextManager() {
|
||||
public @NonNull ContextManager getContextManager() {
|
||||
return this.contextManager;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NodeFactory getNodeFactory() {
|
||||
public @NonNull NodeFactory getNodeFactory() {
|
||||
return ApiNodeFactory.INSTANCE;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public MetaStackFactory getMetaStackFactory() {
|
||||
public @NonNull MetaStackFactory getMetaStackFactory() {
|
||||
return this.metaStackFactory;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ package me.lucko.luckperms.common.api;
|
||||
|
||||
import me.lucko.luckperms.api.PromotionResult;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Utility class for creating instances of {@link PromotionResult}.
|
||||
*/
|
||||
@@ -76,21 +76,18 @@ public final class PromotionResults {
|
||||
this(status, null, null);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Status getStatus() {
|
||||
public @NonNull Status getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getGroupFrom() {
|
||||
public @NonNull Optional<String> getGroupFrom() {
|
||||
return Optional.ofNullable(this.groupFrom);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getGroupTo() {
|
||||
public @NonNull Optional<String> getGroupTo() {
|
||||
return Optional.ofNullable(this.groupTo);
|
||||
}
|
||||
|
||||
|
||||
+13
-21
@@ -34,11 +34,11 @@ import me.lucko.luckperms.common.api.delegates.model.ApiUser;
|
||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ApiContextManager implements me.lucko.luckperms.api.context.ContextManager {
|
||||
private final LuckPermsPlugin plugin;
|
||||
@@ -56,75 +56,67 @@ public class ApiContextManager implements me.lucko.luckperms.api.context.Context
|
||||
return subject;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ImmutableContextSet getApplicableContext(@Nonnull Object subject) {
|
||||
public @NonNull ImmutableContextSet getApplicableContext(@NonNull Object subject) {
|
||||
Objects.requireNonNull(subject, "subject");
|
||||
return this.handle.getApplicableContext(checkType(subject));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Contexts getApplicableContexts(@Nonnull Object subject) {
|
||||
public @NonNull Contexts getApplicableContexts(@NonNull Object subject) {
|
||||
Objects.requireNonNull(subject, "subject");
|
||||
return this.handle.getApplicableContexts(checkType(subject));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<ImmutableContextSet> lookupApplicableContext(@Nonnull User user) {
|
||||
public @NonNull Optional<ImmutableContextSet> lookupApplicableContext(@NonNull User user) {
|
||||
Objects.requireNonNull(user, "user");
|
||||
return this.plugin.getContextForUser(ApiUser.cast(user)).map(c -> c.getContexts().makeImmutable());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<Contexts> lookupApplicableContexts(@Nonnull User user) {
|
||||
public @NonNull Optional<Contexts> lookupApplicableContexts(@NonNull User user) {
|
||||
Objects.requireNonNull(user, "user");
|
||||
return this.plugin.getContextForUser(ApiUser.cast(user));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ImmutableContextSet getStaticContext() {
|
||||
public @NonNull ImmutableContextSet getStaticContext() {
|
||||
return this.handle.getStaticContext();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Contexts getStaticContexts() {
|
||||
public @NonNull Contexts getStaticContexts() {
|
||||
return this.handle.getStaticContexts();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Contexts formContexts(@Nonnull Object subject, @Nonnull ImmutableContextSet contextSet) {
|
||||
public @NonNull Contexts formContexts(@NonNull Object subject, @NonNull ImmutableContextSet contextSet) {
|
||||
Objects.requireNonNull(subject, "subject");
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
return this.handle.formContexts(checkType(subject), contextSet);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Contexts formContexts(@Nonnull ImmutableContextSet contextSet) {
|
||||
public @NonNull Contexts formContexts(@NonNull ImmutableContextSet contextSet) {
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
return this.handle.formContexts(contextSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCalculator(@Nonnull ContextCalculator<?> calculator) {
|
||||
public void registerCalculator(@NonNull ContextCalculator<?> calculator) {
|
||||
Objects.requireNonNull(calculator, "calculator");
|
||||
this.handle.registerCalculator(calculator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStaticCalculator(@Nonnull StaticContextCalculator calculator) {
|
||||
public void registerStaticCalculator(@NonNull StaticContextCalculator calculator) {
|
||||
Objects.requireNonNull(calculator, "calculator");
|
||||
this.handle.registerStaticCalculator(calculator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateCache(@Nonnull Object subject) {
|
||||
public void invalidateCache(@NonNull Object subject) {
|
||||
Objects.requireNonNull(subject, "subject");
|
||||
this.handle.invalidateCache(checkType(subject));
|
||||
}
|
||||
|
||||
+11
-18
@@ -38,14 +38,14 @@ import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ApiGroupManager extends ApiAbstractManager<Group, me.lucko.luckperms.api.Group, GroupManager<?>> implements me.lucko.luckperms.api.manager.GroupManager {
|
||||
public ApiGroupManager(LuckPermsPlugin plugin, GroupManager<?> handle) {
|
||||
super(plugin, handle);
|
||||
@@ -60,31 +60,27 @@ public class ApiGroupManager extends ApiAbstractManager<Group, me.lucko.luckperm
|
||||
return internal.getApiDelegate();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<me.lucko.luckperms.api.Group> createAndLoadGroup(@Nonnull String name) {
|
||||
public @NonNull CompletableFuture<me.lucko.luckperms.api.Group> createAndLoadGroup(@NonNull String name) {
|
||||
name = ApiUtils.checkName(Objects.requireNonNull(name, "name"));
|
||||
return this.plugin.getStorage().createAndLoadGroup(name, CreationCause.API)
|
||||
.thenApply(this::getDelegateFor);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Optional<me.lucko.luckperms.api.Group>> loadGroup(@Nonnull String name) {
|
||||
public @NonNull CompletableFuture<Optional<me.lucko.luckperms.api.Group>> loadGroup(@NonNull String name) {
|
||||
name = ApiUtils.checkName(Objects.requireNonNull(name, "name"));
|
||||
return this.plugin.getStorage().loadGroup(name).thenApply(opt -> opt.map(this::getDelegateFor));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> saveGroup(@Nonnull me.lucko.luckperms.api.Group group) {
|
||||
public @NonNull CompletableFuture<Void> saveGroup(me.lucko.luckperms.api.@NonNull Group group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
return this.plugin.getStorage().saveGroup(ApiGroup.cast(group));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> deleteGroup(@Nonnull me.lucko.luckperms.api.Group group) {
|
||||
public @NonNull CompletableFuture<Void> deleteGroup(me.lucko.luckperms.api.@NonNull Group group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
if (group.getName().equalsIgnoreCase(NodeFactory.DEFAULT_GROUP_NAME)) {
|
||||
throw new IllegalArgumentException("Cannot delete the default group.");
|
||||
@@ -92,35 +88,32 @@ public class ApiGroupManager extends ApiAbstractManager<Group, me.lucko.luckperm
|
||||
return this.plugin.getStorage().deleteGroup(ApiGroup.cast(group), DeletionCause.API);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> loadAllGroups() {
|
||||
public @NonNull CompletableFuture<Void> loadAllGroups() {
|
||||
return this.plugin.getStorage().loadAllGroups();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<List<HeldPermission<String>>> getWithPermission(@Nonnull String permission) {
|
||||
public @NonNull CompletableFuture<List<HeldPermission<String>>> getWithPermission(@NonNull String permission) {
|
||||
Objects.requireNonNull(permission, "permission");
|
||||
return this.plugin.getStorage().getGroupsWithPermission(Constraint.of(StandardComparison.EQUAL, permission));
|
||||
}
|
||||
|
||||
@Override
|
||||
public me.lucko.luckperms.api.Group getGroup(@Nonnull String name) {
|
||||
public me.lucko.luckperms.api.Group getGroup(@NonNull String name) {
|
||||
Objects.requireNonNull(name, "name");
|
||||
return getDelegateFor(this.handle.getIfLoaded(name));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<me.lucko.luckperms.api.Group> getLoadedGroups() {
|
||||
public @NonNull Set<me.lucko.luckperms.api.Group> getLoadedGroups() {
|
||||
return this.handle.getAll().values().stream()
|
||||
.map(this::getDelegateFor)
|
||||
.collect(ImmutableCollectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded(@Nonnull String name) {
|
||||
public boolean isLoaded(@NonNull String name) {
|
||||
Objects.requireNonNull(name, "name");
|
||||
return this.handle.isLoaded(name);
|
||||
}
|
||||
|
||||
+10
-16
@@ -34,13 +34,13 @@ import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ApiTrackManager extends ApiAbstractManager<Track, me.lucko.luckperms.api.Track, TrackManager<?>> implements me.lucko.luckperms.api.manager.TrackManager {
|
||||
public ApiTrackManager(LuckPermsPlugin plugin, TrackManager<?> handle) {
|
||||
super(plugin, handle);
|
||||
@@ -55,57 +55,51 @@ public class ApiTrackManager extends ApiAbstractManager<Track, me.lucko.luckperm
|
||||
return internal.getApiDelegate();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<me.lucko.luckperms.api.Track> createAndLoadTrack(@Nonnull String name) {
|
||||
public @NonNull CompletableFuture<me.lucko.luckperms.api.Track> createAndLoadTrack(@NonNull String name) {
|
||||
name = ApiUtils.checkName(Objects.requireNonNull(name, "name"));
|
||||
return this.plugin.getStorage().createAndLoadTrack(name, CreationCause.API)
|
||||
.thenApply(this::getDelegateFor);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Optional<me.lucko.luckperms.api.Track>> loadTrack(@Nonnull String name) {
|
||||
public @NonNull CompletableFuture<Optional<me.lucko.luckperms.api.Track>> loadTrack(@NonNull String name) {
|
||||
name = ApiUtils.checkName(Objects.requireNonNull(name, "name"));
|
||||
return this.plugin.getStorage().loadTrack(name).thenApply(opt -> opt.map(this::getDelegateFor));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> saveTrack(@Nonnull me.lucko.luckperms.api.Track track) {
|
||||
public @NonNull CompletableFuture<Void> saveTrack(me.lucko.luckperms.api.@NonNull Track track) {
|
||||
Objects.requireNonNull(track, "track");
|
||||
return this.plugin.getStorage().saveTrack(ApiTrack.cast(track));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> deleteTrack(@Nonnull me.lucko.luckperms.api.Track track) {
|
||||
public @NonNull CompletableFuture<Void> deleteTrack(me.lucko.luckperms.api.@NonNull Track track) {
|
||||
Objects.requireNonNull(track, "track");
|
||||
return this.plugin.getStorage().deleteTrack(ApiTrack.cast(track), DeletionCause.API);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> loadAllTracks() {
|
||||
public @NonNull CompletableFuture<Void> loadAllTracks() {
|
||||
return this.plugin.getStorage().loadAllTracks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public me.lucko.luckperms.api.Track getTrack(@Nonnull String name) {
|
||||
public me.lucko.luckperms.api.Track getTrack(@NonNull String name) {
|
||||
Objects.requireNonNull(name, "name");
|
||||
return getDelegateFor(this.handle.getIfLoaded(name));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<me.lucko.luckperms.api.Track> getLoadedTracks() {
|
||||
public @NonNull Set<me.lucko.luckperms.api.Track> getLoadedTracks() {
|
||||
return this.handle.getAll().values().stream()
|
||||
.map(this::getDelegateFor)
|
||||
.collect(ImmutableCollectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded(@Nonnull String name) {
|
||||
public boolean isLoaded(@NonNull String name) {
|
||||
Objects.requireNonNull(name, "name");
|
||||
return this.handle.isLoaded(name);
|
||||
}
|
||||
|
||||
+15
-23
@@ -37,15 +37,15 @@ import me.lucko.luckperms.common.model.UserIdentifier;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ApiUserManager extends ApiAbstractManager<User, me.lucko.luckperms.api.User, UserManager<?>> implements me.lucko.luckperms.api.manager.UserManager {
|
||||
public ApiUserManager(LuckPermsPlugin plugin, UserManager<?> handle) {
|
||||
super(plugin, handle);
|
||||
@@ -59,9 +59,8 @@ public class ApiUserManager extends ApiAbstractManager<User, me.lucko.luckperms.
|
||||
return new ApiUser(internal);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<me.lucko.luckperms.api.User> loadUser(@Nonnull UUID uuid, @Nullable String username) {
|
||||
public @NonNull CompletableFuture<me.lucko.luckperms.api.User> loadUser(@NonNull UUID uuid, @Nullable String username) {
|
||||
Objects.requireNonNull(uuid, "uuid");
|
||||
ApiUtils.checkUsername(username);
|
||||
|
||||
@@ -73,76 +72,69 @@ public class ApiUserManager extends ApiAbstractManager<User, me.lucko.luckperms.
|
||||
.thenApply(this::getDelegateFor);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<UUID> lookupUuid(@Nonnull String username) {
|
||||
public @NonNull CompletableFuture<UUID> lookupUuid(@NonNull String username) {
|
||||
Objects.requireNonNull(username, "username");
|
||||
return this.plugin.getStorage().getPlayerUuid(username);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<String> lookupUsername(@Nonnull UUID uuid) {
|
||||
public @NonNull CompletableFuture<String> lookupUsername(@NonNull UUID uuid) {
|
||||
Objects.requireNonNull(uuid, "uuid");
|
||||
return this.plugin.getStorage().getPlayerName(uuid);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> saveUser(@Nonnull me.lucko.luckperms.api.User user) {
|
||||
public @NonNull CompletableFuture<Void> saveUser(me.lucko.luckperms.api.@NonNull User user) {
|
||||
Objects.requireNonNull(user, "user");
|
||||
return this.plugin.getStorage().saveUser(ApiUser.cast(user));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<PlayerSaveResult> savePlayerData(@Nonnull UUID uuid, @Nonnull String username) {
|
||||
public @NonNull CompletableFuture<PlayerSaveResult> savePlayerData(@NonNull UUID uuid, @NonNull String username) {
|
||||
Objects.requireNonNull(uuid, "uuid");
|
||||
Objects.requireNonNull(username, "username");
|
||||
return this.plugin.getStorage().savePlayerData(uuid, username);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Set<UUID>> getUniqueUsers() {
|
||||
public @NonNull CompletableFuture<Set<UUID>> getUniqueUsers() {
|
||||
return this.plugin.getStorage().getUniqueUsers();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<List<HeldPermission<UUID>>> getWithPermission(@Nonnull String permission) {
|
||||
public @NonNull CompletableFuture<List<HeldPermission<UUID>>> getWithPermission(@NonNull String permission) {
|
||||
Objects.requireNonNull(permission, "permission");
|
||||
return this.plugin.getStorage().getUsersWithPermission(Constraint.of(StandardComparison.EQUAL, permission));
|
||||
}
|
||||
|
||||
@Override
|
||||
public me.lucko.luckperms.api.User getUser(@Nonnull UUID uuid) {
|
||||
public me.lucko.luckperms.api.User getUser(@NonNull UUID uuid) {
|
||||
Objects.requireNonNull(uuid, "uuid");
|
||||
return getDelegateFor(this.handle.getIfLoaded(uuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public me.lucko.luckperms.api.User getUser(@Nonnull String name) {
|
||||
public me.lucko.luckperms.api.User getUser(@NonNull String name) {
|
||||
Objects.requireNonNull(name, "name");
|
||||
return getDelegateFor(this.handle.getByUsername(name));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<me.lucko.luckperms.api.User> getLoadedUsers() {
|
||||
public @NonNull Set<me.lucko.luckperms.api.User> getLoadedUsers() {
|
||||
return this.handle.getAll().values().stream()
|
||||
.map(this::getDelegateFor)
|
||||
.collect(ImmutableCollectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded(@Nonnull UUID uuid) {
|
||||
public boolean isLoaded(@NonNull UUID uuid) {
|
||||
Objects.requireNonNull(uuid, "uuid");
|
||||
return this.handle.isLoaded(UserIdentifier.of(uuid, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupUser(@Nonnull me.lucko.luckperms.api.User user) {
|
||||
public void cleanupUser(me.lucko.luckperms.api.@NonNull User user) {
|
||||
Objects.requireNonNull(user, "user");
|
||||
this.handle.getHouseKeeper().clearApiUsage(ApiUser.cast(user).getUuid());
|
||||
}
|
||||
|
||||
+7
-12
@@ -32,9 +32,9 @@ import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||
import me.lucko.luckperms.common.api.delegates.model.ApiLog;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ApiActionLogger implements ActionLogger {
|
||||
private final LuckPermsPlugin plugin;
|
||||
@@ -43,33 +43,28 @@ public class ApiActionLogger implements ActionLogger {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LogEntry.Builder newEntryBuilder() {
|
||||
public LogEntry.@NonNull Builder newEntryBuilder() {
|
||||
return ExtendedLogEntry.build();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Log> getLog() {
|
||||
public @NonNull CompletableFuture<Log> getLog() {
|
||||
return this.plugin.getStorage().getLog().thenApply(ApiLog::new);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> submit(@Nonnull LogEntry entry) {
|
||||
public @NonNull CompletableFuture<Void> submit(@NonNull LogEntry entry) {
|
||||
return CompletableFuture.runAsync(() -> this.plugin.getLogDispatcher().dispatchFromApi((ExtendedLogEntry) entry), this.plugin.getBootstrap().getScheduler().async());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> submitToStorage(@Nonnull LogEntry entry) {
|
||||
public @NonNull CompletableFuture<Void> submitToStorage(@NonNull LogEntry entry) {
|
||||
return this.plugin.getStorage().logAction(entry);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> broadcastAction(@Nonnull LogEntry entry) {
|
||||
public @NonNull CompletableFuture<Void> broadcastAction(@NonNull LogEntry entry) {
|
||||
return CompletableFuture.runAsync(() -> this.plugin.getLogDispatcher().broadcastFromApi((ExtendedLogEntry) entry), this.plugin.getBootstrap().getScheduler().async());
|
||||
}
|
||||
}
|
||||
|
||||
+7
-12
@@ -32,9 +32,9 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
|
||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
|
||||
public class ApiConfiguration implements LPConfiguration {
|
||||
private final LuckPermsConfiguration handle;
|
||||
@@ -45,9 +45,8 @@ public class ApiConfiguration implements LPConfiguration {
|
||||
this.unsafe = new UnsafeImpl();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getServer() {
|
||||
public @NonNull String getServer() {
|
||||
return this.handle.get(ConfigKeys.SERVER);
|
||||
}
|
||||
|
||||
@@ -71,9 +70,8 @@ public class ApiConfiguration implements LPConfiguration {
|
||||
return this.handle.get(ConfigKeys.LOOKUP_SETTINGS).contains(LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getStorageMethod() {
|
||||
public @NonNull String getStorageMethod() {
|
||||
return this.handle.get(ConfigKeys.STORAGE_METHOD);
|
||||
}
|
||||
|
||||
@@ -82,24 +80,21 @@ public class ApiConfiguration implements LPConfiguration {
|
||||
return this.handle.get(ConfigKeys.SPLIT_STORAGE);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Map<String, String> getSplitStorageOptions() {
|
||||
public @NonNull Map<String, String> getSplitStorageOptions() {
|
||||
return this.handle.get(ConfigKeys.SPLIT_STORAGE_OPTIONS).entrySet().stream()
|
||||
.collect(ImmutableCollectors.toMap(e -> e.getKey().name().toLowerCase(), Map.Entry::getValue));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Unsafe unsafe() {
|
||||
public @NonNull Unsafe unsafe() {
|
||||
return this.unsafe;
|
||||
}
|
||||
|
||||
private final class UnsafeImpl implements Unsafe {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Object getObject(String key) {
|
||||
public @NonNull Object getObject(String key) {
|
||||
ConfigKey<?> configKey = ConfigKeys.getKeys().get(key.toUpperCase());
|
||||
if (configKey == null) {
|
||||
throw new IllegalArgumentException("Unknown key: " + key);
|
||||
|
||||
+3
-3
@@ -30,9 +30,9 @@ import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.common.api.delegates.model.ApiUser;
|
||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ApiMessagingService implements MessagingService {
|
||||
private final InternalMessagingService handle;
|
||||
@@ -52,7 +52,7 @@ public class ApiMessagingService implements MessagingService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushUserUpdate(@Nonnull User user) {
|
||||
public void pushUserUpdate(@NonNull User user) {
|
||||
Objects.requireNonNull(user, "user");
|
||||
this.handle.pushUserUpdate(ApiUser.cast(user));
|
||||
}
|
||||
|
||||
+5
-8
@@ -34,12 +34,12 @@ import me.lucko.luckperms.common.metastacking.SimpleMetaStackDefinition;
|
||||
import me.lucko.luckperms.common.metastacking.StandardStackElements;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ApiMetaStackFactory implements MetaStackFactory {
|
||||
public final LuckPermsPlugin plugin;
|
||||
|
||||
@@ -47,16 +47,14 @@ public class ApiMetaStackFactory implements MetaStackFactory {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<MetaStackElement> fromString(@Nonnull String definition) {
|
||||
public @NonNull Optional<MetaStackElement> fromString(@NonNull String definition) {
|
||||
Objects.requireNonNull(definition, "definition");
|
||||
return Optional.ofNullable(StandardStackElements.parseFromString(this.plugin, definition));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<MetaStackElement> fromStrings(@Nonnull List<String> definitions) {
|
||||
public @NonNull List<MetaStackElement> fromStrings(@NonNull List<String> definitions) {
|
||||
Objects.requireNonNull(definitions, "definitions");
|
||||
if (definitions.isEmpty()) {
|
||||
return ImmutableList.of();
|
||||
@@ -64,9 +62,8 @@ public class ApiMetaStackFactory implements MetaStackFactory {
|
||||
return StandardStackElements.parseList(this.plugin, definitions);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public MetaStackDefinition createDefinition(@Nonnull List<MetaStackElement> elements, @Nonnull String startSpacer, @Nonnull String middleSpacer, @Nonnull String endSpacer) {
|
||||
public @NonNull MetaStackDefinition createDefinition(@NonNull List<MetaStackElement> elements, @NonNull String startSpacer, @NonNull String middleSpacer, @NonNull String endSpacer) {
|
||||
return new SimpleMetaStackDefinition(elements, startSpacer, middleSpacer, endSpacer);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-18
@@ -31,9 +31,9 @@ import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.api.delegates.model.ApiGroup;
|
||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class ApiNodeFactory implements me.lucko.luckperms.api.NodeFactory {
|
||||
public static final ApiNodeFactory INSTANCE = new ApiNodeFactory();
|
||||
@@ -42,59 +42,51 @@ public final class ApiNodeFactory implements me.lucko.luckperms.api.NodeFactory
|
||||
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder newBuilder(@Nonnull String permission) {
|
||||
public Node.@NonNull Builder newBuilder(@NonNull String permission) {
|
||||
Objects.requireNonNull(permission, "permission");
|
||||
return NodeFactory.builder(permission);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder newBuilderFromExisting(@Nonnull Node other) {
|
||||
public Node.@NonNull Builder newBuilderFromExisting(@NonNull Node other) {
|
||||
return Objects.requireNonNull(other, "other").toBuilder();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder makeGroupNode(@Nonnull Group group) {
|
||||
public Node.@NonNull Builder makeGroupNode(@NonNull Group group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
return NodeFactory.buildGroupNode(ApiGroup.cast(group));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder makeGroupNode(@Nonnull String groupName) {
|
||||
public Node.@NonNull Builder makeGroupNode(@NonNull String groupName) {
|
||||
Objects.requireNonNull(groupName, "groupName");
|
||||
return NodeFactory.buildGroupNode(groupName);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder makeMetaNode(@Nonnull String key, @Nonnull String value) {
|
||||
public Node.@NonNull Builder makeMetaNode(@NonNull String key, @NonNull String value) {
|
||||
Objects.requireNonNull(key, "key");
|
||||
Objects.requireNonNull(value, "value");
|
||||
return NodeFactory.buildMetaNode(key, value);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder makeChatMetaNode(@Nonnull ChatMetaType type, int priority, @Nonnull String value) {
|
||||
public Node.@NonNull Builder makeChatMetaNode(@NonNull ChatMetaType type, int priority, @NonNull String value) {
|
||||
Objects.requireNonNull(type, "type");
|
||||
Objects.requireNonNull(value, "value");
|
||||
return NodeFactory.buildChatMetaNode(type, priority, value);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder makePrefixNode(int priority, @Nonnull String prefix) {
|
||||
public Node.@NonNull Builder makePrefixNode(int priority, @NonNull String prefix) {
|
||||
Objects.requireNonNull(prefix, "prefix");
|
||||
return NodeFactory.buildPrefixNode(priority, prefix);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder makeSuffixNode(int priority, @Nonnull String suffix) {
|
||||
public Node.@NonNull Builder makeSuffixNode(int priority, @NonNull String suffix) {
|
||||
Objects.requireNonNull(suffix, "suffix");
|
||||
return NodeFactory.buildSuffixNode(priority, suffix);
|
||||
}
|
||||
|
||||
+5
-8
@@ -29,12 +29,12 @@ import me.lucko.luckperms.api.platform.PlatformInfo;
|
||||
import me.lucko.luckperms.api.platform.PlatformType;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ApiPlatformInfo implements PlatformInfo {
|
||||
private final LuckPermsPlugin plugin;
|
||||
|
||||
@@ -42,9 +42,8 @@ public class ApiPlatformInfo implements PlatformInfo {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getVersion() {
|
||||
public @NonNull String getVersion() {
|
||||
return this.plugin.getBootstrap().getVersion();
|
||||
}
|
||||
|
||||
@@ -53,15 +52,13 @@ public class ApiPlatformInfo implements PlatformInfo {
|
||||
return 4.2;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public PlatformType getType() {
|
||||
public @NonNull PlatformType getType() {
|
||||
return this.plugin.getBootstrap().getType();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<UUID> getUniqueConnections() {
|
||||
public @NonNull Set<UUID> getUniqueConnections() {
|
||||
return Collections.unmodifiableSet(this.plugin.getConnectionListener().getUniqueConnections());
|
||||
}
|
||||
|
||||
|
||||
+6
-8
@@ -27,9 +27,9 @@ package me.lucko.luckperms.common.api.delegates.misc;
|
||||
|
||||
import me.lucko.luckperms.api.UuidCache;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.UUID;
|
||||
|
||||
@Deprecated
|
||||
@SuppressWarnings({"DeprecatedIsStillUsed", "deprecation"})
|
||||
@@ -40,17 +40,15 @@ public class NoopUuidCache implements UuidCache {
|
||||
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public UUID getUUID(@Nonnull UUID external) {
|
||||
@Override
|
||||
public @NonNull UUID getUUID(@NonNull UUID external) {
|
||||
return external;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public UUID getExternalUUID(@Nonnull UUID internal) {
|
||||
@Override
|
||||
public @NonNull UUID getExternalUUID(@NonNull UUID internal) {
|
||||
return internal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +31,12 @@ import me.lucko.luckperms.api.caching.GroupData;
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class ApiGroup extends ApiPermissionHolder implements me.lucko.luckperms.api.Group {
|
||||
public static Group cast(me.lucko.luckperms.api.Group group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
@@ -56,33 +56,28 @@ public final class ApiGroup extends ApiPermissionHolder implements me.lucko.luck
|
||||
return this.handle;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NonNull String getName() {
|
||||
return this.handle.getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @Nullable String getDisplayName() {
|
||||
return this.handle.getDisplayName().orElse(null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getDisplayName(@Nonnull ContextSet contextSet) {
|
||||
public @Nullable String getDisplayName(@NonNull ContextSet contextSet) {
|
||||
return this.handle.getDisplayName(contextSet).orElse(null);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public OptionalInt getWeight() {
|
||||
public @NonNull OptionalInt getWeight() {
|
||||
return this.handle.getWeight();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public GroupData getCachedData() {
|
||||
public @NonNull GroupData getCachedData() {
|
||||
return this.handle.getCachedData();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@ package me.lucko.luckperms.common.api.delegates.model;
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.common.actionlog.Log;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static me.lucko.luckperms.common.api.ApiUtils.checkName;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -44,36 +44,31 @@ public class ApiLog implements me.lucko.luckperms.api.Log {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public SortedSet<LogEntry> getContent() {
|
||||
public @NonNull SortedSet<LogEntry> getContent() {
|
||||
return (SortedSet) this.handle.getContent();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public SortedSet<LogEntry> getContent(@Nonnull UUID actor) {
|
||||
public @NonNull SortedSet<LogEntry> getContent(@NonNull UUID actor) {
|
||||
Objects.requireNonNull(actor, "actor");
|
||||
return (SortedSet) this.handle.getContent(actor);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public SortedSet<LogEntry> getUserHistory(@Nonnull UUID uuid) {
|
||||
public @NonNull SortedSet<LogEntry> getUserHistory(@NonNull UUID uuid) {
|
||||
Objects.requireNonNull(uuid, "uuid");
|
||||
return (SortedSet) this.handle.getUserHistory(uuid);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public SortedSet<LogEntry> getGroupHistory(@Nonnull String name) {
|
||||
public @NonNull SortedSet<LogEntry> getGroupHistory(@NonNull String name) {
|
||||
Objects.requireNonNull(name, "name");
|
||||
return (SortedSet) this.handle.getGroupHistory(checkName(name));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public SortedSet<LogEntry> getTrackHistory(@Nonnull String name) {
|
||||
public @NonNull SortedSet<LogEntry> getTrackHistory(@NonNull String name) {
|
||||
Objects.requireNonNull(name, "name");
|
||||
return (SortedSet) this.handle.getTrackHistory(checkName(name));
|
||||
}
|
||||
|
||||
+39
-69
@@ -53,6 +53,8 @@ import me.lucko.luckperms.common.node.utils.MetaType;
|
||||
import me.lucko.luckperms.common.node.utils.NodeTools;
|
||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -63,8 +65,6 @@ import java.util.TreeSet;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHolder {
|
||||
private final PermissionHolder handle;
|
||||
|
||||
@@ -76,71 +76,60 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
||||
return this.handle;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getObjectName() {
|
||||
public @NonNull String getObjectName() {
|
||||
return this.handle.getObjectName();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getFriendlyName() {
|
||||
public @NonNull String getFriendlyName() {
|
||||
return this.handle.getPlainDisplayName();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CachedData getCachedData() {
|
||||
public @NonNull CachedData getCachedData() {
|
||||
return this.handle.getCachedData();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> refreshCachedData() {
|
||||
public @NonNull CompletableFuture<Void> refreshCachedData() {
|
||||
return CompletableFuture.runAsync(() -> this.handle.getCachedData().invalidate());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ImmutableSetMultimap<ImmutableContextSet, Node> getNodes() {
|
||||
public @NonNull ImmutableSetMultimap<ImmutableContextSet, Node> getNodes() {
|
||||
//noinspection unchecked
|
||||
return (ImmutableSetMultimap) this.handle.enduringData().immutable();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ImmutableSetMultimap<ImmutableContextSet, Node> getTransientNodes() {
|
||||
public @NonNull ImmutableSetMultimap<ImmutableContextSet, Node> getTransientNodes() {
|
||||
//noinspection unchecked
|
||||
return (ImmutableSetMultimap) this.handle.transientData().immutable();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<Node> getOwnNodes() {
|
||||
public @NonNull List<Node> getOwnNodes() {
|
||||
return ImmutableList.copyOf(this.handle.getOwnNodes());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public SortedSet<? extends Node> getPermissions() {
|
||||
public @NonNull SortedSet<? extends Node> getPermissions() {
|
||||
return ImmutableSortedSet.copyOfSorted(this.handle.getOwnNodesSorted());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<Node> getEnduringPermissions() {
|
||||
public @NonNull Set<Node> getEnduringPermissions() {
|
||||
return ImmutableSet.copyOf(this.handle.enduringData().immutable().values());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<Node> getTransientPermissions() {
|
||||
public @NonNull Set<Node> getTransientPermissions() {
|
||||
return ImmutableSet.copyOf(this.handle.transientData().immutable().values());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public SortedSet<LocalizedNode> getAllNodes(@Nonnull Contexts contexts) {
|
||||
public @NonNull SortedSet<LocalizedNode> getAllNodes(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
|
||||
List<LocalizedNode> nodes = new LinkedList<>();
|
||||
@@ -153,9 +142,8 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
||||
return ImmutableSortedSet.copyOfSorted(ret);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public SortedSet<LocalizedNode> getAllNodes() {
|
||||
public @NonNull SortedSet<LocalizedNode> getAllNodes() {
|
||||
List<LocalizedNode> nodes = new LinkedList<>();
|
||||
this.handle.accumulateInheritancesTo(nodes);
|
||||
NodeTools.removeEqual(nodes.iterator(), StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
||||
@@ -166,9 +154,8 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
||||
return ImmutableSortedSet.copyOfSorted(ret);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<LocalizedNode> getAllNodesFiltered(@Nonnull Contexts contexts) {
|
||||
public @NonNull Set<LocalizedNode> getAllNodesFiltered(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
|
||||
List<LocalizedNode> entries = this.handle.getAllEntries(contexts);
|
||||
@@ -180,60 +167,53 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
||||
return ImmutableSet.copyOf(ret);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Map<String, Boolean> exportNodes(@Nonnull Contexts contexts, boolean lowerCase) {
|
||||
public @NonNull Map<String, Boolean> exportNodes(@NonNull Contexts contexts, boolean lowerCase) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
return ImmutableMap.copyOf(this.handle.exportPermissions(contexts, lowerCase, true));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Tristate hasPermission(@Nonnull Node node, @Nonnull NodeEqualityPredicate equalityPredicate) {
|
||||
public @NonNull Tristate hasPermission(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
Objects.requireNonNull(equalityPredicate, "equalityPredicate");
|
||||
return this.handle.hasPermission(NodeMapType.ENDURING, node, equalityPredicate);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Tristate hasTransientPermission(@Nonnull Node node, @Nonnull NodeEqualityPredicate equalityPredicate) {
|
||||
public @NonNull Tristate hasTransientPermission(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
Objects.requireNonNull(equalityPredicate, "equalityPredicate");
|
||||
return this.handle.hasPermission(NodeMapType.TRANSIENT, node, equalityPredicate);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Tristate inheritsPermission(@Nonnull Node node, @Nonnull NodeEqualityPredicate equalityPredicate) {
|
||||
public @NonNull Tristate inheritsPermission(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
Objects.requireNonNull(equalityPredicate, "equalityPredicate");
|
||||
return this.handle.inheritsPermission(node, equalityPredicate);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Tristate hasPermission(@Nonnull Node node) {
|
||||
public @NonNull Tristate hasPermission(@NonNull Node node) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
return this.handle.hasPermission(NodeMapType.ENDURING, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Tristate hasTransientPermission(@Nonnull Node node) {
|
||||
public @NonNull Tristate hasTransientPermission(@NonNull Node node) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
return this.handle.hasPermission(NodeMapType.TRANSIENT, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Tristate inheritsPermission(@Nonnull Node node) {
|
||||
public @NonNull Tristate inheritsPermission(@NonNull Node node) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
return this.handle.inheritsPermission(node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inheritsGroup(@Nonnull me.lucko.luckperms.api.Group group) {
|
||||
public boolean inheritsGroup(me.lucko.luckperms.api.@NonNull Group group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
|
||||
Group g = ApiGroup.cast(group);
|
||||
@@ -245,7 +225,7 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inheritsGroup(@Nonnull me.lucko.luckperms.api.Group group, @Nonnull ContextSet contextSet) {
|
||||
public boolean inheritsGroup(me.lucko.luckperms.api.@NonNull Group group, @NonNull ContextSet contextSet) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
|
||||
@@ -257,52 +237,46 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
||||
return this.handle.hasPermission(NodeMapType.ENDURING, NodeFactory.buildGroupNode(g.getName()).withExtraContext(contextSet).build(), StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE).asBoolean();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DataMutateResult setPermission(@Nonnull Node node) {
|
||||
public @NonNull DataMutateResult setPermission(@NonNull Node node) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
return this.handle.setPermission(node);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TemporaryDataMutateResult setPermission(@Nonnull Node node, @Nonnull TemporaryMergeBehaviour temporaryMergeBehaviour) {
|
||||
public @NonNull TemporaryDataMutateResult setPermission(@NonNull Node node, @NonNull TemporaryMergeBehaviour temporaryMergeBehaviour) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
Objects.requireNonNull(temporaryMergeBehaviour, "temporaryMergeBehaviour");
|
||||
return this.handle.setPermission(node, temporaryMergeBehaviour);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DataMutateResult setTransientPermission(@Nonnull Node node) {
|
||||
public @NonNull DataMutateResult setTransientPermission(@NonNull Node node) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
return this.handle.setTransientPermission(node);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TemporaryDataMutateResult setTransientPermission(@Nonnull Node node, @Nonnull TemporaryMergeBehaviour temporaryMergeBehaviour) {
|
||||
public @NonNull TemporaryDataMutateResult setTransientPermission(@NonNull Node node, @NonNull TemporaryMergeBehaviour temporaryMergeBehaviour) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
Objects.requireNonNull(temporaryMergeBehaviour, "temporaryMergeBehaviour");
|
||||
return this.handle.setTransientPermission(node, temporaryMergeBehaviour);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DataMutateResult unsetPermission(@Nonnull Node node) {
|
||||
public @NonNull DataMutateResult unsetPermission(@NonNull Node node) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
return this.handle.unsetPermission(node);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DataMutateResult unsetTransientPermission(@Nonnull Node node) {
|
||||
public @NonNull DataMutateResult unsetTransientPermission(@NonNull Node node) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
return this.handle.unsetTransientPermission(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearMatching(@Nonnull Predicate<Node> test) {
|
||||
public void clearMatching(@NonNull Predicate<Node> test) {
|
||||
Objects.requireNonNull(test, "test");
|
||||
this.handle.removeIf(test);
|
||||
if (this.handle.getType().isUser()) {
|
||||
@@ -311,7 +285,7 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearMatchingTransient(@Nonnull Predicate<Node> test) {
|
||||
public void clearMatchingTransient(@NonNull Predicate<Node> test) {
|
||||
Objects.requireNonNull(test, "test");
|
||||
this.handle.removeIfTransient(test);
|
||||
}
|
||||
@@ -322,7 +296,7 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearNodes(@Nonnull ContextSet contextSet) {
|
||||
public void clearNodes(@NonNull ContextSet contextSet) {
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
this.handle.clearNodes(contextSet);
|
||||
}
|
||||
@@ -333,7 +307,7 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearParents(@Nonnull ContextSet contextSet) {
|
||||
public void clearParents(@NonNull ContextSet contextSet) {
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
this.handle.clearParents(contextSet, true);
|
||||
}
|
||||
@@ -344,7 +318,7 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearMeta(@Nonnull ContextSet contextSet) {
|
||||
public void clearMeta(@NonNull ContextSet contextSet) {
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
this.handle.clearMeta(MetaType.ANY, contextSet);
|
||||
}
|
||||
@@ -354,28 +328,24 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
||||
this.handle.clearTransientNodes();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<LocalizedNode> resolveInheritances(@Nonnull Contexts contexts) {
|
||||
public @NonNull List<LocalizedNode> resolveInheritances(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
return ImmutableList.copyOf(this.handle.resolveInheritances(contexts));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<LocalizedNode> resolveInheritances() {
|
||||
public @NonNull List<LocalizedNode> resolveInheritances() {
|
||||
return ImmutableList.copyOf(this.handle.resolveInheritances());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<Node> getPermanentPermissionNodes() {
|
||||
public @NonNull Set<Node> getPermanentPermissionNodes() {
|
||||
return this.handle.getOwnNodes().stream().filter(Node::isPermanent).collect(ImmutableCollectors.toSet());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<Node> getTemporaryPermissionNodes() {
|
||||
public @NonNull Set<Node> getTemporaryPermissionNodes() {
|
||||
return this.handle.getOwnNodes().stream().filter(Node::isPrefix).collect(ImmutableCollectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
+25
-48
@@ -39,6 +39,8 @@ import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.storage.Storage;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@@ -48,8 +50,6 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static me.lucko.luckperms.common.api.ApiUtils.checkName;
|
||||
import static me.lucko.luckperms.common.api.ApiUtils.checkUsername;
|
||||
|
||||
@@ -78,9 +78,8 @@ public class ApiStorage implements me.lucko.luckperms.api.Storage {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NonNull String getName() {
|
||||
return this.handle.getName();
|
||||
}
|
||||
|
||||
@@ -89,36 +88,31 @@ public class ApiStorage implements me.lucko.luckperms.api.Storage {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Executor getSyncExecutor() {
|
||||
public @NonNull Executor getSyncExecutor() {
|
||||
return this.plugin.getBootstrap().getScheduler().sync();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Executor getAsyncExecutor() {
|
||||
public @NonNull Executor getAsyncExecutor() {
|
||||
return this.plugin.getBootstrap().getScheduler().async();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> logAction(@Nonnull LogEntry entry) {
|
||||
public @NonNull CompletableFuture<Boolean> logAction(@NonNull LogEntry entry) {
|
||||
Objects.requireNonNull(entry, "entry");
|
||||
return this.handle.logAction(entry)
|
||||
.thenApply(r -> true)
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Log> getLog() {
|
||||
public @NonNull CompletableFuture<Log> getLog() {
|
||||
return this.handle.getLog().<Log>thenApply(ApiLog::new).exceptionally(consumeExceptionToNull());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadUser(@Nonnull UUID uuid, String username) {
|
||||
public @NonNull CompletableFuture<Boolean> loadUser(@NonNull UUID uuid, String username) {
|
||||
Objects.requireNonNull(uuid, "uuid");
|
||||
username = checkUsername(username);
|
||||
|
||||
@@ -131,66 +125,58 @@ public class ApiStorage implements me.lucko.luckperms.api.Storage {
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveUser(@Nonnull User user) {
|
||||
public @NonNull CompletableFuture<Boolean> saveUser(@NonNull User user) {
|
||||
Objects.requireNonNull(user, "user");
|
||||
return this.handle.saveUser(ApiUser.cast(user))
|
||||
.thenApply(r -> true)
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Set<UUID>> getUniqueUsers() {
|
||||
public @NonNull CompletableFuture<Set<UUID>> getUniqueUsers() {
|
||||
return this.handle.getUniqueUsers().exceptionally(consumeExceptionToNull());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@Nonnull String permission) {
|
||||
public @NonNull CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@NonNull String permission) {
|
||||
Objects.requireNonNull(permission, "permission");
|
||||
return this.handle.getUsersWithPermission(Constraint.of(StandardComparison.EQUAL, permission)).exceptionally(consumeExceptionToNull());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> createAndLoadGroup(@Nonnull String name) {
|
||||
public @NonNull CompletableFuture<Boolean> createAndLoadGroup(@NonNull String name) {
|
||||
Objects.requireNonNull(name, "name");
|
||||
return this.handle.createAndLoadGroup(checkName(name), CreationCause.API)
|
||||
.thenApply(r -> true)
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadGroup(@Nonnull String name) {
|
||||
public @NonNull CompletableFuture<Boolean> loadGroup(@NonNull String name) {
|
||||
Objects.requireNonNull(name, "name");
|
||||
return this.handle.loadGroup(checkName(name))
|
||||
.thenApply(Optional::isPresent)
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadAllGroups() {
|
||||
public @NonNull CompletableFuture<Boolean> loadAllGroups() {
|
||||
return this.handle.loadAllGroups()
|
||||
.thenApply(r -> true)
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveGroup(@Nonnull Group group) {
|
||||
public @NonNull CompletableFuture<Boolean> saveGroup(@NonNull Group group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
return this.handle.saveGroup(ApiGroup.cast(group))
|
||||
.thenApply(r -> true)
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> deleteGroup(@Nonnull Group group) {
|
||||
public @NonNull CompletableFuture<Boolean> deleteGroup(@NonNull Group group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
if (group.getName().equalsIgnoreCase(NodeFactory.DEFAULT_GROUP_NAME)) {
|
||||
throw new IllegalArgumentException("Cannot delete the default group.");
|
||||
@@ -200,60 +186,53 @@ public class ApiStorage implements me.lucko.luckperms.api.Storage {
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@Nonnull String permission) {
|
||||
public @NonNull CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@NonNull String permission) {
|
||||
Objects.requireNonNull(permission, "permission");
|
||||
return this.handle.getGroupsWithPermission(Constraint.of(StandardComparison.EQUAL, permission)).exceptionally(consumeExceptionToNull());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> createAndLoadTrack(@Nonnull String name) {
|
||||
public @NonNull CompletableFuture<Boolean> createAndLoadTrack(@NonNull String name) {
|
||||
Objects.requireNonNull(name, "name");
|
||||
return this.handle.createAndLoadTrack(checkName(name), CreationCause.API)
|
||||
.thenApply(r -> true)
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadTrack(@Nonnull String name) {
|
||||
public @NonNull CompletableFuture<Boolean> loadTrack(@NonNull String name) {
|
||||
Objects.requireNonNull(name, "name");
|
||||
return this.handle.loadTrack(checkName(name))
|
||||
.thenApply(Optional::isPresent)
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadAllTracks() {
|
||||
public @NonNull CompletableFuture<Boolean> loadAllTracks() {
|
||||
return this.handle.loadAllTracks()
|
||||
.thenApply(r -> true)
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveTrack(@Nonnull Track track) {
|
||||
public @NonNull CompletableFuture<Boolean> saveTrack(@NonNull Track track) {
|
||||
Objects.requireNonNull(track, "track");
|
||||
return this.handle.saveTrack(ApiTrack.cast(track))
|
||||
.thenApply(r -> true)
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> deleteTrack(@Nonnull Track track) {
|
||||
public @NonNull CompletableFuture<Boolean> deleteTrack(@NonNull Track track) {
|
||||
Objects.requireNonNull(track, "track");
|
||||
return this.handle.deleteTrack(ApiTrack.cast(track), DeletionCause.API)
|
||||
.thenApply(r -> true)
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveUUIDData(@Nonnull String username, @Nonnull UUID uuid) {
|
||||
public @NonNull CompletableFuture<Boolean> saveUUIDData(@NonNull String username, @NonNull UUID uuid) {
|
||||
Objects.requireNonNull(username, "username");
|
||||
Objects.requireNonNull(uuid, "uuid");
|
||||
return this.handle.savePlayerData(uuid, checkUsername(username))
|
||||
@@ -261,16 +240,14 @@ public class ApiStorage implements me.lucko.luckperms.api.Storage {
|
||||
.exceptionally(consumeExceptionToFalse());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<UUID> getUUID(@Nonnull String username) {
|
||||
public @NonNull CompletableFuture<UUID> getUUID(@NonNull String username) {
|
||||
Objects.requireNonNull(username, "username");
|
||||
return this.handle.getPlayerUuid(checkUsername(username));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<String> getName(@Nonnull UUID uuid) {
|
||||
public @NonNull CompletableFuture<String> getName(@NonNull UUID uuid) {
|
||||
Objects.requireNonNull(uuid, "uuid");
|
||||
return this.handle.getPlayerName(uuid);
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class ApiTrack implements me.lucko.luckperms.api.Track {
|
||||
public static Track cast(me.lucko.luckperms.api.Track track) {
|
||||
Objects.requireNonNull(track, "track");
|
||||
@@ -58,15 +58,13 @@ public final class ApiTrack implements me.lucko.luckperms.api.Track {
|
||||
return this.handle;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NonNull String getName() {
|
||||
return this.handle.getName();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> getGroups() {
|
||||
public @NonNull List<String> getGroups() {
|
||||
return this.handle.getGroups();
|
||||
}
|
||||
|
||||
@@ -76,7 +74,7 @@ public final class ApiTrack implements me.lucko.luckperms.api.Track {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNext(@Nonnull Group current) {
|
||||
public String getNext(@NonNull Group current) {
|
||||
Objects.requireNonNull(current, "current");
|
||||
try {
|
||||
return this.handle.getNext(ApiGroup.cast(current));
|
||||
@@ -86,7 +84,7 @@ public final class ApiTrack implements me.lucko.luckperms.api.Track {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrevious(@Nonnull Group current) {
|
||||
public String getPrevious(@NonNull Group current) {
|
||||
Objects.requireNonNull(current, "current");
|
||||
try {
|
||||
return this.handle.getPrevious(ApiGroup.cast(current));
|
||||
@@ -95,54 +93,48 @@ public final class ApiTrack implements me.lucko.luckperms.api.Track {
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public PromotionResult promote(@Nonnull User user, @Nonnull ContextSet contextSet) {
|
||||
public @NonNull PromotionResult promote(@NonNull User user, @NonNull ContextSet contextSet) {
|
||||
return this.handle.promote(ApiUser.cast(user), contextSet, Predicates.alwaysTrue(), null, true);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DemotionResult demote(@Nonnull User user, @Nonnull ContextSet contextSet) {
|
||||
public @NonNull DemotionResult demote(@NonNull User user, @NonNull ContextSet contextSet) {
|
||||
return this.handle.demote(ApiUser.cast(user), contextSet, Predicates.alwaysTrue(), null, true);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DataMutateResult appendGroup(@Nonnull Group group) {
|
||||
public @NonNull DataMutateResult appendGroup(@NonNull Group group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
return this.handle.appendGroup(ApiGroup.cast(group));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DataMutateResult insertGroup(@Nonnull Group group, int position) throws IndexOutOfBoundsException {
|
||||
public @NonNull DataMutateResult insertGroup(@NonNull Group group, int position) throws IndexOutOfBoundsException {
|
||||
Objects.requireNonNull(group, "group");
|
||||
return this.handle.insertGroup(ApiGroup.cast(group), position);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DataMutateResult removeGroup(@Nonnull Group group) {
|
||||
public @NonNull DataMutateResult removeGroup(@NonNull Group group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
return this.handle.removeGroup(ApiGroup.cast(group));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DataMutateResult removeGroup(@Nonnull String group) {
|
||||
public @NonNull DataMutateResult removeGroup(@NonNull String group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
return this.handle.removeGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsGroup(@Nonnull Group group) {
|
||||
public boolean containsGroup(@NonNull Group group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
return this.handle.containsGroup(ApiGroup.cast(group));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsGroup(@Nonnull String group) {
|
||||
public boolean containsGroup(@NonNull String group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
return this.handle.containsGroup(group);
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ import me.lucko.luckperms.common.model.NodeMapType;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class ApiUser extends ApiPermissionHolder implements me.lucko.luckperms.api.User {
|
||||
public static User cast(me.lucko.luckperms.api.User u) {
|
||||
Preconditions.checkState(u instanceof ApiUser, "Illegal instance " + u.getClass() + " cannot be handled by this implementation.");
|
||||
@@ -57,9 +57,8 @@ public final class ApiUser extends ApiPermissionHolder implements me.lucko.luckp
|
||||
return this.handle;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
public @NonNull UUID getUuid() {
|
||||
return this.handle.getUuid();
|
||||
}
|
||||
|
||||
@@ -68,15 +67,13 @@ public final class ApiUser extends ApiPermissionHolder implements me.lucko.luckp
|
||||
return this.handle.getName().orElse(null);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getPrimaryGroup() {
|
||||
public @NonNull String getPrimaryGroup() {
|
||||
return this.handle.getPrimaryGroup().getValue();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DataMutateResult setPrimaryGroup(@Nonnull String group) {
|
||||
public @NonNull DataMutateResult setPrimaryGroup(@NonNull String group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
if (getPrimaryGroup().equalsIgnoreCase(group)) {
|
||||
return DataMutateResult.ALREADY_HAS;
|
||||
@@ -90,9 +87,8 @@ public final class ApiUser extends ApiPermissionHolder implements me.lucko.luckp
|
||||
return DataMutateResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UserData getCachedData() {
|
||||
public @NonNull UserData getCachedData() {
|
||||
return this.handle.getCachedData();
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public abstract class BufferedRequest<T> {
|
||||
private final long delay;
|
||||
private final TimeUnit unit;
|
||||
|
||||
private SchedulerAdapter schedulerAdapter;
|
||||
private final SchedulerAdapter schedulerAdapter;
|
||||
private SchedulerTask task;
|
||||
|
||||
private final Object[] mutex = new Object[0];
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
|
||||
package me.lucko.luckperms.common.buffers;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Simple one element cache implementation.
|
||||
@@ -37,8 +37,7 @@ import javax.annotation.Nonnull;
|
||||
public abstract class Cache<T> {
|
||||
private volatile T value = null;
|
||||
|
||||
@Nonnull
|
||||
protected abstract T supply();
|
||||
protected abstract @NonNull T supply();
|
||||
|
||||
public final T get() {
|
||||
T val = this.value;
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
|
||||
package me.lucko.luckperms.common.buffers;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* An expiring supplier extension.
|
||||
*
|
||||
@@ -50,8 +50,7 @@ public abstract class ExpiringCache<T> implements Supplier<T> {
|
||||
this.durationNanos = unit.toNanos(duration);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected abstract T supply();
|
||||
protected abstract @NonNull T supply();
|
||||
|
||||
@Override
|
||||
public T get() {
|
||||
|
||||
@@ -136,7 +136,7 @@ public final class BulkUpdate {
|
||||
if (!(o instanceof BulkUpdate)) return false;
|
||||
final BulkUpdate that = (BulkUpdate) o;
|
||||
|
||||
return Objects.equals(this.getDataType(), that.getDataType()) &&
|
||||
return this.getDataType() == that.getDataType() &&
|
||||
Objects.equals(this.getAction(), that.getAction()) &&
|
||||
Objects.equals(this.getQueries(), that.getQueries());
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public interface Action {
|
||||
*
|
||||
* Will include a placeholder for the table, as "{table}".
|
||||
*
|
||||
* @return the action in sql form
|
||||
* @param builder the statement builder
|
||||
*/
|
||||
void appendSql(PreparedStatementBuilder builder);
|
||||
|
||||
|
||||
@@ -43,15 +43,15 @@ import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
||||
import me.lucko.luckperms.common.metastacking.SimpleMetaStack;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Abstract implementation of {@link CachedData}.
|
||||
*/
|
||||
@@ -184,73 +184,66 @@ public abstract class AbstractCachedData implements CachedData {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final PermissionCache getPermissionData(@Nonnull Contexts contexts) {
|
||||
public final @NonNull PermissionCache getPermissionData(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
|
||||
//noinspection ConstantConditions
|
||||
return this.permission.synchronous().get(contexts);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final MetaCache getMetaData(@Nonnull MetaContexts contexts) {
|
||||
public final @NonNull MetaCache getMetaData(@NonNull MetaContexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
|
||||
//noinspection ConstantConditions
|
||||
return this.meta.synchronous().get(contexts);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final MetaCache getMetaData(@Nonnull Contexts contexts) {
|
||||
public final @NonNull MetaCache getMetaData(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
return getMetaData(getDefaultMetaContexts(contexts));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final PermissionCache calculatePermissions(@Nonnull Contexts contexts) {
|
||||
public final @NonNull PermissionCache calculatePermissions(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
return calculatePermissions(contexts, null);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final MetaCache calculateMeta(@Nonnull MetaContexts contexts) {
|
||||
public final @NonNull MetaCache calculateMeta(@NonNull MetaContexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
return calculateMeta(contexts, null);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final MetaCache calculateMeta(@Nonnull Contexts contexts) {
|
||||
public final @NonNull MetaCache calculateMeta(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
return calculateMeta(getDefaultMetaContexts(contexts));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void recalculatePermissions(@Nonnull Contexts contexts) {
|
||||
public final void recalculatePermissions(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
this.permission.synchronous().refresh(contexts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void recalculateMeta(@Nonnull MetaContexts contexts) {
|
||||
public final void recalculateMeta(@NonNull MetaContexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
this.meta.synchronous().refresh(contexts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void recalculateMeta(@Nonnull Contexts contexts) {
|
||||
public final void recalculateMeta(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
recalculateMeta(getDefaultMetaContexts(contexts));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final CompletableFuture<PermissionCache> reloadPermissions(@Nonnull Contexts contexts) {
|
||||
public final @NonNull CompletableFuture<PermissionCache> reloadPermissions(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
|
||||
// get the previous value - to use when recalculating
|
||||
@@ -269,9 +262,8 @@ public abstract class AbstractCachedData implements CachedData {
|
||||
return this.permission.get(contexts);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final CompletableFuture<MetaCache> reloadMeta(@Nonnull MetaContexts contexts) {
|
||||
public final @NonNull CompletableFuture<MetaCache> reloadMeta(@NonNull MetaContexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
|
||||
// get the previous value - to use when recalculating
|
||||
@@ -290,9 +282,8 @@ public abstract class AbstractCachedData implements CachedData {
|
||||
return this.meta.get(contexts);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final CompletableFuture<MetaCache> reloadMeta(@Nonnull Contexts contexts) {
|
||||
public final @NonNull CompletableFuture<MetaCache> reloadMeta(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
return reloadMeta(getDefaultMetaContexts(contexts));
|
||||
}
|
||||
@@ -309,34 +300,32 @@ public abstract class AbstractCachedData implements CachedData {
|
||||
keys.forEach(this::recalculateMeta);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final CompletableFuture<Void> reloadPermissions() {
|
||||
public final @NonNull CompletableFuture<Void> reloadPermissions() {
|
||||
Set<Contexts> keys = this.permission.synchronous().asMap().keySet();
|
||||
return CompletableFuture.allOf(keys.stream().map(this::reloadPermissions).toArray(CompletableFuture[]::new));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final CompletableFuture<Void> reloadMeta() {
|
||||
public final @NonNull CompletableFuture<Void> reloadMeta() {
|
||||
Set<MetaContexts> keys = this.meta.synchronous().asMap().keySet();
|
||||
return CompletableFuture.allOf(keys.stream().map(this::reloadMeta).toArray(CompletableFuture[]::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void invalidatePermissions(@Nonnull Contexts contexts) {
|
||||
public final void invalidatePermissions(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
this.permission.synchronous().invalidate(contexts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void invalidateMeta(@Nonnull MetaContexts contexts) {
|
||||
public final void invalidateMeta(@NonNull MetaContexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
this.meta.synchronous().invalidate(contexts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void invalidateMeta(@Nonnull Contexts contexts) {
|
||||
public final void invalidateMeta(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
this.meta.synchronous().invalidate(getDefaultMetaContexts(contexts));
|
||||
}
|
||||
@@ -379,24 +368,24 @@ public abstract class AbstractCachedData implements CachedData {
|
||||
|
||||
private final class PermissionCacheLoader implements CacheLoader<Contexts, PermissionCache> {
|
||||
@Override
|
||||
public PermissionCache load(@Nonnull Contexts contexts) {
|
||||
public PermissionCache load(@NonNull Contexts contexts) {
|
||||
return calculatePermissions(contexts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionCache reload(@Nonnull Contexts contexts, @Nonnull PermissionCache oldData) {
|
||||
public PermissionCache reload(@NonNull Contexts contexts, @NonNull PermissionCache oldData) {
|
||||
return calculatePermissions(contexts, oldData);
|
||||
}
|
||||
}
|
||||
|
||||
private final class MetaCacheLoader implements CacheLoader<MetaContexts, MetaCache> {
|
||||
@Override
|
||||
public MetaCache load(@Nonnull MetaContexts contexts) {
|
||||
public MetaCache load(@NonNull MetaContexts contexts) {
|
||||
return calculateMeta(contexts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaCache reload(@Nonnull MetaContexts contexts, @Nonnull MetaCache oldData) {
|
||||
public MetaCache reload(@NonNull MetaContexts contexts, @NonNull MetaCache oldData) {
|
||||
return calculateMeta(contexts, oldData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ import me.lucko.luckperms.api.caching.MetaData;
|
||||
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
||||
import me.lucko.luckperms.common.metastacking.MetaStack;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Holds cached meta for a given context
|
||||
*/
|
||||
@@ -100,51 +100,43 @@ public class MetaCache implements MetaData {
|
||||
return suffixStack == null ? null : suffixStack.toFormattedString();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public MetaStackDefinition getPrefixStackDefinition() {
|
||||
public @NonNull MetaStackDefinition getPrefixStackDefinition() {
|
||||
return this.prefixStack.getDefinition();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public MetaStackDefinition getSuffixStackDefinition() {
|
||||
public @NonNull MetaStackDefinition getSuffixStackDefinition() {
|
||||
return this.suffixStack.getDefinition();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Contexts getContexts() {
|
||||
public @NonNull Contexts getContexts() {
|
||||
return this.metaContexts.getContexts();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public MetaContexts getMetaContexts() {
|
||||
public @NonNull MetaContexts getMetaContexts() {
|
||||
return this.metaContexts;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ListMultimap<String, String> getMetaMultimap() {
|
||||
public @NonNull ListMultimap<String, String> getMetaMultimap() {
|
||||
return this.metaMultimap;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Map<String, String> getMeta() {
|
||||
public @NonNull Map<String, String> getMeta() {
|
||||
return this.meta;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public SortedMap<Integer, String> getPrefixes() {
|
||||
public @NonNull SortedMap<Integer, String> getPrefixes() {
|
||||
return this.prefixes;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public SortedMap<Integer, String> getSuffixes() {
|
||||
public @NonNull SortedMap<Integer, String> getSuffixes() {
|
||||
return this.suffixes;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Holds cached permissions data for a given context
|
||||
*/
|
||||
@@ -97,15 +97,13 @@ public class PermissionCache implements PermissionData {
|
||||
return this.calculator;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Map<String, Boolean> getImmutableBacking() {
|
||||
public @NonNull Map<String, Boolean> getImmutableBacking() {
|
||||
return this.permissionsUnmodifiable;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Tristate getPermissionValue(@Nonnull String permission) {
|
||||
public @NonNull Tristate getPermissionValue(@NonNull String permission) {
|
||||
if (permission == null) {
|
||||
throw new NullPointerException("permission");
|
||||
}
|
||||
@@ -119,9 +117,8 @@ public class PermissionCache implements PermissionData {
|
||||
return this.calculator.getPermissionValue(permission, origin);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Contexts getContexts() {
|
||||
public @NonNull Contexts getContexts() {
|
||||
return this.contexts;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -35,11 +35,11 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Calculates and caches permissions
|
||||
*/
|
||||
@@ -96,7 +96,7 @@ public class PermissionCalculator implements CacheLoader<String, Tristate> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tristate load(@Nonnull String permission) {
|
||||
public Tristate load(@NonNull String permission) {
|
||||
// offer the permission to the permission vault
|
||||
// we only need to do this once per permission, so it doesn't matter
|
||||
// that this call is behind the cache.
|
||||
|
||||
@@ -174,7 +174,7 @@ public class CommandManager {
|
||||
if (this.mainCommands.stream().anyMatch(c -> c.shouldDisplay() && c.isAuthorized(sender))) {
|
||||
Message.VIEW_AVAILABLE_COMMANDS_PROMPT.send(sender, label);
|
||||
} else {
|
||||
Collection<? extends Group> groups = plugin.getGroupManager().getAll().values();
|
||||
Collection<? extends Group> groups = this.plugin.getGroupManager().getAll().values();
|
||||
if (groups.size() <= 1 && groups.stream().allMatch(g -> g.getOwnNodes().isEmpty())) {
|
||||
Message.FIRST_TIME_SETUP.send(sender, label, sender.getName());
|
||||
} else {
|
||||
|
||||
@@ -35,14 +35,14 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An abstract command class
|
||||
*
|
||||
@@ -56,34 +56,29 @@ public abstract class Command<T, S> {
|
||||
*
|
||||
* Contains details about usage, description, etc
|
||||
*/
|
||||
@Nonnull
|
||||
private final LocalizedCommandSpec spec;
|
||||
private final @NonNull LocalizedCommandSpec spec;
|
||||
|
||||
/**
|
||||
* The name of the command. Should be properly capitalised.
|
||||
*/
|
||||
@Nonnull
|
||||
private final String name;
|
||||
private final @NonNull String name;
|
||||
|
||||
/**
|
||||
* The permission required to use this command. Nullable.
|
||||
*/
|
||||
@Nullable
|
||||
private final CommandPermission permission;
|
||||
private final @Nullable CommandPermission permission;
|
||||
|
||||
/**
|
||||
* A predicate used for testing the size of the arguments list passed to this command
|
||||
*/
|
||||
@Nonnull
|
||||
private Predicate<Integer> argumentCheck = Predicates.alwaysFalse();
|
||||
private final @NonNull Predicate<Integer> argumentCheck;
|
||||
|
||||
/**
|
||||
* Child commands. Nullable.
|
||||
*/
|
||||
@Nullable
|
||||
private final List<Command<S, ?>> children;
|
||||
private final @Nullable List<Command<S, ?>> children;
|
||||
|
||||
public Command(@Nonnull LocalizedCommandSpec spec, @Nonnull String name, @Nullable CommandPermission permission, @Nonnull Predicate<Integer> argumentCheck, @Nullable List<Command<S, ?>> children) {
|
||||
public Command(@NonNull LocalizedCommandSpec spec, @NonNull String name, @Nullable CommandPermission permission, @NonNull Predicate<Integer> argumentCheck, @Nullable List<Command<S, ?>> children) {
|
||||
this.spec = spec;
|
||||
this.name = name;
|
||||
this.permission = permission;
|
||||
@@ -91,11 +86,11 @@ public abstract class Command<T, S> {
|
||||
this.children = children == null ? null : ImmutableList.copyOf(children);
|
||||
}
|
||||
|
||||
public Command(@Nonnull LocalizedCommandSpec spec, @Nonnull String name, @Nullable CommandPermission permission, @Nonnull Predicate<Integer> argumentCheck) {
|
||||
public Command(@NonNull LocalizedCommandSpec spec, @NonNull String name, @Nullable CommandPermission permission, @NonNull Predicate<Integer> argumentCheck) {
|
||||
this(spec, name, permission, argumentCheck, null);
|
||||
}
|
||||
|
||||
public Command(@Nonnull LocalizedCommandSpec spec, @Nonnull String name, @Nonnull Predicate<Integer> argumentCheck) {
|
||||
public Command(@NonNull LocalizedCommandSpec spec, @NonNull String name, @NonNull Predicate<Integer> argumentCheck) {
|
||||
this(spec, name, null, argumentCheck, null);
|
||||
}
|
||||
|
||||
@@ -104,8 +99,7 @@ public abstract class Command<T, S> {
|
||||
*
|
||||
* @return the command spec
|
||||
*/
|
||||
@Nonnull
|
||||
public LocalizedCommandSpec getSpec() {
|
||||
public @NonNull LocalizedCommandSpec getSpec() {
|
||||
return this.spec;
|
||||
}
|
||||
|
||||
@@ -116,8 +110,7 @@ public abstract class Command<T, S> {
|
||||
*
|
||||
* @return the command name
|
||||
*/
|
||||
@Nonnull
|
||||
public String getName() {
|
||||
public @NonNull String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -126,8 +119,7 @@ public abstract class Command<T, S> {
|
||||
*
|
||||
* @return the command permission
|
||||
*/
|
||||
@Nonnull
|
||||
public Optional<CommandPermission> getPermission() {
|
||||
public @NonNull Optional<CommandPermission> getPermission() {
|
||||
return Optional.ofNullable(this.permission);
|
||||
}
|
||||
|
||||
@@ -137,8 +129,7 @@ public abstract class Command<T, S> {
|
||||
*
|
||||
* @return the argument checking predicate
|
||||
*/
|
||||
@Nonnull
|
||||
public Predicate<Integer> getArgumentCheck() {
|
||||
public @NonNull Predicate<Integer> getArgumentCheck() {
|
||||
return this.argumentCheck;
|
||||
}
|
||||
|
||||
@@ -147,8 +138,7 @@ public abstract class Command<T, S> {
|
||||
*
|
||||
* @return any child commands
|
||||
*/
|
||||
@Nonnull
|
||||
public Optional<List<Command<S, ?>>> getChildren() {
|
||||
public @NonNull Optional<List<Command<S, ?>>> getChildren() {
|
||||
return Optional.ofNullable(this.children);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -40,8 +42,6 @@ import java.util.Optional;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class MainCommand<T, I> extends Command<Void, T> {
|
||||
|
||||
// equals 1 if the command doesn't take a mid argument, e.g. /lp log sub-command....
|
||||
@@ -189,9 +189,8 @@ public abstract class MainCommand<T, I> extends Command<Void, T> {
|
||||
return getChildren().get().stream().anyMatch(sc -> sc.isAuthorized(sender));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<List<Command<T, ?>>> getChildren() {
|
||||
public @NonNull Optional<List<Command<T, ?>>> getChildren() {
|
||||
return super.getChildren();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class TabCompleter {
|
||||
* @return this
|
||||
*/
|
||||
public TabCompleter at(int position, CompletionSupplier supplier) {
|
||||
Preconditions.checkState(position < from);
|
||||
Preconditions.checkState(position < this.from);
|
||||
this.suppliers.put(position, supplier);
|
||||
return this;
|
||||
}
|
||||
|
||||
+3
-4
@@ -38,6 +38,8 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -45,8 +47,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class MigrationMainCommand extends MainCommand<Object, Object> {
|
||||
private static final Map<String, String> PLUGINS = ImmutableBiMap.<String, String>builder()
|
||||
// bukkit
|
||||
@@ -68,9 +68,8 @@ public class MigrationMainCommand extends MainCommand<Object, Object> {
|
||||
super(CommandSpec.MIGRATION.localize(locale), "Migration", 1, null);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public synchronized Optional<List<Command<Object, ?>>> getChildren() {
|
||||
public synchronized @NonNull Optional<List<Command<Object, ?>>> getChildren() {
|
||||
if (this.commands == null) {
|
||||
this.commands = getAvailableCommands(getSpec().getLocaleManager());
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ import me.lucko.luckperms.common.buffers.ExpiringCache;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -45,8 +47,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Base implementation of {@link ContextManager} which caches content lookups.
|
||||
*
|
||||
@@ -271,9 +271,8 @@ public abstract class ContextManager<T> {
|
||||
super(50L, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Contexts supply() {
|
||||
public @NonNull Contexts supply() {
|
||||
return calculateStatic();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||
import me.lucko.luckperms.common.buffers.ExpiringCache;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ContextsSupplier} that caches results.
|
||||
@@ -48,9 +48,8 @@ public final class ContextsCache<T> extends ExpiringCache<Contexts> implements C
|
||||
this.contextManager = contextManager;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected Contexts supply() {
|
||||
protected @NonNull Contexts supply() {
|
||||
return this.contextManager.calculate(this.subject);
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -31,7 +31,7 @@ import me.lucko.luckperms.api.context.StaticContextCalculator;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class LPStaticContextsCalculator implements StaticContextCalculator {
|
||||
private final LuckPermsConfiguration config;
|
||||
@@ -40,9 +40,8 @@ public class LPStaticContextsCalculator implements StaticContextCalculator {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public MutableContextSet giveApplicableContext(@Nonnull MutableContextSet accumulator) {
|
||||
public @NonNull MutableContextSet giveApplicableContext(@NonNull MutableContextSet accumulator) {
|
||||
String server = this.config.get(ConfigKeys.SERVER);
|
||||
if (!server.equals("global")) {
|
||||
accumulator.add(Contexts.SERVER_KEY, server);
|
||||
|
||||
@@ -34,13 +34,13 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import net.kyori.event.EventSubscriber;
|
||||
import net.kyori.event.SimpleEventBus;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
||||
|
||||
/**
|
||||
@@ -88,17 +88,15 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
||||
return this.bus.hasSubscribers(eventClass);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T extends LuckPermsEvent> EventHandler<T> subscribe(@Nonnull Class<T> eventClass, @Nonnull Consumer<? super T> handler) {
|
||||
public @NonNull <T extends LuckPermsEvent> EventHandler<T> subscribe(@NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler) {
|
||||
Objects.requireNonNull(eventClass, "eventClass");
|
||||
Objects.requireNonNull(handler, "handler");
|
||||
return registerSubscription(eventClass, handler, null);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T extends LuckPermsEvent> EventHandler<T> subscribe(Object plugin, @Nonnull Class<T> eventClass, @Nonnull Consumer<? super T> handler) {
|
||||
public @NonNull <T extends LuckPermsEvent> EventHandler<T> subscribe(Object plugin, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler) {
|
||||
Objects.requireNonNull(plugin, "plugin");
|
||||
Objects.requireNonNull(eventClass, "eventClass");
|
||||
Objects.requireNonNull(handler, "handler");
|
||||
@@ -119,9 +117,8 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
||||
return eventHandler;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(@Nonnull Class<T> eventClass) {
|
||||
public @NonNull <T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(@NonNull Class<T> eventClass) {
|
||||
return this.bus.getHandlers(eventClass);
|
||||
}
|
||||
|
||||
@@ -154,7 +151,7 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldPost(LuckPermsEvent event, EventSubscriber<?> subscriber) {
|
||||
protected boolean shouldPost(@NonNull LuckPermsEvent event, @NonNull EventSubscriber<?> subscriber) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,8 @@ import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -90,8 +92,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class EventFactory {
|
||||
private final AbstractEventBus<?> eventBus;
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@ import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
|
||||
import net.kyori.event.EventSubscriber;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Simple implementation of {@link EventHandler}.
|
||||
*
|
||||
@@ -62,8 +62,7 @@ public class LuckPermsEventHandler<T extends LuckPermsEvent> implements EventHan
|
||||
/**
|
||||
* The plugin which "owns" this handler
|
||||
*/
|
||||
@Nullable
|
||||
private final Object plugin;
|
||||
private final @Nullable Object plugin;
|
||||
|
||||
/**
|
||||
* If this handler is active
|
||||
@@ -104,7 +103,7 @@ public class LuckPermsEventHandler<T extends LuckPermsEvent> implements EventHan
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(T event) throws Throwable {
|
||||
public void invoke(@NonNull T event) throws Throwable {
|
||||
try {
|
||||
this.consumer.accept(event);
|
||||
this.callCount.incrementAndGet();
|
||||
@@ -114,20 +113,17 @@ public class LuckPermsEventHandler<T extends LuckPermsEvent> implements EventHan
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<T> getEventClass() {
|
||||
public @NonNull Class<T> getEventClass() {
|
||||
return this.eventClass;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Consumer<? super T> getConsumer() {
|
||||
public @NonNull Consumer<? super T> getConsumer() {
|
||||
return this.consumer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getPlugin() {
|
||||
public @Nullable Object getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ package me.lucko.luckperms.common.event.model;
|
||||
import me.lucko.luckperms.api.Entity;
|
||||
import me.lucko.luckperms.api.event.source.EntitySource;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class EntitySourceImpl implements EntitySource {
|
||||
private final Entity entity;
|
||||
@@ -37,15 +37,13 @@ public class EntitySourceImpl implements EntitySource {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Entity getEntity() {
|
||||
public @NonNull Entity getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Type getType() {
|
||||
public @NonNull Type getType() {
|
||||
return Type.ENTITY;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ package me.lucko.luckperms.common.event.model;
|
||||
import me.lucko.luckperms.api.Entity;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SenderEntity implements Entity {
|
||||
private final Sender sender;
|
||||
@@ -40,24 +40,21 @@ public class SenderEntity implements Entity {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
public @Nullable UUID getUniqueId() {
|
||||
if (this.sender.isConsole()) {
|
||||
return null;
|
||||
}
|
||||
return this.sender.getUuid();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NonNull String getName() {
|
||||
return this.sender.getName();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Type getType() {
|
||||
public @NonNull Type getType() {
|
||||
if (this.sender.isConsole()) {
|
||||
return Type.CONSOLE;
|
||||
} else {
|
||||
|
||||
@@ -27,7 +27,7 @@ package me.lucko.luckperms.common.event.model;
|
||||
|
||||
import me.lucko.luckperms.api.event.source.Source;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public final class UnknownSource implements Source {
|
||||
public static final Source INSTANCE = new UnknownSource();
|
||||
@@ -36,9 +36,8 @@ public final class UnknownSource implements Source {
|
||||
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Type getType() {
|
||||
public @NonNull Type getType() {
|
||||
return Type.UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class Argument {
|
||||
public static Argument create(String name, boolean required, String description) {
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
|
||||
package me.lucko.luckperms.common.locale.command;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The localized data for a {@link CommandSpec}.
|
||||
*/
|
||||
@@ -44,18 +44,15 @@ public final class CommandSpecData {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
public @Nullable String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getUsage() {
|
||||
public @Nullable String getUsage() {
|
||||
return this.usage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, String> getArgs() {
|
||||
public @Nullable Map<String, String> getArgs() {
|
||||
return this.args;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import me.lucko.luckperms.common.utils.TextUtils;
|
||||
|
||||
import net.kyori.text.TextComponent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* An enumeration of some of the messages used within the plugin.
|
||||
|
||||
@@ -32,9 +32,9 @@ import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import me.lucko.luckperms.common.model.Identifiable;
|
||||
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An abstract manager class
|
||||
@@ -48,12 +48,12 @@ public abstract class AbstractManager<I, C extends Identifiable<I>, T extends C>
|
||||
private final LoadingCache<I, T> objects = Caffeine.newBuilder()
|
||||
.build(new CacheLoader<I, T>() {
|
||||
@Override
|
||||
public T load(@Nonnull I i) {
|
||||
public T load(@NonNull I i) {
|
||||
return apply(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T reload(@Nonnull I i, @Nonnull T t) {
|
||||
public T reload(@NonNull I i, @NonNull T t) {
|
||||
return t; // Never needs to be refreshed.
|
||||
}
|
||||
});
|
||||
|
||||
+5
-5
@@ -48,6 +48,9 @@ import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.utils.gson.JObject;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
@@ -55,9 +58,6 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class LuckPermsMessagingService implements InternalMessagingService, IncomingMessageConsumer {
|
||||
private static final Gson GSON = new GsonBuilder().disableHtmlEscaping().create();
|
||||
|
||||
@@ -143,7 +143,7 @@ public class LuckPermsMessagingService implements InternalMessagingService, Inco
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean consumeIncomingMessage(@Nonnull Message message) {
|
||||
public boolean consumeIncomingMessage(@NonNull Message message) {
|
||||
Objects.requireNonNull(message, "message");
|
||||
|
||||
if (!this.receivedMessages.add(message.getId())) {
|
||||
@@ -167,7 +167,7 @@ public class LuckPermsMessagingService implements InternalMessagingService, Inco
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean consumeIncomingMessageAsString(@Nonnull String encodedString) {
|
||||
public boolean consumeIncomingMessageAsString(@NonNull String encodedString) {
|
||||
Objects.requireNonNull(encodedString, "encodedString");
|
||||
JsonObject decodedObject = GSON.fromJson(encodedString, JsonObject.class).getAsJsonObject();
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import me.lucko.luckperms.common.storage.dao.sql.SqlDao;
|
||||
import me.lucko.luckperms.common.storage.dao.sql.connection.hikari.MariaDbConnectionFactory;
|
||||
import me.lucko.luckperms.common.storage.dao.sql.connection.hikari.MySqlConnectionFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class MessagingFactory<P extends LuckPermsPlugin> {
|
||||
private final P plugin;
|
||||
@@ -103,15 +103,13 @@ public class MessagingFactory<P extends LuckPermsPlugin> {
|
||||
|
||||
private class RedisMessengerProvider implements MessengerProvider {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NonNull String getName() {
|
||||
return "Redis";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Messenger obtain(@Nonnull IncomingMessageConsumer incomingMessageConsumer) {
|
||||
public @NonNull Messenger obtain(@NonNull IncomingMessageConsumer incomingMessageConsumer) {
|
||||
RedisMessenger redis = new RedisMessenger(getPlugin(), incomingMessageConsumer);
|
||||
redis.init(getPlugin().getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getPlugin().getConfiguration().get(ConfigKeys.REDIS_PASSWORD));
|
||||
return redis;
|
||||
@@ -120,15 +118,13 @@ public class MessagingFactory<P extends LuckPermsPlugin> {
|
||||
|
||||
private class SqlMessengerProvider implements MessengerProvider {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NonNull String getName() {
|
||||
return "Sql";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Messenger obtain(@Nonnull IncomingMessageConsumer incomingMessageConsumer) {
|
||||
public @NonNull Messenger obtain(@NonNull IncomingMessageConsumer incomingMessageConsumer) {
|
||||
SqlDao dao = (SqlDao) getPlugin().getStorage().getDao();
|
||||
Preconditions.checkState(dao.getProvider() instanceof MySqlConnectionFactory || dao.getProvider() instanceof MariaDbConnectionFactory, "not a supported sql type");
|
||||
|
||||
|
||||
+3
-4
@@ -28,9 +28,9 @@ package me.lucko.luckperms.common.messaging.message;
|
||||
import me.lucko.luckperms.api.messenger.message.Message;
|
||||
import me.lucko.luckperms.api.messenger.message.OutgoingMessage;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class AbstractMessage implements Message, OutgoingMessage {
|
||||
private final UUID id;
|
||||
@@ -39,9 +39,8 @@ public abstract class AbstractMessage implements Message, OutgoingMessage {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UUID getId() {
|
||||
public @NonNull UUID getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
+6
-8
@@ -32,10 +32,10 @@ import me.lucko.luckperms.api.messenger.message.type.LogMessage;
|
||||
import me.lucko.luckperms.common.actionlog.LogEntryJsonSerializer;
|
||||
import me.lucko.luckperms.common.messaging.LuckPermsMessagingService;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LogMessageImpl extends AbstractMessage implements LogMessage {
|
||||
public static final String TYPE = "log";
|
||||
@@ -55,17 +55,15 @@ public class LogMessageImpl extends AbstractMessage implements LogMessage {
|
||||
this.logEntry = logEntry;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LogEntry getLogEntry() {
|
||||
public @NonNull LogEntry getLogEntry() {
|
||||
return this.logEntry;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String asEncodedString() {
|
||||
public @NonNull String asEncodedString() {
|
||||
return LuckPermsMessagingService.encodeMessageAsString(
|
||||
TYPE, getId(), LogEntryJsonSerializer.serialize(logEntry)
|
||||
TYPE, getId(), LogEntryJsonSerializer.serialize(this.logEntry)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -30,10 +30,10 @@ import com.google.gson.JsonElement;
|
||||
import me.lucko.luckperms.api.messenger.message.type.UpdateMessage;
|
||||
import me.lucko.luckperms.common.messaging.LuckPermsMessagingService;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UpdateMessageImpl extends AbstractMessage implements UpdateMessage {
|
||||
public static final String TYPE = "update";
|
||||
@@ -46,9 +46,8 @@ public class UpdateMessageImpl extends AbstractMessage implements UpdateMessage
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String asEncodedString() {
|
||||
public @NonNull String asEncodedString() {
|
||||
return LuckPermsMessagingService.encodeMessageAsString(TYPE, getId(), null);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-8
@@ -31,10 +31,10 @@ import me.lucko.luckperms.api.messenger.message.type.UserUpdateMessage;
|
||||
import me.lucko.luckperms.common.messaging.LuckPermsMessagingService;
|
||||
import me.lucko.luckperms.common.utils.gson.JObject;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserUpdateMessageImpl extends AbstractMessage implements UserUpdateMessage {
|
||||
public static final String TYPE = "userupdate";
|
||||
@@ -61,17 +61,15 @@ public class UserUpdateMessageImpl extends AbstractMessage implements UserUpdate
|
||||
this.userUuid = userUuid;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UUID getUser() {
|
||||
public @NonNull UUID getUser() {
|
||||
return this.userUuid;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String asEncodedString() {
|
||||
public @NonNull String asEncodedString() {
|
||||
return LuckPermsMessagingService.encodeMessageAsString(
|
||||
TYPE, getId(), new JObject().add("userUuid", userUuid.toString()).toJson()
|
||||
TYPE, getId(), new JObject().add("userUuid", this.userUuid.toString()).toJson()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@ import me.lucko.luckperms.api.messenger.Messenger;
|
||||
import me.lucko.luckperms.api.messenger.message.OutgoingMessage;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* An implementation of {@link Messenger} using Redis.
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ public class RedisMessenger implements Messenger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendOutgoingMessage(@Nonnull OutgoingMessage outgoingMessage) {
|
||||
public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) {
|
||||
try (Jedis jedis = this.jedisPool.getResource()) {
|
||||
jedis.publish(CHANNEL, outgoingMessage.asEncodedString());
|
||||
} catch (Exception e) {
|
||||
|
||||
+3
-3
@@ -29,13 +29,13 @@ import me.lucko.luckperms.api.messenger.IncomingMessageConsumer;
|
||||
import me.lucko.luckperms.api.messenger.Messenger;
|
||||
import me.lucko.luckperms.api.messenger.message.OutgoingMessage;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* An implementation of {@link Messenger} using SQL.
|
||||
*/
|
||||
@@ -69,7 +69,7 @@ public abstract class AbstractSqlMessenger implements Messenger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendOutgoingMessage(@Nonnull OutgoingMessage outgoingMessage) {
|
||||
public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) {
|
||||
try (Connection c = getConnection()) {
|
||||
try (PreparedStatement ps = c.prepareStatement("INSERT INTO " + getTableName() + "(`time`, `msg`) VALUES(NOW(), ?)")) {
|
||||
ps.setString(1, outgoingMessage.asEncodedString());
|
||||
|
||||
+4
-4
@@ -32,13 +32,13 @@ import me.lucko.luckperms.api.ChatMetaType;
|
||||
import me.lucko.luckperms.api.LocalizedNode;
|
||||
import me.lucko.luckperms.api.metastacking.MetaStackElement;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class FluentMetaStackElement implements MetaStackElement {
|
||||
|
||||
public static Builder builder(String name) {
|
||||
@@ -54,7 +54,7 @@ public final class FluentMetaStackElement implements MetaStackElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAccumulate(@Nonnull LocalizedNode node, @Nonnull ChatMetaType type, @Nullable Map.Entry<Integer, String> current) {
|
||||
public boolean shouldAccumulate(@NonNull LocalizedNode node, @NonNull ChatMetaType type, Map.@Nullable Entry<Integer, String> current) {
|
||||
for (MetaStackElement element : this.subElements) {
|
||||
if (!element.shouldAccumulate(node, type, current)) {
|
||||
return false;
|
||||
|
||||
+6
-10
@@ -30,11 +30,11 @@ import com.google.common.collect.ImmutableList;
|
||||
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
||||
import me.lucko.luckperms.api.metastacking.MetaStackElement;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class SimpleMetaStackDefinition implements MetaStackDefinition {
|
||||
|
||||
private final List<MetaStackElement> elements;
|
||||
@@ -53,27 +53,23 @@ public final class SimpleMetaStackDefinition implements MetaStackDefinition {
|
||||
this.hashCode = calculateHashCode();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<MetaStackElement> getElements() {
|
||||
public @NonNull List<MetaStackElement> getElements() {
|
||||
return this.elements;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getStartSpacer() {
|
||||
public @NonNull String getStartSpacer() {
|
||||
return this.startSpacer;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getMiddleSpacer() {
|
||||
public @NonNull String getMiddleSpacer() {
|
||||
return this.middleSpacer;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getEndSpacer() {
|
||||
public @NonNull String getEndSpacer() {
|
||||
return this.endSpacer;
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -33,13 +33,13 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||
import me.lucko.luckperms.common.utils.Uuids;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Contains the standard {@link MetaStackElement}s provided by LuckPerms.
|
||||
*/
|
||||
@@ -217,7 +217,7 @@ public final class StandardStackElements {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAccumulate(@Nonnull LocalizedNode node, @Nonnull ChatMetaType type, @Nullable Map.Entry<Integer, String> current) {
|
||||
public boolean shouldAccumulate(@NonNull LocalizedNode node, @NonNull ChatMetaType type, Map.@Nullable Entry<Integer, String> current) {
|
||||
Track t = this.plugin.getTrackManager().getIfLoaded(this.trackName);
|
||||
return t != null && t.containsGroup(node.getLocation());
|
||||
}
|
||||
@@ -246,7 +246,7 @@ public final class StandardStackElements {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAccumulate(@Nonnull LocalizedNode node, @Nonnull ChatMetaType type, @Nullable Map.Entry<Integer, String> current) {
|
||||
public boolean shouldAccumulate(@NonNull LocalizedNode node, @NonNull ChatMetaType type, Map.@Nullable Entry<Integer, String> current) {
|
||||
Track t = this.plugin.getTrackManager().getIfLoaded(this.trackName);
|
||||
return t != null && !t.containsGroup(node.getLocation());
|
||||
}
|
||||
@@ -273,7 +273,7 @@ public final class StandardStackElements {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAccumulate(@Nonnull LocalizedNode node, @Nonnull ChatMetaType type, @Nullable Map.Entry<Integer, String> current) {
|
||||
public boolean shouldAccumulate(@NonNull LocalizedNode node, @NonNull ChatMetaType type, Map.@Nullable Entry<Integer, String> current) {
|
||||
return this.groupName.equals(node.getLocation());
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ public final class StandardStackElements {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAccumulate(@Nonnull LocalizedNode node, @Nonnull ChatMetaType type, @Nullable Map.Entry<Integer, String> current) {
|
||||
public boolean shouldAccumulate(@NonNull LocalizedNode node, @NonNull ChatMetaType type, Map.@Nullable Entry<Integer, String> current) {
|
||||
return !this.groupName.equals(node.getLocation());
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ import me.lucko.luckperms.api.nodetype.types.DisplayNameType;
|
||||
import me.lucko.luckperms.common.buffers.Cache;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Cache instance to supply the display name of a {@link Group}.
|
||||
@@ -44,9 +44,8 @@ public class DisplayNameCache extends Cache<Optional<String>> {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected Optional<String> supply() {
|
||||
protected @NonNull Optional<String> supply() {
|
||||
// query for a displayname node
|
||||
for (Node n : this.group.getOwnNodes(this.group.getPlugin().getContextManager().getStaticContext())) {
|
||||
Optional<DisplayNameType> displayName = n.getTypeData(DisplayNameType.KEY);
|
||||
|
||||
@@ -42,6 +42,9 @@ import me.lucko.luckperms.common.node.comparator.NodeComparator;
|
||||
import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator;
|
||||
import me.lucko.luckperms.common.node.model.ImmutableLocalizedNode;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
@@ -55,9 +58,6 @@ import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A map of nodes held by a {@link PermissionHolder}.
|
||||
*
|
||||
@@ -273,9 +273,8 @@ public final class NodeMap {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ImmutableSetMultimap<ImmutableContextSet, LocalizedNode> supply() {
|
||||
protected @NonNull ImmutableSetMultimap<ImmutableContextSet, LocalizedNode> supply() {
|
||||
return ImmutableSetMultimap.copyOf(this.handle.map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ import me.lucko.luckperms.common.node.utils.MetaType;
|
||||
import me.lucko.luckperms.common.node.utils.NodeTools;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
@@ -68,8 +70,6 @@ import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Represents an object that can hold permissions, (a user or group)
|
||||
*
|
||||
@@ -762,15 +762,13 @@ public abstract class PermissionHolder {
|
||||
this.mergedNode = mergedNode;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DataMutateResult getResult() {
|
||||
public @NonNull DataMutateResult getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node getMergedNode() {
|
||||
public @NonNull Node getMergedNode() {
|
||||
return this.mergedNode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -47,8 +49,6 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class Track implements Identifiable<String> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,11 +32,11 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.primarygroup.ContextualHolder;
|
||||
import me.lucko.luckperms.common.primarygroup.PrimaryGroupHolder;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class User extends PermissionHolder implements Identifiable<UserIdentifier> {
|
||||
private final ApiUser apiDelegate = new ApiUser(this);
|
||||
|
||||
@@ -48,8 +48,7 @@ public class User extends PermissionHolder implements Identifiable<UserIdentifie
|
||||
/**
|
||||
* The last known username of a player
|
||||
*/
|
||||
@Nullable
|
||||
private String name = null;
|
||||
private @Nullable String name = null;
|
||||
|
||||
/**
|
||||
* The users primary group
|
||||
|
||||
@@ -25,13 +25,13 @@
|
||||
|
||||
package me.lucko.luckperms.common.model;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Used to identify a specific {@link User}.
|
||||
*/
|
||||
@@ -42,9 +42,9 @@ public final class UserIdentifier implements Identifiable<UUID> {
|
||||
*
|
||||
* @param uuid the uuid of the user
|
||||
* @param username the username of the user, nullable
|
||||
* @return
|
||||
* @return a new identifier
|
||||
*/
|
||||
public static UserIdentifier of(@Nonnull UUID uuid, @Nullable String username) {
|
||||
public static UserIdentifier of(@NonNull UUID uuid, @Nullable String username) {
|
||||
Objects.requireNonNull(uuid, "uuid");
|
||||
if (username == null || username.equalsIgnoreCase("null") || username.isEmpty()) {
|
||||
username = null;
|
||||
|
||||
@@ -31,12 +31,12 @@ import me.lucko.luckperms.api.nodetype.types.WeightType;
|
||||
import me.lucko.luckperms.common.buffers.Cache;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Cache instance to supply the weight of a {@link Group}.
|
||||
*/
|
||||
@@ -47,9 +47,8 @@ public class WeightCache extends Cache<OptionalInt> {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected OptionalInt supply() {
|
||||
protected @NonNull OptionalInt supply() {
|
||||
boolean seen = false;
|
||||
int best = 0;
|
||||
for (Node n : this.group.getOwnNodes(ImmutableContextSet.empty())) {
|
||||
|
||||
@@ -31,12 +31,13 @@ import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||
import me.lucko.luckperms.common.node.model.ImmutableNode;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Builds node instances
|
||||
*/
|
||||
@@ -63,7 +64,7 @@ public class NodeBuilder implements Node.Builder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node.Builder copyFrom(@Nonnull Node node) {
|
||||
public Node.Builder copyFrom(@NonNull Node node) {
|
||||
Objects.requireNonNull(node, "node");
|
||||
this.value = node.getValue();
|
||||
this.override = node.isOverride();
|
||||
@@ -74,58 +75,50 @@ public class NodeBuilder implements Node.Builder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder setNegated(boolean negated) {
|
||||
public Node.@NonNull Builder setNegated(boolean negated) {
|
||||
this.value = !negated;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder setValue(boolean value) {
|
||||
public Node.@NonNull Builder setValue(boolean value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder setOverride(boolean override) {
|
||||
public Node.@NonNull Builder setOverride(boolean override) {
|
||||
this.override = override;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder setExpiry(long expireAt) {
|
||||
public Node.@NonNull Builder setExpiry(long expireAt) {
|
||||
this.expireAt = expireAt;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder clearExpiry() {
|
||||
public Node.@NonNull Builder clearExpiry() {
|
||||
this.expireAt = 0L;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder setWorld(String world) {
|
||||
public Node.@NonNull Builder setWorld(String world) {
|
||||
this.world = world;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder setServer(String server) {
|
||||
public Node.@NonNull Builder setServer(String server) {
|
||||
this.server = server;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder withExtraContext(@Nonnull String key, @Nonnull String value) {
|
||||
public Node.@NonNull Builder withExtraContext(@NonNull String key, @NonNull String value) {
|
||||
Objects.requireNonNull(key, "key");
|
||||
Objects.requireNonNull(value, "value");
|
||||
switch (key.toLowerCase()) {
|
||||
@@ -143,48 +136,42 @@ public class NodeBuilder implements Node.Builder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder withExtraContext(@Nonnull Map.Entry<String, String> entry) {
|
||||
public Node.@NonNull Builder withExtraContext(Map.@NonNull Entry<String, String> entry) {
|
||||
Objects.requireNonNull(entry, "entry");
|
||||
withExtraContext(entry.getKey(), entry.getValue());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder withExtraContext(@Nonnull Map<String, String> map) {
|
||||
public Node.@NonNull Builder withExtraContext(@NonNull Map<String, String> map) {
|
||||
Objects.requireNonNull(map, "map");
|
||||
withExtraContext(ContextSet.fromMap(map));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder withExtraContext(@Nonnull Set<Map.Entry<String, String>> context) {
|
||||
public Node.@NonNull Builder withExtraContext(@NonNull Set<Map.Entry<String, String>> context) {
|
||||
Objects.requireNonNull(context, "context");
|
||||
withExtraContext(ContextSet.fromEntries(context));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder withExtraContext(@Nonnull ContextSet set) {
|
||||
public Node.@NonNull Builder withExtraContext(@NonNull ContextSet set) {
|
||||
Objects.requireNonNull(set, "set");
|
||||
set.toSet().forEach(this::withExtraContext);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node.Builder setExtraContext(@Nonnull ContextSet contextSet) {
|
||||
public Node.@NonNull Builder setExtraContext(@NonNull ContextSet contextSet) {
|
||||
this.extraContexts = ImmutableContextSet.builder().addAll(contextSet);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node build() {
|
||||
public @NonNull Node build() {
|
||||
return new ImmutableNode(this.permission, this.value, this.override, this.expireAt, this.server, this.world, this.extraContexts.build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.api.nodetype.NodeType;
|
||||
import me.lucko.luckperms.api.nodetype.NodeTypeKey;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class ForwardingNode implements Node {
|
||||
|
||||
public abstract Node delegate();
|
||||
@@ -54,9 +54,8 @@ public abstract class ForwardingNode implements Node {
|
||||
return this == obj || delegate().equals(obj);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getPermission() {
|
||||
public @NonNull String getPermission() {
|
||||
return delegate().getPermission();
|
||||
}
|
||||
|
||||
@@ -65,9 +64,8 @@ public abstract class ForwardingNode implements Node {
|
||||
return delegate().getValue();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Tristate getTristate() {
|
||||
public @NonNull Tristate getTristate() {
|
||||
return delegate().getTristate();
|
||||
}
|
||||
|
||||
@@ -81,15 +79,13 @@ public abstract class ForwardingNode implements Node {
|
||||
return delegate().isOverride();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getServer() {
|
||||
public @NonNull Optional<String> getServer() {
|
||||
return delegate().getServer();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getWorld() {
|
||||
public @NonNull Optional<String> getWorld() {
|
||||
return delegate().getWorld();
|
||||
}
|
||||
|
||||
@@ -114,13 +110,12 @@ public abstract class ForwardingNode implements Node {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyWithContext(@Nonnull ContextSet contextSet) {
|
||||
public boolean shouldApplyWithContext(@NonNull ContextSet contextSet) {
|
||||
return delegate().shouldApplyWithContext(contextSet);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> resolveShorthand() {
|
||||
public @NonNull List<String> resolveShorthand() {
|
||||
return delegate().resolveShorthand();
|
||||
}
|
||||
|
||||
@@ -139,9 +134,8 @@ public abstract class ForwardingNode implements Node {
|
||||
return delegate().getExpiryUnixTime();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Date getExpiry() throws IllegalStateException {
|
||||
public @NonNull Date getExpiry() throws IllegalStateException {
|
||||
return delegate().getExpiry();
|
||||
}
|
||||
|
||||
@@ -155,15 +149,13 @@ public abstract class ForwardingNode implements Node {
|
||||
return delegate().hasExpired();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ContextSet getContexts() {
|
||||
public @NonNull ContextSet getContexts() {
|
||||
return delegate().getContexts();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ContextSet getFullContexts() {
|
||||
public @NonNull ContextSet getFullContexts() {
|
||||
return delegate().getFullContexts();
|
||||
}
|
||||
|
||||
@@ -172,9 +164,8 @@ public abstract class ForwardingNode implements Node {
|
||||
return delegate().isGroupNode();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getGroupName() throws IllegalStateException {
|
||||
public @NonNull String getGroupName() throws IllegalStateException {
|
||||
return delegate().getGroupName();
|
||||
}
|
||||
|
||||
@@ -208,9 +199,8 @@ public abstract class ForwardingNode implements Node {
|
||||
return delegate().isMeta();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Map.Entry<String, String> getMeta() throws IllegalStateException {
|
||||
public Map.@NonNull Entry<String, String> getMeta() throws IllegalStateException {
|
||||
return delegate().getMeta();
|
||||
}
|
||||
|
||||
@@ -219,9 +209,8 @@ public abstract class ForwardingNode implements Node {
|
||||
return delegate().isPrefix();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Map.Entry<Integer, String> getPrefix() throws IllegalStateException {
|
||||
public Map.@NonNull Entry<Integer, String> getPrefix() throws IllegalStateException {
|
||||
return delegate().getPrefix();
|
||||
}
|
||||
|
||||
@@ -230,9 +219,8 @@ public abstract class ForwardingNode implements Node {
|
||||
return delegate().isSuffix();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Map.Entry<Integer, String> getSuffix() throws IllegalStateException {
|
||||
public Map.@NonNull Entry<Integer, String> getSuffix() throws IllegalStateException {
|
||||
return delegate().getSuffix();
|
||||
}
|
||||
|
||||
|
||||
+4
-6
@@ -28,9 +28,9 @@ package me.lucko.luckperms.common.node.model;
|
||||
import me.lucko.luckperms.api.LocalizedNode;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Holds a Node and where it was inherited from. All calls are passed onto the contained Node instance.
|
||||
@@ -56,15 +56,13 @@ public final class ImmutableLocalizedNode extends ForwardingNode implements Loca
|
||||
return this.node;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node getNode() {
|
||||
public @NonNull Node getNode() {
|
||||
return this.node;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getLocation() {
|
||||
public @NonNull String getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,15 +40,15 @@ import me.lucko.luckperms.common.node.factory.NodeBuilder;
|
||||
import me.lucko.luckperms.common.node.utils.ShorthandParser;
|
||||
import me.lucko.luckperms.common.processors.WildcardProcessor;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
/**
|
||||
@@ -73,10 +73,8 @@ public final class ImmutableNode implements Node {
|
||||
private final boolean value;
|
||||
private boolean override;
|
||||
|
||||
@Nullable
|
||||
private final String server;
|
||||
@Nullable
|
||||
private final String world;
|
||||
private final @Nullable String server;
|
||||
private final @Nullable String world;
|
||||
|
||||
private final long expireAt; // 0L for no expiry
|
||||
private final ImmutableContextSet contexts;
|
||||
@@ -153,9 +151,8 @@ public final class ImmutableNode implements Node {
|
||||
return new NodeBuilder(this);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getPermission() {
|
||||
public @NonNull String getPermission() {
|
||||
return this.permission;
|
||||
}
|
||||
|
||||
@@ -169,15 +166,13 @@ public final class ImmutableNode implements Node {
|
||||
return this.override;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getServer() {
|
||||
public @NonNull Optional<String> getServer() {
|
||||
return this.optServer;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getWorld() {
|
||||
public @NonNull Optional<String> getWorld() {
|
||||
return this.optWorld;
|
||||
}
|
||||
|
||||
@@ -191,15 +186,13 @@ public final class ImmutableNode implements Node {
|
||||
return this.world != null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ImmutableContextSet getContexts() {
|
||||
public @NonNull ImmutableContextSet getContexts() {
|
||||
return this.contexts;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ImmutableContextSet getFullContexts() {
|
||||
public @NonNull ImmutableContextSet getFullContexts() {
|
||||
return this.fullContexts;
|
||||
}
|
||||
|
||||
@@ -214,7 +207,7 @@ public final class ImmutableNode implements Node {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyWithContext(@Nonnull ContextSet contextSet) {
|
||||
public boolean shouldApplyWithContext(@NonNull ContextSet contextSet) {
|
||||
return getFullContexts().isSatisfiedBy(contextSet);
|
||||
}
|
||||
|
||||
@@ -229,9 +222,8 @@ public final class ImmutableNode implements Node {
|
||||
return this.expireAt;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Date getExpiry() {
|
||||
public @NonNull Date getExpiry() {
|
||||
checkState(isTemporary(), "Node does not have an expiry time.");
|
||||
return new Date(this.expireAt * 1000L);
|
||||
}
|
||||
@@ -272,9 +264,8 @@ public final class ImmutableNode implements Node {
|
||||
return Optional.ofNullable(result);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> resolveShorthand() {
|
||||
public @NonNull List<String> resolveShorthand() {
|
||||
return this.resolvedShorthand;
|
||||
}
|
||||
|
||||
@@ -337,7 +328,7 @@ public final class ImmutableNode implements Node {
|
||||
private enum Equality {
|
||||
EXACT {
|
||||
@Override
|
||||
public boolean areEqual(@Nonnull ImmutableNode o1, @Nonnull ImmutableNode o2) {
|
||||
public boolean areEqual(@NonNull ImmutableNode o1, @NonNull ImmutableNode o2) {
|
||||
return o1 == o2 ||
|
||||
o1.permission == o2.permission &&
|
||||
o1.value == o2.value &&
|
||||
@@ -350,7 +341,7 @@ public final class ImmutableNode implements Node {
|
||||
},
|
||||
IGNORE_VALUE {
|
||||
@Override
|
||||
public boolean areEqual(@Nonnull ImmutableNode o1, @Nonnull ImmutableNode o2) {
|
||||
public boolean areEqual(@NonNull ImmutableNode o1, @NonNull ImmutableNode o2) {
|
||||
return o1 == o2 ||
|
||||
o1.permission == o2.permission &&
|
||||
o1.override == o2.override &&
|
||||
@@ -362,7 +353,7 @@ public final class ImmutableNode implements Node {
|
||||
},
|
||||
IGNORE_EXPIRY_TIME {
|
||||
@Override
|
||||
public boolean areEqual(@Nonnull ImmutableNode o1, @Nonnull ImmutableNode o2) {
|
||||
public boolean areEqual(@NonNull ImmutableNode o1, @NonNull ImmutableNode o2) {
|
||||
return o1 == o2 ||
|
||||
o1.permission == o2.permission &&
|
||||
o1.value == o2.value &&
|
||||
@@ -375,7 +366,7 @@ public final class ImmutableNode implements Node {
|
||||
},
|
||||
IGNORE_EXPIRY_TIME_AND_VALUE {
|
||||
@Override
|
||||
public boolean areEqual(@Nonnull ImmutableNode o1, @Nonnull ImmutableNode o2) {
|
||||
public boolean areEqual(@NonNull ImmutableNode o1, @NonNull ImmutableNode o2) {
|
||||
return o1 == o2 ||
|
||||
o1.permission == o2.permission &&
|
||||
o1.override == o2.override &&
|
||||
@@ -387,7 +378,7 @@ public final class ImmutableNode implements Node {
|
||||
},
|
||||
IGNORE_VALUE_OR_IF_TEMPORARY {
|
||||
@Override
|
||||
public boolean areEqual(@Nonnull ImmutableNode o1, @Nonnull ImmutableNode o2) {
|
||||
public boolean areEqual(@NonNull ImmutableNode o1, @NonNull ImmutableNode o2) {
|
||||
return o1 == o2 ||
|
||||
o1.permission == o2.permission &&
|
||||
o1.override == o2.override &&
|
||||
@@ -397,7 +388,7 @@ public final class ImmutableNode implements Node {
|
||||
}
|
||||
};
|
||||
|
||||
public abstract boolean areEqual(@Nonnull ImmutableNode o1, @Nonnull ImmutableNode o2);
|
||||
public abstract boolean areEqual(@NonNull ImmutableNode o1, @NonNull ImmutableNode o2);
|
||||
}
|
||||
|
||||
private static String internString(String s) {
|
||||
|
||||
@@ -29,11 +29,11 @@ import me.lucko.luckperms.api.HeldPermission;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalLong;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class NodeHeldPermission<T extends Comparable<T>> implements HeldPermission<T> {
|
||||
public static <T extends Comparable<T>> NodeHeldPermission<T> of(T holder, NodeDataContainer node) {
|
||||
return of(holder, node.toNode());
|
||||
@@ -51,9 +51,8 @@ public final class NodeHeldPermission<T extends Comparable<T>> implements HeldPe
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getPermission() {
|
||||
public @NonNull String getPermission() {
|
||||
return this.node.getPermission();
|
||||
}
|
||||
|
||||
@@ -62,15 +61,13 @@ public final class NodeHeldPermission<T extends Comparable<T>> implements HeldPe
|
||||
return this.node.getValue();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getServer() {
|
||||
public @NonNull Optional<String> getServer() {
|
||||
return this.node.getServer();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getWorld() {
|
||||
public @NonNull Optional<String> getWorld() {
|
||||
return this.node.getWorld();
|
||||
}
|
||||
|
||||
@@ -84,15 +81,13 @@ public final class NodeHeldPermission<T extends Comparable<T>> implements HeldPe
|
||||
return this.node.getContexts();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node asNode() {
|
||||
public @NonNull Node asNode() {
|
||||
return this.node;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public T getHolder() {
|
||||
public @NonNull T getHolder() {
|
||||
return this.holder;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ import me.lucko.luckperms.common.buffers.Cache;
|
||||
import me.lucko.luckperms.common.node.factory.LegacyNodeFactory;
|
||||
import me.lucko.luckperms.common.utils.PatternCache;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
@@ -48,9 +51,6 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class NodeTypes {
|
||||
|
||||
public static final String PREFIX_KEY = "prefix";
|
||||
@@ -71,8 +71,7 @@ public final class NodeTypes {
|
||||
// used to split prefix/suffix/meta nodes
|
||||
private static final Splitter META_SPLITTER = Splitter.on(PatternCache.compileDelimiterPattern(".", "\\")).limit(2);
|
||||
|
||||
@Nonnull
|
||||
public static Map<NodeTypeKey<?>, NodeType> parseTypes(String s) {
|
||||
public static @NonNull Map<NodeTypeKey<?>, NodeType> parseTypes(String s) {
|
||||
Map<NodeTypeKey<?>, NodeType> results = new IdentityHashMap<>();
|
||||
|
||||
NodeType type = parseInheritanceType(s);
|
||||
@@ -117,8 +116,7 @@ public final class NodeTypes {
|
||||
return results;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static InheritanceType parseInheritanceType(String s) {
|
||||
public static @Nullable InheritanceType parseInheritanceType(String s) {
|
||||
s = s.toLowerCase();
|
||||
if (!s.startsWith(GROUP_NODE_MARKER)) {
|
||||
return null;
|
||||
@@ -128,8 +126,7 @@ public final class NodeTypes {
|
||||
return new Inheritance(groupName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static MetaType parseMetaType(String s) {
|
||||
public static @Nullable MetaType parseMetaType(String s) {
|
||||
if (!s.toLowerCase().startsWith(META_NODE_MARKER)) {
|
||||
return null;
|
||||
}
|
||||
@@ -148,8 +145,7 @@ public final class NodeTypes {
|
||||
);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PrefixType parsePrefixType(String s) {
|
||||
public static @Nullable PrefixType parsePrefixType(String s) {
|
||||
if (!s.toLowerCase().startsWith(PREFIX_NODE_MARKER)) {
|
||||
return null;
|
||||
}
|
||||
@@ -171,8 +167,7 @@ public final class NodeTypes {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SuffixType parseSuffixType(String s) {
|
||||
public static @Nullable SuffixType parseSuffixType(String s) {
|
||||
if (!s.toLowerCase().startsWith(SUFFIX_NODE_MARKER)) {
|
||||
return null;
|
||||
}
|
||||
@@ -194,8 +189,7 @@ public final class NodeTypes {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static WeightType parseWeightType(String s) {
|
||||
public static @Nullable WeightType parseWeightType(String s) {
|
||||
String lower = s.toLowerCase();
|
||||
if (!lower.startsWith(WEIGHT_NODE_MARKER)) {
|
||||
return null;
|
||||
@@ -208,8 +202,7 @@ public final class NodeTypes {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static DisplayNameType parseDisplayNameType(String s) {
|
||||
public static @Nullable DisplayNameType parseDisplayNameType(String s) {
|
||||
if (!s.toLowerCase().startsWith(DISPLAY_NAME_NODE_MARKER)) {
|
||||
return null;
|
||||
}
|
||||
@@ -217,8 +210,7 @@ public final class NodeTypes {
|
||||
return new DisplayName(s.substring(DISPLAY_NAME_NODE_MARKER.length()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static RegexType parseRegexType(String s) {
|
||||
public static @Nullable RegexType parseRegexType(String s) {
|
||||
if (!s.startsWith(REGEX_MARKER_1) && !s.startsWith(REGEX_MARKER_2)) {
|
||||
return null;
|
||||
}
|
||||
@@ -233,9 +225,8 @@ public final class NodeTypes {
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getGroupName() {
|
||||
public @NonNull String getGroupName() {
|
||||
return this.groupName;
|
||||
}
|
||||
|
||||
@@ -267,15 +258,13 @@ public final class NodeTypes {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getKey() {
|
||||
public @NonNull String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getValue() {
|
||||
public @NonNull String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@@ -313,15 +302,13 @@ public final class NodeTypes {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
public @NonNull String getPrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Map.Entry<Integer, String> getAsEntry() {
|
||||
public Map.@NonNull Entry<Integer, String> getAsEntry() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -374,15 +361,13 @@ public final class NodeTypes {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getSuffix() {
|
||||
public @NonNull String getSuffix() {
|
||||
return this.suffix;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Map.Entry<Integer, String> getAsEntry() {
|
||||
public Map.@NonNull Entry<Integer, String> getAsEntry() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -459,9 +444,8 @@ public final class NodeTypes {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
@@ -491,21 +475,18 @@ public final class NodeTypes {
|
||||
this.patternString = patternString;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected PatternCache.CachedPattern supply() {
|
||||
protected PatternCache.@NonNull CachedPattern supply() {
|
||||
return PatternCache.lookup(this.patternString);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getPatternString() {
|
||||
public @NonNull String getPatternString() {
|
||||
return this.patternString;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<Pattern> getPattern() {
|
||||
public @NonNull Optional<Pattern> getPattern() {
|
||||
return Optional.ofNullable(get().getPattern());
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -30,6 +30,8 @@ import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader;
|
||||
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
@@ -39,8 +41,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Bootstrap plugin interface
|
||||
*
|
||||
@@ -126,8 +126,7 @@ public interface LuckPermsBootstrap {
|
||||
*
|
||||
* @return the server name
|
||||
*/
|
||||
@Nullable
|
||||
default String getServerName() {
|
||||
default @Nullable String getServerName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -32,18 +32,17 @@ import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Optional;
|
||||
|
||||
public class AllParentsByWeightHolder extends ContextualHolder {
|
||||
public AllParentsByWeightHolder(User user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected Optional<String> calculateValue(Contexts contexts) {
|
||||
protected @NonNull Optional<String> calculateValue(Contexts contexts) {
|
||||
InheritanceGraph graph = this.user.getPlugin().getInheritanceHandler().getGraph(contexts);
|
||||
|
||||
// fully traverse the graph, obtain a list of permission holders the user inherits from
|
||||
|
||||
@@ -32,12 +32,12 @@ import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Abstract implementation of {@link PrimaryGroupHolder} which caches all lookups.
|
||||
*/
|
||||
@@ -52,8 +52,7 @@ public abstract class ContextualHolder extends StoredHolder {
|
||||
super(user);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected abstract Optional<String> calculateValue(Contexts contexts);
|
||||
protected abstract @NonNull Optional<String> calculateValue(Contexts contexts);
|
||||
|
||||
public void invalidateCache() {
|
||||
this.cache.invalidateAll();
|
||||
|
||||
+3
-4
@@ -30,20 +30,19 @@ import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ParentsByWeightHolder extends ContextualHolder {
|
||||
public ParentsByWeightHolder(User user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected Optional<String> calculateValue(Contexts contexts) {
|
||||
protected @NonNull Optional<String> calculateValue(Contexts contexts) {
|
||||
Set<Group> groups = new LinkedHashSet<>();
|
||||
for (Node node : this.user.getOwnGroupNodes(contexts.getContexts())) {
|
||||
Group group = this.user.getPlugin().getGroupManager().getIfLoaded(node.getGroupName());
|
||||
|
||||
@@ -29,14 +29,14 @@ import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import me.lucko.luckperms.api.PlayerSaveResult;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents the result to a player history save operation
|
||||
*/
|
||||
@@ -69,8 +69,8 @@ public final class PlayerSaveResultImpl implements PlayerSaveResult {
|
||||
}
|
||||
|
||||
private final Set<Status> status;
|
||||
@Nullable private final String oldUsername;
|
||||
@Nullable private final Set<UUID> otherUuids;
|
||||
private final @Nullable String oldUsername;
|
||||
private final @Nullable Set<UUID> otherUuids;
|
||||
|
||||
private PlayerSaveResultImpl(EnumSet<Status> status, @Nullable String oldUsername, @Nullable Set<UUID> otherUuids) {
|
||||
this.status = ImmutableSet.copyOf(status);
|
||||
@@ -89,32 +89,29 @@ public final class PlayerSaveResultImpl implements PlayerSaveResult {
|
||||
* @param otherUuids the other uuids
|
||||
* @return a new result
|
||||
*/
|
||||
public PlayerSaveResultImpl withOtherUuidsPresent(@Nonnull Set<UUID> otherUuids) {
|
||||
public PlayerSaveResultImpl withOtherUuidsPresent(@NonNull Set<UUID> otherUuids) {
|
||||
EnumSet<Status> status = EnumSet.copyOf(this.status);
|
||||
status.add(Status.OTHER_UUIDS_PRESENT_FOR_USERNAME);
|
||||
return new PlayerSaveResultImpl(status, this.oldUsername, ImmutableSet.copyOf(otherUuids));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<Status> getStatus() {
|
||||
public @NonNull Set<Status> getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean includes(@Nonnull Status status) {
|
||||
public boolean includes(@NonNull Status status) {
|
||||
return this.status.contains(status);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getOldUsername() {
|
||||
public @Nullable String getOldUsername() {
|
||||
return this.oldUsername;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Set<UUID> getOtherUuids() {
|
||||
public @Nullable Set<UUID> getOtherUuids() {
|
||||
return this.otherUuids;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -43,8 +45,6 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class AbstractDao {
|
||||
|
||||
protected final LuckPermsPlugin plugin;
|
||||
@@ -109,10 +109,8 @@ public abstract class AbstractDao {
|
||||
|
||||
public abstract PlayerSaveResult savePlayerData(UUID uuid, String username) throws Exception;
|
||||
|
||||
@Nullable
|
||||
public abstract UUID getPlayerUuid(String username) throws Exception;
|
||||
public abstract @Nullable UUID getPlayerUuid(String username) throws Exception;
|
||||
|
||||
@Nullable
|
||||
public abstract String getPlayerName(UUID uuid) throws Exception;
|
||||
public abstract @Nullable String getPlayerName(UUID uuid) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,9 @@ import me.lucko.luckperms.api.PlayerSaveResult;
|
||||
import me.lucko.luckperms.common.storage.PlayerSaveResultImpl;
|
||||
import me.lucko.luckperms.common.utils.Uuids;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
@@ -47,8 +50,6 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class FileUuidCache {
|
||||
private static final Splitter KV_SPLIT = Splitter.on(':').omitEmptyStrings();
|
||||
private static final Splitter LEGACY_KV_SPLIT = Splitter.on('=').omitEmptyStrings();
|
||||
@@ -61,7 +62,7 @@ public class FileUuidCache {
|
||||
private final SetMultimap<String, UUID> reverse = Multimaps.newSetMultimap(new ConcurrentHashMap<>(), ConcurrentHashMap::newKeySet);
|
||||
|
||||
@Override
|
||||
public String put(UUID key, String value) {
|
||||
public String put(@NonNull UUID key, @NonNull String value) {
|
||||
String existing = super.put(key, value);
|
||||
|
||||
// check if we need to remove a reverse entry which has been replaced
|
||||
@@ -77,7 +78,7 @@ public class FileUuidCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String remove(Object k) {
|
||||
public String remove(@NonNull Object k) {
|
||||
UUID key = (UUID) k;
|
||||
String username = super.remove(key);
|
||||
if (username != null) {
|
||||
@@ -128,8 +129,7 @@ public class FileUuidCache {
|
||||
* @param username the username to lookup with
|
||||
* @return a uuid, or null
|
||||
*/
|
||||
@Nullable
|
||||
public UUID lookupUuid(String username) {
|
||||
public @Nullable UUID lookupUuid(String username) {
|
||||
Set<UUID> uuids = this.lookupMap.lookupUuid(username);
|
||||
return Iterables.getFirst(uuids, null);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -38,8 +40,6 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* An immutable and sorted version of TreeNode
|
||||
*
|
||||
@@ -117,7 +117,7 @@ public class ImmutableTreeNode implements Comparable<ImmutableTreeNode> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@Nonnull ImmutableTreeNode o) {
|
||||
public int compareTo(@NonNull ImmutableTreeNode o) {
|
||||
return (this.children != null) == o.getChildren().isPresent() ? 0 : (this.children != null ? 1 : -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ package me.lucko.luckperms.common.treeview;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents one "branch" or "level" of the node tree
|
||||
*/
|
||||
@@ -86,8 +86,7 @@ public class TreeNode {
|
||||
return this.children;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TreeNode tryInsert(String s) {
|
||||
public @Nullable TreeNode tryInsert(String s) {
|
||||
Map<String, TreeNode> childMap = getChildMap();
|
||||
if (!allowInsert(this)) {
|
||||
return null;
|
||||
|
||||
@@ -29,12 +29,12 @@ import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.google.common.collect.ForwardingSet;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* A simple expiring set implementation using Caffeine caches
|
||||
*
|
||||
@@ -50,7 +50,7 @@ public class ExpiringSet<E> extends ForwardingSet<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E element) {
|
||||
public boolean add(@NonNull E element) {
|
||||
this.cache.put(element, Boolean.TRUE);
|
||||
|
||||
// we don't care about the return value
|
||||
@@ -58,7 +58,7 @@ public class ExpiringSet<E> extends ForwardingSet<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(@Nonnull Collection<? extends E> collection) {
|
||||
public boolean addAll(@NonNull Collection<? extends E> collection) {
|
||||
for (E element : collection) {
|
||||
add(element);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class ExpiringSet<E> extends ForwardingSet<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object key) {
|
||||
public boolean remove(@NonNull Object key) {
|
||||
this.cache.invalidate(key);
|
||||
|
||||
// we don't care about the return value
|
||||
@@ -76,7 +76,7 @@ public class ExpiringSet<E> extends ForwardingSet<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(@Nonnull Collection<?> keys) {
|
||||
public boolean removeAll(@NonNull Collection<?> keys) {
|
||||
this.cache.invalidateAll(keys);
|
||||
|
||||
// we don't care about the return value
|
||||
|
||||
@@ -28,12 +28,12 @@ package me.lucko.luckperms.common.utils;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class PatternCache {
|
||||
|
||||
private static final LoadingCache<String, CachedPattern> CACHE = Caffeine.newBuilder()
|
||||
@@ -86,13 +86,11 @@ public final class PatternCache {
|
||||
this.ex = ex;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Pattern getPattern() {
|
||||
public @Nullable Pattern getPattern() {
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PatternSyntaxException getException() {
|
||||
public @Nullable PatternSyntaxException getException() {
|
||||
return this.ex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@
|
||||
|
||||
package me.lucko.luckperms.common.utils;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Utilities for working with {@link UUID}s.
|
||||
*/
|
||||
@@ -40,8 +40,7 @@ public final class Uuids {
|
||||
|
||||
public static final Predicate<String> PREDICATE = s -> parseNullable(s) != null;
|
||||
|
||||
@Nullable
|
||||
public static UUID fromString(String s) {
|
||||
public static @Nullable UUID fromString(String s) {
|
||||
try {
|
||||
return UUID.fromString(s);
|
||||
} catch (IllegalArgumentException e) {
|
||||
@@ -49,8 +48,7 @@ public final class Uuids {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static UUID parseNullable(String s) {
|
||||
public static @Nullable UUID parseNullable(String s) {
|
||||
UUID uuid = fromString(s);
|
||||
if (uuid == null) {
|
||||
uuid = fromString(UUID_PATTERN.matcher(s).replaceAll("$1-$2-$3-$4-$5"));
|
||||
|
||||
@@ -46,7 +46,7 @@ public class HttpClient {
|
||||
|
||||
private static OkHttpClient client = null;
|
||||
|
||||
private synchronized static OkHttpClient getClient() {
|
||||
private static synchronized OkHttpClient getClient() {
|
||||
if (client == null) {
|
||||
client = new OkHttpClient.Builder()
|
||||
.proxySelector(new NullSafeProxySelector())
|
||||
|
||||
Reference in New Issue
Block a user