diff --git a/api/build.gradle b/api/build.gradle index 7c3c28a1..ff353c1c 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -2,7 +2,7 @@ project.version = '4.2' dependencies { compileOnly 'com.google.guava:guava:19.0' - compileOnly 'com.google.code.findbugs:jsr305:3.0.2' + compileOnly 'org.checkerframework:checker-qual:2.5.5' } if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')) { diff --git a/api/src/main/java/me/lucko/luckperms/LuckPerms.java b/api/src/main/java/me/lucko/luckperms/LuckPerms.java index e6d71d66..a3f80607 100644 --- a/api/src/main/java/me/lucko/luckperms/LuckPerms.java +++ b/api/src/main/java/me/lucko/luckperms/LuckPerms.java @@ -27,9 +27,9 @@ package me.lucko.luckperms; import me.lucko.luckperms.api.LuckPermsApi; -import java.util.Optional; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Optional; /** * Provides static access to the {@link LuckPermsApi}. @@ -49,8 +49,7 @@ public final class LuckPerms { * @return an api instance * @throws IllegalStateException if the api is not loaded */ - @Nonnull - public static LuckPermsApi getApi() { + public static @NonNull LuckPermsApi getApi() { if (instance == null) { throw new IllegalStateException("API is not loaded."); } @@ -66,8 +65,7 @@ public final class LuckPerms { * * @return an optional api instance */ - @Nonnull - public static Optional getApiSafe() { + public static @NonNull Optional getApiSafe() { return Optional.ofNullable(instance); } diff --git a/api/src/main/java/me/lucko/luckperms/api/ActionLogger.java b/api/src/main/java/me/lucko/luckperms/api/ActionLogger.java index 15a7015b..393a92e8 100644 --- a/api/src/main/java/me/lucko/luckperms/api/ActionLogger.java +++ b/api/src/main/java/me/lucko/luckperms/api/ActionLogger.java @@ -25,9 +25,9 @@ package me.lucko.luckperms.api; -import java.util.concurrent.CompletableFuture; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.concurrent.CompletableFuture; /** * Represents the object responsible for handling action logging. @@ -41,8 +41,7 @@ public interface ActionLogger { * * @return a new builder */ - @Nonnull - LogEntry.Builder newEntryBuilder(); + LogEntry.@NonNull Builder newEntryBuilder(); /** * Gets a {@link Log} instance from the plugin storage. @@ -50,7 +49,7 @@ public interface ActionLogger { * @return a log instance * @see Storage#getLog() */ - @Nonnull + @NonNull CompletableFuture getLog(); /** @@ -69,8 +68,8 @@ public interface ActionLogger { * @param entry the entry to submit * @return a future which will complete when the action is done */ - @Nonnull - CompletableFuture submit(@Nonnull LogEntry entry); + @NonNull + CompletableFuture submit(@NonNull LogEntry entry); /** * Submits a log entry to the plugins storage handler. @@ -80,8 +79,8 @@ public interface ActionLogger { * @param entry the entry to submit * @return a future which will complete when the action is done */ - @Nonnull - CompletableFuture submitToStorage(@Nonnull LogEntry entry); + @NonNull + CompletableFuture submitToStorage(@NonNull LogEntry entry); /** * Submits a log entry to the plugins log broadcasting handler. @@ -92,7 +91,7 @@ public interface ActionLogger { * @param entry the entry to submit * @return a future which will complete when the action is done */ - @Nonnull - CompletableFuture broadcastAction(@Nonnull LogEntry entry); + @NonNull + CompletableFuture broadcastAction(@NonNull LogEntry entry); } diff --git a/api/src/main/java/me/lucko/luckperms/api/ChatMetaType.java b/api/src/main/java/me/lucko/luckperms/api/ChatMetaType.java index 2d97b16b..e276bdc7 100644 --- a/api/src/main/java/me/lucko/luckperms/api/ChatMetaType.java +++ b/api/src/main/java/me/lucko/luckperms/api/ChatMetaType.java @@ -25,12 +25,12 @@ package me.lucko.luckperms.api; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.Map; import java.util.Objects; import java.util.Optional; -import javax.annotation.Nonnull; - /** * Represents a type of chat meta * @@ -43,13 +43,12 @@ public enum ChatMetaType { */ PREFIX("prefix") { @Override - public boolean matches(@Nonnull Node node) { + public boolean matches(@NonNull Node node) { return Objects.requireNonNull(node, "node").isPrefix(); } - @Nonnull @Override - public Map.Entry getEntry(@Nonnull Node node) { + public Map.@NonNull Entry getEntry(@NonNull Node node) { return Objects.requireNonNull(node, "node").getPrefix(); } }, @@ -59,13 +58,12 @@ public enum ChatMetaType { */ SUFFIX("suffix") { @Override - public boolean matches(@Nonnull Node node) { + public boolean matches(@NonNull Node node) { return Objects.requireNonNull(node, "node").isSuffix(); } - @Nonnull @Override - public Map.Entry getEntry(@Nonnull Node node) { + public Map.@NonNull Entry getEntry(@NonNull Node node) { return Objects.requireNonNull(node, "node").getSuffix(); } }; @@ -82,7 +80,7 @@ public enum ChatMetaType { * @param node the node to test * @return true if the node has the same type */ - public abstract boolean matches(@Nonnull Node node); + public abstract boolean matches(@NonNull Node node); /** * Returns if the passed node should be ignored when searching for meta of this type @@ -90,7 +88,7 @@ public enum ChatMetaType { * @param node the node to test * @return true if the node does not share the same type */ - public boolean shouldIgnore(@Nonnull Node node) { + public boolean shouldIgnore(@NonNull Node node) { return !matches(node); } @@ -101,8 +99,7 @@ public enum ChatMetaType { * @return the entry * @throws IllegalStateException if the node does not share the same type */ - @Nonnull - public abstract Map.Entry getEntry(@Nonnull Node node); + public abstract Map.@NonNull Entry getEntry(@NonNull Node node); @Override public String toString() { @@ -116,8 +113,7 @@ public enum ChatMetaType { * @return the parsed chat meta type * @since 3.4 */ - @Nonnull - public static Optional ofNode(@Nonnull Node node) { + public static @NonNull Optional ofNode(@NonNull Node node) { if (node.isPrefix()) { return Optional.of(PREFIX); } else if (node.isSuffix()) { diff --git a/api/src/main/java/me/lucko/luckperms/api/Contexts.java b/api/src/main/java/me/lucko/luckperms/api/Contexts.java index 35485f6e..9cfb4b74 100644 --- a/api/src/main/java/me/lucko/luckperms/api/Contexts.java +++ b/api/src/main/java/me/lucko/luckperms/api/Contexts.java @@ -30,13 +30,12 @@ import com.google.common.collect.ImmutableSet; import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.ImmutableContextSet; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.EnumSet; import java.util.Objects; import java.util.Set; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.Immutable; - /** * Encapsulates the {@link ContextSet contexts} and {@link LookupSetting settings} for * a permission or meta lookup. @@ -45,7 +44,6 @@ import javax.annotation.concurrent.Immutable; * * @since 2.11 */ -@Immutable public class Contexts { /** @@ -82,8 +80,7 @@ public class Contexts { * * @return a context that will satisfy all contextual requirements. */ - @Nonnull - public static Contexts allowAll() { + public static @NonNull Contexts allowAll() { return FullySatisfiedContexts.getInstance(); } @@ -96,8 +93,7 @@ public class Contexts { * @return the global contexts * @since 3.3 */ - @Nonnull - public static Contexts global() { + public static @NonNull Contexts global() { return GLOBAL; } @@ -113,8 +109,7 @@ public class Contexts { * @param isOp the value of {@link LookupSetting#IS_OP} * @return a new instance */ - @Nonnull - public static Contexts of(@Nonnull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) { + public static @NonNull Contexts of(@NonNull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) { Objects.requireNonNull(contextSet, "contextSet"); EnumSet settings = formSettings( includeNodesSetWithoutServer, @@ -145,7 +140,7 @@ public class Contexts { * @param settings the settings * @return a new instance */ - public static Contexts of(@Nonnull ContextSet contextSet, @Nonnull Set settings) { + public static Contexts of(@NonNull ContextSet contextSet, @NonNull Set settings) { Objects.requireNonNull(contextSet, "contextSet"); Objects.requireNonNull(settings, "settings"); @@ -183,7 +178,7 @@ public class Contexts { * @deprecated in favour of {@link #of(ContextSet, boolean, boolean, boolean, boolean, boolean, boolean)} */ @Deprecated - public Contexts(@Nonnull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) { + public Contexts(@NonNull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) { this.contextSet = Objects.requireNonNull(contextSet, "contextSet").makeImmutable(); this.settings = ImmutableSet.copyOf(formSettings( includeNodesSetWithoutServer, @@ -196,7 +191,7 @@ public class Contexts { this.hashCode = calculateHashCode(); } - protected Contexts(@Nonnull ImmutableContextSet contextSet, @Nonnull ImmutableSet settings) { + protected Contexts(@NonNull ImmutableContextSet contextSet, @NonNull ImmutableSet settings) { this.contextSet = contextSet; this.settings = settings; this.hashCode = calculateHashCode(); @@ -208,8 +203,7 @@ public class Contexts { * @return an immutable context from this instance * @since 2.13 */ - @Nonnull - public ContextSet getContexts() { + public @NonNull ContextSet getContexts() { return this.contextSet; } @@ -219,8 +213,7 @@ public class Contexts { * @return the settings * @since 4.2 */ - @Nonnull - public Set getSettings() { + public @NonNull Set getSettings() { return this.settings; } @@ -231,7 +224,7 @@ public class Contexts { * @return the value * @since 4.2 */ - public boolean hasSetting(@Nonnull LookupSetting setting) { + public boolean hasSetting(@NonNull LookupSetting setting) { return this.settings.contains(setting); } @@ -307,9 +300,8 @@ public class Contexts { return hasSetting(LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD); } - @Nonnull @Override - public String toString() { + public @NonNull String toString() { return "Contexts(contextSet=" + this.contextSet + ", settings=" + this.settings + ")"; } diff --git a/api/src/main/java/me/lucko/luckperms/api/DemotionResult.java b/api/src/main/java/me/lucko/luckperms/api/DemotionResult.java index 02052925..22fa319c 100644 --- a/api/src/main/java/me/lucko/luckperms/api/DemotionResult.java +++ b/api/src/main/java/me/lucko/luckperms/api/DemotionResult.java @@ -25,9 +25,9 @@ package me.lucko.luckperms.api; -import java.util.Optional; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Optional; /** * Encapsulates the result of {@link User}s demotion along a {@link Track}. @@ -41,7 +41,7 @@ public interface DemotionResult extends MutateResult { * * @return the status */ - @Nonnull + @NonNull Status getStatus(); @Override @@ -60,7 +60,7 @@ public interface DemotionResult extends MutateResult { * * @return the group the user was demoted from. */ - @Nonnull + @NonNull Optional getGroupFrom(); /** @@ -71,7 +71,7 @@ public interface DemotionResult extends MutateResult { * * @return the group the user was demoted to. */ - @Nonnull + @NonNull Optional getGroupTo(); /** diff --git a/api/src/main/java/me/lucko/luckperms/api/Entity.java b/api/src/main/java/me/lucko/luckperms/api/Entity.java index 4f0d512a..5b8833cd 100644 --- a/api/src/main/java/me/lucko/luckperms/api/Entity.java +++ b/api/src/main/java/me/lucko/luckperms/api/Entity.java @@ -25,10 +25,10 @@ package me.lucko.luckperms.api; -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; /** * Represents an entity on the server. @@ -57,7 +57,7 @@ public interface Entity { * * @return the object name */ - @Nonnull + @NonNull String getName(); /** @@ -65,7 +65,7 @@ public interface Entity { * * @return the type */ - @Nonnull + @NonNull Type getType(); /** diff --git a/api/src/main/java/me/lucko/luckperms/api/FullySatisfiedContexts.java b/api/src/main/java/me/lucko/luckperms/api/FullySatisfiedContexts.java index cebc5d59..d332feea 100644 --- a/api/src/main/java/me/lucko/luckperms/api/FullySatisfiedContexts.java +++ b/api/src/main/java/me/lucko/luckperms/api/FullySatisfiedContexts.java @@ -31,7 +31,7 @@ import me.lucko.luckperms.api.caching.CachedData; import me.lucko.luckperms.api.caching.MetaContexts; import me.lucko.luckperms.api.context.ImmutableContextSet; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * A special instance of {@link Contexts}, which when passed to: @@ -54,8 +54,7 @@ public final class FullySatisfiedContexts extends Contexts { // singleton private static final FullySatisfiedContexts INSTANCE = new FullySatisfiedContexts(); - @Nonnull - public static Contexts getInstance() { + public static @NonNull Contexts getInstance() { return INSTANCE; } @@ -63,9 +62,8 @@ public final class FullySatisfiedContexts extends Contexts { super(ImmutableContextSet.empty(), ImmutableSet.copyOf(Contexts.global().getSettings())); } - @Nonnull @Override - public String toString() { + public @NonNull String toString() { return "FullySatisfiedContexts()"; } diff --git a/api/src/main/java/me/lucko/luckperms/api/Group.java b/api/src/main/java/me/lucko/luckperms/api/Group.java index ccbab7bf..0a3e7778 100644 --- a/api/src/main/java/me/lucko/luckperms/api/Group.java +++ b/api/src/main/java/me/lucko/luckperms/api/Group.java @@ -28,10 +28,10 @@ package me.lucko.luckperms.api; import me.lucko.luckperms.api.caching.GroupData; import me.lucko.luckperms.api.context.ContextSet; -import java.util.OptionalInt; +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.OptionalInt; /** * An inheritable holder of permission data. @@ -43,7 +43,7 @@ public interface Group extends PermissionHolder { * * @return the name of the group */ - @Nonnull + @NonNull String getName(); /** @@ -71,7 +71,7 @@ public interface Group extends PermissionHolder { * @since 4.3 */ @Nullable - String getDisplayName(@Nonnull ContextSet contextSet); + String getDisplayName(@NonNull ContextSet contextSet); /** * Gets the weight of this group, if present. @@ -79,7 +79,7 @@ public interface Group extends PermissionHolder { * @return the group weight * @since 2.17 */ - @Nonnull + @NonNull OptionalInt getWeight(); /** @@ -88,7 +88,7 @@ public interface Group extends PermissionHolder { * @return the groups cached data. * @since 4.0 */ - @Nonnull + @NonNull @Override GroupData getCachedData(); diff --git a/api/src/main/java/me/lucko/luckperms/api/HeldPermission.java b/api/src/main/java/me/lucko/luckperms/api/HeldPermission.java index 157f4baf..37e5396f 100644 --- a/api/src/main/java/me/lucko/luckperms/api/HeldPermission.java +++ b/api/src/main/java/me/lucko/luckperms/api/HeldPermission.java @@ -27,19 +27,17 @@ package me.lucko.luckperms.api; 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; -import javax.annotation.concurrent.Immutable; - /** * A relationship between a {@link PermissionHolder} and a permission. * * @param the identifier type of the holder * @since 2.17 */ -@Immutable public interface HeldPermission { /** @@ -47,7 +45,7 @@ public interface HeldPermission { * * @return the holder */ - @Nonnull + @NonNull T getHolder(); /** @@ -55,7 +53,7 @@ public interface HeldPermission { * * @return the permission */ - @Nonnull + @NonNull String getPermission(); /** @@ -70,7 +68,7 @@ public interface HeldPermission { * * @return the server */ - @Nonnull + @NonNull Optional getServer(); /** @@ -78,7 +76,7 @@ public interface HeldPermission { * * @return the world */ - @Nonnull + @NonNull Optional getWorld(); /** @@ -100,7 +98,7 @@ public interface HeldPermission { * * @return a Node copy of this permission */ - @Nonnull + @NonNull Node asNode(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java b/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java index 93ed9317..5c1a1c66 100644 --- a/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java +++ b/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java @@ -25,9 +25,9 @@ package me.lucko.luckperms.api; -import java.util.Map; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Map; /** * Wrapper around parts of the LuckPerms configuration file @@ -39,7 +39,7 @@ public interface LPConfiguration { * * @return the name of this server */ - @Nonnull + @NonNull String getServer(); /** @@ -78,7 +78,7 @@ public interface LPConfiguration { * * @return the storage method string from the configuration */ - @Nonnull + @NonNull String getStorageMethod(); /** @@ -96,10 +96,10 @@ public interface LPConfiguration { * method. For example: key = user, value = json * @since 2.7 */ - @Nonnull + @NonNull Map getSplitStorageOptions(); - @Nonnull + @NonNull Unsafe unsafe(); interface Unsafe { @@ -115,7 +115,7 @@ public interface LPConfiguration { * @return the corresponding object, if one is present * @throws IllegalArgumentException if the key isn't known */ - @Nonnull + @NonNull Object getObject(String key); } diff --git a/api/src/main/java/me/lucko/luckperms/api/LocalizedNode.java b/api/src/main/java/me/lucko/luckperms/api/LocalizedNode.java index e103058e..5f54470b 100644 --- a/api/src/main/java/me/lucko/luckperms/api/LocalizedNode.java +++ b/api/src/main/java/me/lucko/luckperms/api/LocalizedNode.java @@ -25,8 +25,7 @@ package me.lucko.luckperms.api; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.Immutable; +import org.checkerframework.checker.nullness.qual.NonNull; /** * An extension of {@link Node}, providing information about @@ -34,7 +33,6 @@ import javax.annotation.concurrent.Immutable; * * @since 2.11 */ -@Immutable public interface LocalizedNode extends Node { /** @@ -44,7 +42,7 @@ public interface LocalizedNode extends Node { * * @return the node this instance is representing */ - @Nonnull + @NonNull Node getNode(); /** @@ -58,7 +56,7 @@ public interface LocalizedNode extends Node { * * @return where the node was inherited from. */ - @Nonnull + @NonNull String getLocation(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/Log.java b/api/src/main/java/me/lucko/luckperms/api/Log.java index 43a05121..d4732adc 100644 --- a/api/src/main/java/me/lucko/luckperms/api/Log.java +++ b/api/src/main/java/me/lucko/luckperms/api/Log.java @@ -25,12 +25,11 @@ package me.lucko.luckperms.api; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.SortedSet; import java.util.UUID; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.Immutable; - /** * Represents the internal LuckPerms log. * @@ -41,7 +40,6 @@ import javax.annotation.concurrent.Immutable; * *

All methods are thread safe, and return immutable and thread safe collections.

*/ -@Immutable public interface Log { /** @@ -49,7 +47,7 @@ public interface Log { * * @return the content */ - @Nonnull + @NonNull SortedSet getContent(); /** @@ -58,8 +56,8 @@ public interface Log { * @param actor the uuid of the actor to filter by * @return the content for the given actor */ - @Nonnull - SortedSet getContent(@Nonnull UUID actor); + @NonNull + SortedSet getContent(@NonNull UUID actor); /** * Gets the log content for a given user @@ -67,8 +65,8 @@ public interface Log { * @param uuid the uuid to filter by * @return all content in this log where the user = uuid */ - @Nonnull - SortedSet getUserHistory(@Nonnull UUID uuid); + @NonNull + SortedSet getUserHistory(@NonNull UUID uuid); /** * Gets the log content for a given group @@ -76,8 +74,8 @@ public interface Log { * @param name the name to filter by * @return all content in this log where the group = name */ - @Nonnull - SortedSet getGroupHistory(@Nonnull String name); + @NonNull + SortedSet getGroupHistory(@NonNull String name); /** * Gets the log content for a given track @@ -85,7 +83,7 @@ public interface Log { * @param name the name to filter by * @return all content in this log where the track = name */ - @Nonnull - SortedSet getTrackHistory(@Nonnull String name); + @NonNull + SortedSet getTrackHistory(@NonNull String name); } diff --git a/api/src/main/java/me/lucko/luckperms/api/LogEntry.java b/api/src/main/java/me/lucko/luckperms/api/LogEntry.java index ea53df67..abc2f672 100644 --- a/api/src/main/java/me/lucko/luckperms/api/LogEntry.java +++ b/api/src/main/java/me/lucko/luckperms/api/LogEntry.java @@ -25,19 +25,17 @@ package me.lucko.luckperms.api; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + import java.util.Optional; import java.util.UUID; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - /** * Represents a logged action. * * @see ActionLogger#newEntryBuilder() for creating an instance */ -@Immutable public interface LogEntry extends Comparable { /** @@ -54,7 +52,7 @@ public interface LogEntry extends Comparable { * * @return the actor id */ - @Nonnull + @NonNull UUID getActor(); /** @@ -62,7 +60,7 @@ public interface LogEntry extends Comparable { * * @return the name of the actor */ - @Nonnull + @NonNull String getActorName(); /** @@ -70,7 +68,7 @@ public interface LogEntry extends Comparable { * * @return the action type */ - @Nonnull + @NonNull Type getType(); /** @@ -80,7 +78,7 @@ public interface LogEntry extends Comparable { * * @return the uuid of acted object */ - @Nonnull + @NonNull Optional getActed(); /** @@ -88,7 +86,7 @@ public interface LogEntry extends Comparable { * * @return the name of the acted object */ - @Nonnull + @NonNull String getActedName(); /** @@ -99,7 +97,7 @@ public interface LogEntry extends Comparable { * * @return the action */ - @Nonnull + @NonNull String getAction(); /** @@ -122,8 +120,7 @@ public interface LogEntry extends Comparable { return this.code; } - @Nonnull - public static Type valueOf(char code) { + public static @NonNull Type valueOf(char code) { switch (code) { case 'U': case 'u': @@ -152,7 +149,7 @@ public interface LogEntry extends Comparable { * @return the builder * @see LogEntry#getTimestamp() */ - @Nonnull + @NonNull Builder setTimestamp(long timestamp); /** @@ -162,8 +159,8 @@ public interface LogEntry extends Comparable { * @return the builder * @see LogEntry#getActor() */ - @Nonnull - Builder setActor(@Nonnull UUID actor); + @NonNull + Builder setActor(@NonNull UUID actor); /** * Sets the actor name of the entry. @@ -172,8 +169,8 @@ public interface LogEntry extends Comparable { * @return the builder * @see LogEntry#getActorName() */ - @Nonnull - Builder setActorName(@Nonnull String actorName); + @NonNull + Builder setActorName(@NonNull String actorName); /** * Sets the type of the entry. @@ -182,8 +179,8 @@ public interface LogEntry extends Comparable { * @return the builder * @see LogEntry#getType() */ - @Nonnull - Builder setType(@Nonnull Type type); + @NonNull + Builder setType(@NonNull Type type); /** * Sets the acted object for the entry. @@ -192,7 +189,7 @@ public interface LogEntry extends Comparable { * @return the builder * @see LogEntry#getActed() */ - @Nonnull + @NonNull Builder setActed(@Nullable UUID acted); /** @@ -202,8 +199,8 @@ public interface LogEntry extends Comparable { * @return the builder * @see LogEntry#getActedName() */ - @Nonnull - Builder setActedName(@Nonnull String actedName); + @NonNull + Builder setActedName(@NonNull String actedName); /** * Sets the action of the entry. @@ -212,15 +209,15 @@ public interface LogEntry extends Comparable { * @return the builder * @see LogEntry#getAction() */ - @Nonnull - Builder setAction(@Nonnull String action); + @NonNull + Builder setAction(@NonNull String action); /** * Creates a {@link LogEntry} instance from the builder. * * @return a new log entry instance */ - @Nonnull + @NonNull LogEntry build(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java b/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java index c37165bc..5df2c2ea 100644 --- a/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java +++ b/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java @@ -37,14 +37,14 @@ import me.lucko.luckperms.api.messenger.MessengerProvider; import me.lucko.luckperms.api.metastacking.MetaStackFactory; import me.lucko.luckperms.api.platform.PlatformInfo; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.CompletableFuture; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - /** * The LuckPerms API. * @@ -62,7 +62,7 @@ public interface LuckPermsApi { * @return the platform info * @since 4.0 */ - @Nonnull + @NonNull PlatformInfo getPlatformInfo(); /** @@ -78,7 +78,7 @@ public interface LuckPermsApi { * @return the user manager * @since 4.0 */ - @Nonnull + @NonNull UserManager getUserManager(); /** @@ -94,7 +94,7 @@ public interface LuckPermsApi { * @return the group manager * @since 4.0 */ - @Nonnull + @NonNull GroupManager getGroupManager(); /** @@ -110,7 +110,7 @@ public interface LuckPermsApi { * @return the track manager * @since 4.0 */ - @Nonnull + @NonNull TrackManager getTrackManager(); /** @@ -125,7 +125,7 @@ public interface LuckPermsApi { * @return a future * @since 4.0 */ - @Nonnull + @NonNull CompletableFuture runUpdateTask(); /** @@ -135,7 +135,7 @@ public interface LuckPermsApi { * @return the event bus * @since 3.0 */ - @Nonnull + @NonNull EventBus getEventBus(); /** @@ -143,7 +143,7 @@ public interface LuckPermsApi { * * @return the configuration */ - @Nonnull + @NonNull LPConfiguration getConfiguration(); /** @@ -155,7 +155,7 @@ public interface LuckPermsApi { * @return a storage instance * @since 2.14 */ - @Nonnull + @NonNull Storage getStorage(); /** @@ -170,7 +170,7 @@ public interface LuckPermsApi { * * @return the messaging service instance, if present. */ - @Nonnull + @NonNull Optional getMessagingService(); /** @@ -182,7 +182,7 @@ public interface LuckPermsApi { * @param messengerProvider the messenger provider. * @since 4.1 */ - void registerMessengerProvider(@Nonnull MessengerProvider messengerProvider); + void registerMessengerProvider(@NonNull MessengerProvider messengerProvider); /** * Gets the {@link ActionLogger}. @@ -193,7 +193,7 @@ public interface LuckPermsApi { * @return the action logger * @since 4.1 */ - @Nonnull + @NonNull ActionLogger getActionLogger(); /** @@ -206,7 +206,7 @@ public interface LuckPermsApi { * @deprecated this feature is now handled internally - and the API returns a * No-op implementation of this class. */ - @Nonnull + @NonNull @Deprecated UuidCache getUuidCache(); @@ -219,7 +219,7 @@ public interface LuckPermsApi { * @return the context manager * @since 4.0 */ - @Nonnull + @NonNull ContextManager getContextManager(); /** @@ -229,7 +229,7 @@ public interface LuckPermsApi { * * @return the node factory */ - @Nonnull + @NonNull NodeFactory getNodeFactory(); /** @@ -242,7 +242,7 @@ public interface LuckPermsApi { * @return the meta stack factory * @since 3.2 */ - @Nonnull + @NonNull MetaStackFactory getMetaStackFactory(); @@ -265,8 +265,7 @@ public interface LuckPermsApi { * @return a {@link User} object, if one matching the uuid is loaded, or null if not * @throws NullPointerException if the uuid is null */ - @Nullable - default User getUser(@Nonnull UUID uuid) { + default @Nullable User getUser(@NonNull UUID uuid) { return getUserManager().getUser(uuid); } @@ -277,8 +276,7 @@ public interface LuckPermsApi { * @return an optional {@link User} object * @throws NullPointerException if the uuid is null */ - @Nonnull - default Optional getUserSafe(@Nonnull UUID uuid) { + default @NonNull Optional getUserSafe(@NonNull UUID uuid) { return getUserManager().getUserOpt(uuid); } @@ -289,8 +287,7 @@ public interface LuckPermsApi { * @return a {@link User} object, if one matching the uuid is loaded, or null if not * @throws NullPointerException if the name is null */ - @Nullable - default User getUser(@Nonnull String name) { + default @Nullable User getUser(@NonNull String name) { return getUserManager().getUser(name); } @@ -301,8 +298,7 @@ public interface LuckPermsApi { * @return an optional {@link User} object * @throws NullPointerException if the name is null */ - @Nonnull - default Optional getUserSafe(@Nonnull String name) { + default @NonNull Optional getUserSafe(@NonNull String name) { return getUserManager().getUserOpt(name); } @@ -311,8 +307,7 @@ public interface LuckPermsApi { * * @return a {@link Set} of {@link User} objects */ - @Nonnull - default Set getUsers() { + default @NonNull Set getUsers() { return getUserManager().getLoadedUsers(); } @@ -323,7 +318,7 @@ public interface LuckPermsApi { * @return true if the user is loaded * @throws NullPointerException if the uuid is null */ - default boolean isUserLoaded(@Nonnull UUID uuid) { + default boolean isUserLoaded(@NonNull UUID uuid) { return getUserManager().isLoaded(uuid); } @@ -333,7 +328,7 @@ public interface LuckPermsApi { * @param user the user to unload * @throws NullPointerException if the user is null */ - default void cleanupUser(@Nonnull User user) { + default void cleanupUser(@NonNull User user) { getUserManager().cleanupUser(user); } @@ -344,8 +339,7 @@ public interface LuckPermsApi { * @return a {@link Group} object, if one matching the name exists, or null if not * @throws NullPointerException if the name is null */ - @Nullable - default Group getGroup(@Nonnull String name) { + default @Nullable Group getGroup(@NonNull String name) { return getGroupManager().getGroup(name); } @@ -358,8 +352,7 @@ public interface LuckPermsApi { * @return an optional {@link Group} object * @throws NullPointerException if the name is null */ - @Nonnull - default Optional getGroupSafe(@Nonnull String name) { + default @NonNull Optional getGroupSafe(@NonNull String name) { return getGroupManager().getGroupOpt(name); } @@ -368,8 +361,7 @@ public interface LuckPermsApi { * * @return a {@link Set} of {@link Group} objects */ - @Nonnull - default Set getGroups() { + default @NonNull Set getGroups() { return getGroupManager().getLoadedGroups(); } @@ -380,7 +372,7 @@ public interface LuckPermsApi { * @return true if the group is loaded * @throws NullPointerException if the name is null */ - default boolean isGroupLoaded(@Nonnull String name) { + default boolean isGroupLoaded(@NonNull String name) { return getGroupManager().isLoaded(name); } @@ -392,8 +384,7 @@ public interface LuckPermsApi { * if not * @throws NullPointerException if the name is null */ - @Nullable - default Track getTrack(@Nonnull String name) { + default @Nullable Track getTrack(@NonNull String name) { return getTrackManager().getTrack(name); } @@ -406,8 +397,7 @@ public interface LuckPermsApi { * @return an optional {@link Track} object * @throws NullPointerException if the name is null */ - @Nonnull - default Optional getTrackSafe(@Nonnull String name) { + default @NonNull Optional getTrackSafe(@NonNull String name) { return getTrackManager().getTrackOpt(name); } @@ -416,8 +406,7 @@ public interface LuckPermsApi { * * @return a {@link Set} of {@link Track} objects */ - @Nonnull - default Set getTracks() { + default @NonNull Set getTracks() { return getTrackManager().getLoadedTracks(); } @@ -428,7 +417,7 @@ public interface LuckPermsApi { * @return true if the track is loaded * @throws NullPointerException if the name is null */ - default boolean isTrackLoaded(@Nonnull String name) { + default boolean isTrackLoaded(@NonNull String name) { return getTrackManager().isLoaded(name); } @@ -438,8 +427,7 @@ public interface LuckPermsApi { * @return a new builder * @since 4.0 */ - @Nonnull - default LogEntry.Builder newLogEntryBuilder() { + default LogEntry.@NonNull Builder newLogEntryBuilder() { return getActionLogger().newEntryBuilder(); } @@ -452,8 +440,7 @@ public interface LuckPermsApi { * @throws NullPointerException if the permission is null * @since 2.6 */ - @Nonnull - default Node.Builder buildNode(@Nonnull String permission) throws IllegalArgumentException { + default Node.@NonNull Builder buildNode(@NonNull String permission) throws IllegalArgumentException { return getNodeFactory().newBuilder(permission); } @@ -463,7 +450,7 @@ public interface LuckPermsApi { * @param calculator the context calculator to register. The type MUST be the player class of the platform. * @throws ClassCastException if the type is not the player class of the platform. */ - default void registerContextCalculator(@Nonnull ContextCalculator calculator) { + default void registerContextCalculator(@NonNull ContextCalculator calculator) { getContextManager().registerCalculator(calculator); } @@ -475,8 +462,7 @@ public interface LuckPermsApi { * @param user the user to get contexts for * @return an optional containing contexts. Will return empty if the user is not online. */ - @Nonnull - default Optional getContextForUser(@Nonnull User user) { + default @NonNull Optional getContextForUser(@NonNull User user) { return getContextManager().lookupApplicableContexts(user); } @@ -487,8 +473,7 @@ public interface LuckPermsApi { * @return a set of contexts. * @since 2.17 */ - @Nonnull - default ContextSet getContextForPlayer(@Nonnull Object player) { + default @NonNull ContextSet getContextForPlayer(@NonNull Object player) { return getContextManager().getApplicableContext(player); } @@ -499,8 +484,7 @@ public interface LuckPermsApi { * @return a set of contexts. * @since 3.3 */ - @Nonnull - default Contexts getContextsForPlayer(@Nonnull Object player) { + default @NonNull Contexts getContextsForPlayer(@NonNull Object player) { return getContextManager().getApplicableContexts(player); } diff --git a/api/src/main/java/me/lucko/luckperms/api/MessagingService.java b/api/src/main/java/me/lucko/luckperms/api/MessagingService.java index e0b0fa3e..a35db6b3 100644 --- a/api/src/main/java/me/lucko/luckperms/api/MessagingService.java +++ b/api/src/main/java/me/lucko/luckperms/api/MessagingService.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.api; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * A means to push changes to other servers using the platforms networking @@ -71,6 +71,6 @@ public interface MessagingService { * @param user the user to push the update for * @since 4.1 */ - void pushUserUpdate(@Nonnull User user); + void pushUserUpdate(@NonNull User user); } diff --git a/api/src/main/java/me/lucko/luckperms/api/Node.java b/api/src/main/java/me/lucko/luckperms/api/Node.java index 7963b4e9..3d6de6ed 100644 --- a/api/src/main/java/me/lucko/luckperms/api/Node.java +++ b/api/src/main/java/me/lucko/luckperms/api/Node.java @@ -37,6 +37,9 @@ import me.lucko.luckperms.api.nodetype.types.PrefixType; import me.lucko.luckperms.api.nodetype.types.SuffixType; import me.lucko.luckperms.api.nodetype.types.WeightType; +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; @@ -46,10 +49,6 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - /** * Represents a LuckPerms "node". * @@ -104,7 +103,6 @@ import javax.annotation.concurrent.Immutable; * @see NodeFactory for obtaining and constructing instances. * @since 2.6 */ -@Immutable public interface Node { /** @@ -115,7 +113,7 @@ public interface Node { * * @return the actual permission node */ - @Nonnull + @NonNull String getPermission(); /** @@ -132,8 +130,7 @@ public interface Node { * * @return the value of this node as a Tristate */ - @Nonnull - default Tristate getTristate() { + default @NonNull Tristate getTristate() { return Tristate.fromBoolean(getValue()); } @@ -163,7 +160,7 @@ public interface Node { * * @return an {@link Optional} containing the server, if one is defined */ - @Nonnull + @NonNull Optional getServer(); /** @@ -171,7 +168,7 @@ public interface Node { * * @return an {@link Optional} containing the world, if one is defined */ - @Nonnull + @NonNull Optional getWorld(); /** @@ -211,7 +208,7 @@ public interface Node { * @return true if the node should apply * @since 2.13 */ - boolean shouldApplyWithContext(@Nonnull ContextSet contextSet); + boolean shouldApplyWithContext(@NonNull ContextSet contextSet); /** * Resolves any shorthand parts of this node and returns the full list of @@ -221,7 +218,7 @@ public interface Node { * * @return a list of full nodes */ - @Nonnull + @NonNull List resolveShorthand(); /** @@ -254,7 +251,7 @@ public interface Node { * @return the {@link Date} when this node will expire * @throws IllegalStateException if the node is not temporary */ - @Nonnull + @NonNull Date getExpiry() throws IllegalStateException; /** @@ -282,7 +279,7 @@ public interface Node { * @return the extra contexts required for this node to apply * @since 2.13 */ - @Nonnull + @NonNull ContextSet getContexts(); /** @@ -294,7 +291,7 @@ public interface Node { * @see Contexts#SERVER_KEY * @see Contexts#WORLD_KEY */ - @Nonnull + @NonNull ContextSet getFullContexts(); /** @@ -369,8 +366,7 @@ public interface Node { * @return the name of the group * @throws IllegalStateException if this node doesn't have {@link InheritanceType} data */ - @Nonnull - default String getGroupName() throws IllegalStateException { + default @NonNull String getGroupName() throws IllegalStateException { return typeData(InheritanceType.KEY).getGroupName(); } @@ -390,8 +386,7 @@ public interface Node { * @return the meta entry * @throws IllegalStateException if this node doesn't have {@link MetaType} data */ - @Nonnull - default Map.Entry getMeta() throws IllegalStateException { + default Map.@NonNull Entry getMeta() throws IllegalStateException { return typeData(MetaType.KEY); } @@ -411,8 +406,7 @@ public interface Node { * @return the meta entry * @throws IllegalStateException if this node doesn't have {@link PrefixType} data */ - @Nonnull - default Map.Entry getPrefix() throws IllegalStateException { + default Map.@NonNull Entry getPrefix() throws IllegalStateException { return typeData(PrefixType.KEY).getAsEntry(); } @@ -432,8 +426,7 @@ public interface Node { * @return the meta entry * @throws IllegalStateException if this node doesn't have {@link SuffixType} data */ - @Nonnull - default Map.Entry getSuffix() throws IllegalStateException { + default Map.@NonNull Entry getSuffix() throws IllegalStateException { return typeData(SuffixType.KEY).getAsEntry(); } @@ -481,7 +474,7 @@ public interface Node { * @see StandardNodeEquality#IGNORE_VALUE */ @Deprecated - default boolean equalsIgnoringValue(@Nonnull Node other) { + default boolean equalsIgnoringValue(@NonNull Node other) { return equals(other, StandardNodeEquality.IGNORE_VALUE); } @@ -495,7 +488,7 @@ public interface Node { * @see StandardNodeEquality#IGNORE_EXPIRY_TIME_AND_VALUE */ @Deprecated - default boolean almostEquals(@Nonnull Node other) { + default boolean almostEquals(@NonNull Node other) { return equals(other, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE); } @@ -510,7 +503,7 @@ public interface Node { * @see StandardNodeEquality#IGNORE_VALUE_OR_IF_TEMPORARY */ @Deprecated - default boolean equalsIgnoringValueOrTemp(@Nonnull Node other) { + default boolean equalsIgnoringValueOrTemp(@NonNull Node other) { return equals(other, StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY); } @@ -539,7 +532,7 @@ public interface Node { * @return the builder * @since 4.2 */ - Builder copyFrom(@Nonnull Node node); + Builder copyFrom(@NonNull Node node); /** * Sets the value of negated for the node. @@ -548,7 +541,7 @@ public interface Node { * @return the builder * @see Node#isNegated() */ - @Nonnull + @NonNull Builder setNegated(boolean negated); /** @@ -558,7 +551,7 @@ public interface Node { * @return the builder * @see Node#getValue() */ - @Nonnull + @NonNull Builder setValue(boolean value); /** @@ -571,7 +564,7 @@ public interface Node { * @return the builder * @see Node#isOverride() */ - @Nonnull + @NonNull Builder setOverride(boolean override); /** @@ -584,7 +577,7 @@ public interface Node { * @return the builder * @see Node#getExpiryUnixTime() */ - @Nonnull + @NonNull Builder setExpiry(long expiryUnixTimestamp); /** @@ -598,8 +591,7 @@ public interface Node { * @return the builder * @since 4.2 */ - @Nonnull - default Builder setExpiry(long duration, TimeUnit unit) { + default @NonNull Builder setExpiry(long duration, TimeUnit unit) { Preconditions.checkArgument(duration > 0, "duration must be positive"); long seconds = Objects.requireNonNull(unit, "unit").toSeconds(duration); long timeNow = System.currentTimeMillis() / 1000L; @@ -612,7 +604,7 @@ public interface Node { * @return the builder * @since 4.2 */ - @Nonnull + @NonNull Builder clearExpiry(); /** @@ -622,7 +614,7 @@ public interface Node { * @return the builder * @see Node#getWorld() */ - @Nonnull + @NonNull Builder setWorld(@Nullable String world); /** @@ -632,7 +624,7 @@ public interface Node { * @return the builder * @see Node#getServer() */ - @Nonnull + @NonNull Builder setServer(@Nullable String server); /** @@ -644,8 +636,8 @@ public interface Node { * @see ContextSet * @see Node#getContexts() */ - @Nonnull - Builder withExtraContext(@Nonnull String key, @Nonnull String value); + @NonNull + Builder withExtraContext(@NonNull String key, @NonNull String value); /** * Appends extra contexts onto the node. @@ -655,8 +647,8 @@ public interface Node { * @see ContextSet * @see Node#getContexts() */ - @Nonnull - Builder withExtraContext(@Nonnull Map map); + @NonNull + Builder withExtraContext(@NonNull Map map); /** * Appends extra contexts onto the node. @@ -666,8 +658,8 @@ public interface Node { * @see ContextSet * @see Node#getContexts() */ - @Nonnull - Builder withExtraContext(@Nonnull Set> context); + @NonNull + Builder withExtraContext(@NonNull Set> context); /** * Appends an extra context onto the node. @@ -677,8 +669,8 @@ public interface Node { * @see ContextSet * @see Node#getContexts() */ - @Nonnull - Builder withExtraContext(@Nonnull Map.Entry entry); + @NonNull + Builder withExtraContext(Map.@NonNull Entry entry); /** * Appends extra contexts onto the node. @@ -688,8 +680,8 @@ public interface Node { * @see ContextSet * @see Node#getContexts() */ - @Nonnull - Builder withExtraContext(@Nonnull ContextSet contextSet); + @NonNull + Builder withExtraContext(@NonNull ContextSet contextSet); /** * Sets the extra contexts for the node. @@ -700,15 +692,15 @@ public interface Node { * @see Node#getContexts() * @since 4.2 */ - @Nonnull - Builder setExtraContext(@Nonnull ContextSet contextSet); + @NonNull + Builder setExtraContext(@NonNull ContextSet contextSet); /** * Creates a {@link Node} instance from the builder. * * @return a new node instance */ - @Nonnull + @NonNull Node build(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/NodeEqualityPredicate.java b/api/src/main/java/me/lucko/luckperms/api/NodeEqualityPredicate.java index 4c7250d2..e3d0500a 100644 --- a/api/src/main/java/me/lucko/luckperms/api/NodeEqualityPredicate.java +++ b/api/src/main/java/me/lucko/luckperms/api/NodeEqualityPredicate.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.api; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * A rule for determining if two nodes are equal. @@ -47,6 +47,6 @@ public interface NodeEqualityPredicate { * @param o2 the second node * @return true if equal */ - boolean areEqual(@Nonnull Node o1, @Nonnull Node o2); + boolean areEqual(@NonNull Node o1, @NonNull Node o2); } diff --git a/api/src/main/java/me/lucko/luckperms/api/NodeFactory.java b/api/src/main/java/me/lucko/luckperms/api/NodeFactory.java index e62554ab..f97c405e 100644 --- a/api/src/main/java/me/lucko/luckperms/api/NodeFactory.java +++ b/api/src/main/java/me/lucko/luckperms/api/NodeFactory.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.api; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Assists with constructing {@link Node} instances. @@ -41,8 +41,7 @@ public interface NodeFactory { * @return a node builder instance * @throws NullPointerException if the permission is null */ - @Nonnull - Node.Builder newBuilder(@Nonnull String permission); + Node.@NonNull Builder newBuilder(@NonNull String permission); /** * Creates a node builder instance from an existing node @@ -51,8 +50,7 @@ public interface NodeFactory { * @return a node builder instance * @throws NullPointerException if the other node is null */ - @Nonnull - Node.Builder newBuilderFromExisting(@Nonnull Node other); + Node.@NonNull Builder newBuilderFromExisting(@NonNull Node other); /** @@ -64,8 +62,7 @@ public interface NodeFactory { * @throws IllegalStateException if the group instance was not obtained from LuckPerms. * @since 3.1 */ - @Nonnull - Node.Builder makeGroupNode(@Nonnull Group group); + Node.@NonNull Builder makeGroupNode(@NonNull Group group); /** * Creates a node builder from a group @@ -75,8 +72,7 @@ public interface NodeFactory { * @throws NullPointerException if the groupName is null * @since 4.0 */ - @Nonnull - Node.Builder makeGroupNode(@Nonnull String groupName); + Node.@NonNull Builder makeGroupNode(@NonNull String groupName); /** * Creates a node builder from a key value pair @@ -86,8 +82,7 @@ public interface NodeFactory { * @return a node builder instance * @throws NullPointerException if the key or value is null */ - @Nonnull - Node.Builder makeMetaNode(@Nonnull String key, @Nonnull String value); + Node.@NonNull Builder makeMetaNode(@NonNull String key, @NonNull String value); /** * Creates a node builder for the given chat meta type @@ -99,8 +94,7 @@ public interface NodeFactory { * @throws NullPointerException if the type or value is null * @since 3.2 */ - @Nonnull - Node.Builder makeChatMetaNode(@Nonnull ChatMetaType type, int priority, @Nonnull String value); + Node.@NonNull Builder makeChatMetaNode(@NonNull ChatMetaType type, int priority, @NonNull String value); /** * Creates a node builder from a prefix string and priority @@ -110,8 +104,7 @@ public interface NodeFactory { * @return a node builder instance * @throws NullPointerException if the prefix is null */ - @Nonnull - Node.Builder makePrefixNode(int priority, @Nonnull String prefix); + Node.@NonNull Builder makePrefixNode(int priority, @NonNull String prefix); /** * Creates a node builder from a prefix string and priority @@ -121,7 +114,6 @@ public interface NodeFactory { * @return a node builder instance * @throws NullPointerException if the suffix is null */ - @Nonnull - Node.Builder makeSuffixNode(int priority, @Nonnull String suffix); + Node.@NonNull Builder makeSuffixNode(int priority, @NonNull String suffix); } diff --git a/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java b/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java index 8916adee..7e37b8ce 100644 --- a/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java +++ b/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java @@ -37,6 +37,8 @@ import me.lucko.luckperms.api.nodetype.types.MetaType; import me.lucko.luckperms.api.nodetype.types.PrefixType; import me.lucko.luckperms.api.nodetype.types.SuffixType; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.List; import java.util.Map; import java.util.Set; @@ -45,8 +47,6 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.function.Predicate; -import javax.annotation.Nonnull; - /** * Generic superinterface for an object which holds permissions. */ @@ -68,7 +68,7 @@ public interface PermissionHolder { * * @return the identifier for this object. Either a uuid string or name. */ - @Nonnull + @NonNull String getObjectName(); /** @@ -86,7 +86,7 @@ public interface PermissionHolder { * @return a friendly identifier for this holder * @since 3.2 */ - @Nonnull + @NonNull String getFriendlyName(); /** @@ -95,7 +95,7 @@ public interface PermissionHolder { * @return the holders cached data. * @since 3.2 */ - @Nonnull + @NonNull CachedData getCachedData(); /** @@ -107,7 +107,7 @@ public interface PermissionHolder { * @return the task future * @since 4.0 */ - @Nonnull + @NonNull CompletableFuture refreshCachedData(); /** @@ -119,7 +119,7 @@ public interface PermissionHolder { * @return the holders own permissions * @since 3.3 */ - @Nonnull + @NonNull ImmutableSetMultimap getNodes(); /** @@ -132,7 +132,7 @@ public interface PermissionHolder { * @return the holders own permissions * @since 3.3 */ - @Nonnull + @NonNull ImmutableSetMultimap getTransientNodes(); /** @@ -150,7 +150,7 @@ public interface PermissionHolder { * @return a list of the holders own nodes. * @since 3.3 */ - @Nonnull + @NonNull List getOwnNodes(); /** @@ -166,7 +166,7 @@ public interface PermissionHolder { * @return an immutable set of permissions in priority order * @since 2.6 */ - @Nonnull + @NonNull SortedSet getPermissions(); /** @@ -184,7 +184,7 @@ public interface PermissionHolder { * @return a set of nodes * @since 2.6 */ - @Nonnull + @NonNull Set getEnduringPermissions(); /** @@ -201,7 +201,7 @@ public interface PermissionHolder { * @return a set of nodes * @since 2.6 */ - @Nonnull + @NonNull Set getTransientPermissions(); /** @@ -217,7 +217,7 @@ public interface PermissionHolder { * @return a set of permanent nodes * @since 2.6 */ - @Nonnull + @NonNull Set getPermanentPermissionNodes(); /** @@ -233,7 +233,7 @@ public interface PermissionHolder { * @return a set of temporary nodes * @since 2.6 */ - @Nonnull + @NonNull Set getTemporaryPermissionNodes(); /** @@ -252,8 +252,8 @@ public interface PermissionHolder { * @return a list of nodes * @since 3.3 */ - @Nonnull - List resolveInheritances(@Nonnull Contexts contexts); + @NonNull + List resolveInheritances(@NonNull Contexts contexts); /** * Recursively resolves this holders permissions. @@ -273,7 +273,7 @@ public interface PermissionHolder { * @return a list of nodes * @since 3.3 */ - @Nonnull + @NonNull List resolveInheritances(); /** @@ -290,8 +290,8 @@ public interface PermissionHolder { * @throws NullPointerException if the context is null * @since 2.11 */ - @Nonnull - SortedSet getAllNodes(@Nonnull Contexts contexts); + @NonNull + SortedSet getAllNodes(@NonNull Contexts contexts); /** * Gets a mutable sorted set of the nodes that this object has and inherits. @@ -305,7 +305,7 @@ public interface PermissionHolder { * @throws NullPointerException if the context is null * @since 3.3 */ - @Nonnull + @NonNull SortedSet getAllNodes(); /** @@ -319,8 +319,8 @@ public interface PermissionHolder { * @throws NullPointerException if the context is null * @since 2.11 */ - @Nonnull - Set getAllNodesFiltered(@Nonnull Contexts contexts); + @NonNull + Set getAllNodesFiltered(@NonNull Contexts contexts); /** * Converts the output of {@link #getAllNodesFiltered(Contexts)} into string and boolean form, @@ -330,8 +330,8 @@ public interface PermissionHolder { * @param convertToLowercase if the keys should be made lowercase whilst being exported * @return a mutable map of permissions */ - @Nonnull - Map exportNodes(@Nonnull Contexts contexts, boolean convertToLowercase); + @NonNull + Map exportNodes(@NonNull Contexts contexts, boolean convertToLowercase); /** * Removes any temporary permissions that have expired. @@ -352,8 +352,8 @@ public interface PermissionHolder { * @throws NullPointerException if the node is null * @since 4.1 */ - @Nonnull - Tristate hasPermission(@Nonnull Node node, @Nonnull NodeEqualityPredicate equalityPredicate); + @NonNull + Tristate hasPermission(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate); /** * Checks to see if the object has a certain permission. @@ -366,8 +366,8 @@ public interface PermissionHolder { * @throws NullPointerException if the node is null * @since 4.1 */ - @Nonnull - Tristate hasTransientPermission(@Nonnull Node node, @Nonnull NodeEqualityPredicate equalityPredicate); + @NonNull + Tristate hasTransientPermission(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate); /** * Checks to see if the object inherits a certain permission. @@ -380,8 +380,8 @@ public interface PermissionHolder { * @throws NullPointerException if the node is null * @since 4.1 */ - @Nonnull - Tristate inheritsPermission(@Nonnull Node node, @Nonnull NodeEqualityPredicate equalityPredicate); + @NonNull + Tristate inheritsPermission(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate); /** * Checks to see if the object has a certain permission. @@ -393,8 +393,8 @@ public interface PermissionHolder { * @throws NullPointerException if the node is null * @since 2.6 */ - @Nonnull - Tristate hasPermission(@Nonnull Node node); + @NonNull + Tristate hasPermission(@NonNull Node node); /** * Checks to see if the object has a certain permission. @@ -406,8 +406,8 @@ public interface PermissionHolder { * @throws NullPointerException if the node is null * @since 2.6 */ - @Nonnull - Tristate hasTransientPermission(@Nonnull Node node); + @NonNull + Tristate hasTransientPermission(@NonNull Node node); /** * Checks to see if the object inherits a certain permission. @@ -419,8 +419,8 @@ public interface PermissionHolder { * @throws NullPointerException if the node is null * @since 2.6 */ - @Nonnull - Tristate inheritsPermission(@Nonnull Node node); + @NonNull + Tristate inheritsPermission(@NonNull Node node); /** * Check to see if this holder inherits another group in the global context. @@ -435,7 +435,7 @@ public interface PermissionHolder { * @throws IllegalStateException if the group instance was not obtained from LuckPerms. * @since 4.0 */ - boolean inheritsGroup(@Nonnull Group group); + boolean inheritsGroup(@NonNull Group group); /** * Check to see if this holder inherits another group. @@ -449,7 +449,7 @@ public interface PermissionHolder { * @throws IllegalStateException if the group instance was not obtained from LuckPerms. * @since 4.0 */ - boolean inheritsGroup(@Nonnull Group group, @Nonnull ContextSet contextSet); + boolean inheritsGroup(@NonNull Group group, @NonNull ContextSet contextSet); /** * Sets a permission node for the permission holder. @@ -472,8 +472,8 @@ public interface PermissionHolder { * @throws NullPointerException if the node is null * @since 4.0 */ - @Nonnull - DataMutateResult setPermission(@Nonnull Node node); + @NonNull + DataMutateResult setPermission(@NonNull Node node); /** * Sets a permission node for the permission holder. @@ -497,8 +497,8 @@ public interface PermissionHolder { * @throws NullPointerException if the node is null * @since 4.3 */ - @Nonnull - TemporaryDataMutateResult setPermission(@Nonnull Node node, @Nonnull TemporaryMergeBehaviour temporaryMergeBehaviour); + @NonNull + TemporaryDataMutateResult setPermission(@NonNull Node node, @NonNull TemporaryMergeBehaviour temporaryMergeBehaviour); /** * Sets a transient permission for the permission holder. @@ -521,8 +521,8 @@ public interface PermissionHolder { * @throws NullPointerException if the node is null * @since 4.0 */ - @Nonnull - DataMutateResult setTransientPermission(@Nonnull Node node); + @NonNull + DataMutateResult setTransientPermission(@NonNull Node node); /** * Sets a transient permission for the permission holder. @@ -546,8 +546,8 @@ public interface PermissionHolder { * @throws NullPointerException if the node is null * @since 4.3 */ - @Nonnull - TemporaryDataMutateResult setTransientPermission(@Nonnull Node node, @Nonnull TemporaryMergeBehaviour temporaryMergeBehaviour); + @NonNull + TemporaryDataMutateResult setTransientPermission(@NonNull Node node, @NonNull TemporaryMergeBehaviour temporaryMergeBehaviour); /** * Unsets a permission for the permission holder. @@ -570,8 +570,8 @@ public interface PermissionHolder { * @throws NullPointerException if the node is null * @since 4.0 */ - @Nonnull - DataMutateResult unsetPermission(@Nonnull Node node); + @NonNull + DataMutateResult unsetPermission(@NonNull Node node); /** * Unsets a transient permission for the permission holder. @@ -583,8 +583,8 @@ public interface PermissionHolder { * @throws NullPointerException if the node is null * @since 4.0 */ - @Nonnull - DataMutateResult unsetTransientPermission(@Nonnull Node node); + @NonNull + DataMutateResult unsetTransientPermission(@NonNull Node node); /** * Clears any nodes from the holder which pass the predicate. @@ -605,7 +605,7 @@ public interface PermissionHolder { * @param test the predicate to test for nodes which should be removed * @since 3.2 */ - void clearMatching(@Nonnull Predicate test); + void clearMatching(@NonNull Predicate test); /** * Clears any transient nodes from the holder which pass the predicate. @@ -624,7 +624,7 @@ public interface PermissionHolder { * @param test the predicate to test for nodes which should be removed * @since 3.2 */ - void clearMatchingTransient(@Nonnull Predicate test); + void clearMatchingTransient(@NonNull Predicate test); /** * Clears all nodes held by the permission holder. @@ -661,7 +661,7 @@ public interface PermissionHolder { * @param contextSet the contexts to filter by * @since 3.2 */ - void clearNodes(@Nonnull ContextSet contextSet); + void clearNodes(@NonNull ContextSet contextSet); /** * Clears all parent groups. @@ -698,7 +698,7 @@ public interface PermissionHolder { * @param contextSet the contexts to filter by * @since 3.2 */ - void clearParents(@Nonnull ContextSet contextSet); + void clearParents(@NonNull ContextSet contextSet); /** * Clears all meta held by the permission holder. @@ -741,7 +741,7 @@ public interface PermissionHolder { * @param contextSet the contexts to filter by * @since 3.2 */ - void clearMeta(@Nonnull ContextSet contextSet); + void clearMeta(@NonNull ContextSet contextSet); /** * Clears all transient nodes the permission holder has. @@ -757,9 +757,8 @@ public interface PermissionHolder { * @since 3.1 * @deprecated now forwards to {@link #setPermission(Node)}. */ - @Nonnull @Deprecated - default DataMutateResult setPermissionUnchecked(@Nonnull Node node) { + default @NonNull DataMutateResult setPermissionUnchecked(@NonNull Node node) { return setPermission(node); } @@ -772,9 +771,8 @@ public interface PermissionHolder { * @since 3.1 * @deprecated now forwards to {@link #setTransientPermission(Node)} */ - @Nonnull @Deprecated - default DataMutateResult setTransientPermissionUnchecked(@Nonnull Node node) { + default @NonNull DataMutateResult setTransientPermissionUnchecked(@NonNull Node node) { return setTransientPermission(node); } @@ -787,9 +785,8 @@ public interface PermissionHolder { * @since 3.1 * @deprecated now forwards to {@link #unsetPermission(Node)} */ - @Nonnull @Deprecated - default DataMutateResult unsetPermissionUnchecked(@Nonnull Node node) { + default @NonNull DataMutateResult unsetPermissionUnchecked(@NonNull Node node) { return unsetPermission(node); } @@ -802,9 +799,8 @@ public interface PermissionHolder { * @since 3.1 * @deprecated now forwards to {@link #unsetTransientPermission(Node)} */ - @Nonnull @Deprecated - default DataMutateResult unsetTransientPermissionUnchecked(@Nonnull Node node) { + default @NonNull DataMutateResult unsetTransientPermissionUnchecked(@NonNull Node node) { return unsetTransientPermission(node); } diff --git a/api/src/main/java/me/lucko/luckperms/api/PlayerSaveResult.java b/api/src/main/java/me/lucko/luckperms/api/PlayerSaveResult.java index 37067a59..8b74373f 100644 --- a/api/src/main/java/me/lucko/luckperms/api/PlayerSaveResult.java +++ b/api/src/main/java/me/lucko/luckperms/api/PlayerSaveResult.java @@ -27,12 +27,12 @@ package me.lucko.luckperms.api; import me.lucko.luckperms.api.manager.UserManager; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + import java.util.Set; import java.util.UUID; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - /** * Encapsulates the result of an operation to save uuid data about a player. * @@ -48,7 +48,7 @@ public interface PlayerSaveResult { * * @return the status */ - @Nonnull + @NonNull Set getStatus(); /** @@ -57,7 +57,7 @@ public interface PlayerSaveResult { * @param status the status to check for * @return if the result includes the status */ - boolean includes(@Nonnull Status status); + boolean includes(@NonNull Status status); /** * Gets the old username involved in the result diff --git a/api/src/main/java/me/lucko/luckperms/api/PromotionResult.java b/api/src/main/java/me/lucko/luckperms/api/PromotionResult.java index b1bcf819..a3e61e17 100644 --- a/api/src/main/java/me/lucko/luckperms/api/PromotionResult.java +++ b/api/src/main/java/me/lucko/luckperms/api/PromotionResult.java @@ -25,9 +25,9 @@ package me.lucko.luckperms.api; -import java.util.Optional; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Optional; /** * Encapsulates the result of {@link User}s promotion along a {@link Track}. @@ -41,7 +41,7 @@ public interface PromotionResult extends MutateResult { * * @return the status */ - @Nonnull + @NonNull Status getStatus(); @Override @@ -57,7 +57,7 @@ public interface PromotionResult extends MutateResult { * * @return the group the user was promoted from. */ - @Nonnull + @NonNull Optional getGroupFrom(); /** @@ -71,7 +71,7 @@ public interface PromotionResult extends MutateResult { * * @return the group the user was promoted to. */ - @Nonnull + @NonNull Optional getGroupTo(); /** diff --git a/api/src/main/java/me/lucko/luckperms/api/StandardNodeEquality.java b/api/src/main/java/me/lucko/luckperms/api/StandardNodeEquality.java index b389802f..2efed101 100644 --- a/api/src/main/java/me/lucko/luckperms/api/StandardNodeEquality.java +++ b/api/src/main/java/me/lucko/luckperms/api/StandardNodeEquality.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.api; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Standard {@link NodeEqualityPredicate}s. @@ -72,7 +72,7 @@ public enum StandardNodeEquality implements NodeEqualityPredicate { IGNORE_VALUE_OR_IF_TEMPORARY; @Override - public boolean areEqual(@Nonnull Node o1, @Nonnull Node o2) { + public boolean areEqual(@NonNull Node o1, @NonNull Node o2) { return o1.standardEquals(o2, this); } } diff --git a/api/src/main/java/me/lucko/luckperms/api/Storage.java b/api/src/main/java/me/lucko/luckperms/api/Storage.java index 8ae72eec..64d5e099 100644 --- a/api/src/main/java/me/lucko/luckperms/api/Storage.java +++ b/api/src/main/java/me/lucko/luckperms/api/Storage.java @@ -29,15 +29,15 @@ import me.lucko.luckperms.api.manager.GroupManager; import me.lucko.luckperms.api.manager.TrackManager; import me.lucko.luckperms.api.manager.UserManager; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + import java.util.List; import java.util.Set; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - /** * A means of loading and saving permission data to/from the backend. * @@ -50,7 +50,7 @@ public interface Storage { * * @return the name of the implementation */ - @Nonnull + @NonNull String getName(); /** @@ -70,9 +70,9 @@ public interface Storage { * @throws NullPointerException if entry is null * @deprecated in favour of {@link ActionLogger#submit(LogEntry)}. */ - @Nonnull + @NonNull @Deprecated - CompletableFuture logAction(@Nonnull LogEntry entry); + CompletableFuture logAction(@NonNull LogEntry entry); /** * Loads and returns the entire log from storage @@ -80,7 +80,7 @@ public interface Storage { * @return a log instance, could be null if loading failed * @deprecated in favour of {@link ActionLogger#getLog()} */ - @Nonnull + @NonNull @Deprecated CompletableFuture getLog(); @@ -93,9 +93,9 @@ public interface Storage { * @throws NullPointerException if uuid is null * @deprecated in favour of {@link UserManager#loadUser(UUID, String)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture loadUser(@Nonnull UUID uuid, @Nullable String username); + CompletableFuture loadUser(@NonNull UUID uuid, @Nullable String username); /** * Loads a user's data from the main storage into the plugins local storage. @@ -105,9 +105,8 @@ public interface Storage { * @throws NullPointerException if uuid is null * @deprecated in favour of {@link UserManager#loadUser(UUID)} */ - @Nonnull @Deprecated - default CompletableFuture loadUser(@Nonnull UUID uuid) { + default @NonNull CompletableFuture loadUser(@NonNull UUID uuid) { return loadUser(uuid, null); } @@ -122,9 +121,9 @@ public interface Storage { * @throws IllegalStateException if the user instance was not obtained from LuckPerms. * @deprecated in favour of {@link UserManager#saveUser(User)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture saveUser(@Nonnull User user); + CompletableFuture saveUser(@NonNull User user); /** * Gets a set all "unique" user UUIDs. @@ -134,7 +133,7 @@ public interface Storage { * @return a set of uuids, or null if the operation failed. * @deprecated in favour of {@link UserManager#getUniqueUsers()} */ - @Nonnull + @NonNull @Deprecated CompletableFuture> getUniqueUsers(); @@ -147,9 +146,9 @@ public interface Storage { * @since 2.17 * @deprecated in favour of {@link UserManager#getWithPermission(String)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture>> getUsersWithPermission(@Nonnull String permission); + CompletableFuture>> getUsersWithPermission(@NonNull String permission); /** * Creates and loads a group into the plugins local storage @@ -160,9 +159,9 @@ public interface Storage { * @throws IllegalArgumentException if the name is invalid * @deprecated in favour of {@link GroupManager#createAndLoadGroup(String)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture createAndLoadGroup(@Nonnull String name); + CompletableFuture createAndLoadGroup(@NonNull String name); /** * Loads a group into the plugins local storage. @@ -173,9 +172,9 @@ public interface Storage { * @throws IllegalArgumentException if the name is invalid * @deprecated in favour of {@link GroupManager#loadGroup(String)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture loadGroup(@Nonnull String name); + CompletableFuture loadGroup(@NonNull String name); /** * Loads all groups from the storage into memory @@ -183,7 +182,7 @@ public interface Storage { * @return true if the operation completed successfully. * @deprecated in favour of {@link GroupManager#loadAllGroups()} */ - @Nonnull + @NonNull @Deprecated CompletableFuture loadAllGroups(); @@ -198,9 +197,9 @@ public interface Storage { * @throws IllegalStateException if the group instance was not obtained from LuckPerms. * @deprecated in favour of {@link GroupManager#saveGroup(Group)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture saveGroup(@Nonnull Group group); + CompletableFuture saveGroup(@NonNull Group group); /** * Permanently deletes a group from storage. @@ -211,9 +210,9 @@ public interface Storage { * @throws IllegalStateException if the group instance was not obtained from LuckPerms. * @deprecated in favour of {@link GroupManager#deleteGroup(Group)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture deleteGroup(@Nonnull Group group); + CompletableFuture deleteGroup(@NonNull Group group); /** * Searches for a list of groups with a given permission. @@ -224,9 +223,9 @@ public interface Storage { * @since 2.17 * @deprecated in favour of {@link GroupManager#getWithPermission(String)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture>> getGroupsWithPermission(@Nonnull String permission); + CompletableFuture>> getGroupsWithPermission(@NonNull String permission); /** * Creates and loads a track into the plugins local storage @@ -237,9 +236,9 @@ public interface Storage { * @throws IllegalArgumentException if the name is invalid * @deprecated in favour of {@link TrackManager#createAndLoadTrack(String)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture createAndLoadTrack(@Nonnull String name); + CompletableFuture createAndLoadTrack(@NonNull String name); /** * Loads a track into the plugins local storage. @@ -250,9 +249,9 @@ public interface Storage { * @throws IllegalArgumentException if the name is invalid * @deprecated in favour of {@link TrackManager#loadTrack(String)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture loadTrack(@Nonnull String name); + CompletableFuture loadTrack(@NonNull String name); /** * Loads all tracks from the storage into memory @@ -260,7 +259,7 @@ public interface Storage { * @return true if the operation completed successfully. * @deprecated in favour of {@link TrackManager#loadAllTracks()} */ - @Nonnull + @NonNull @Deprecated CompletableFuture loadAllTracks(); @@ -273,9 +272,9 @@ public interface Storage { * @throws IllegalStateException if the track instance was not obtained from LuckPerms. * @deprecated in favour of {@link TrackManager#saveTrack(Track)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture saveTrack(@Nonnull Track track); + CompletableFuture saveTrack(@NonNull Track track); /** * Permanently deletes a track from storage @@ -286,9 +285,9 @@ public interface Storage { * @throws IllegalStateException if the track instance was not obtained from LuckPerms. * @deprecated in favour of {@link TrackManager#deleteTrack(Track)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture deleteTrack(@Nonnull Track track); + CompletableFuture deleteTrack(@NonNull Track track); /** * Saves UUID caching data to the global cache @@ -300,8 +299,8 @@ public interface Storage { * @throws IllegalArgumentException if the username is invalid * @deprecated in favour of {@link UserManager#savePlayerData(UUID, String)} */ - @Nonnull - CompletableFuture saveUUIDData(@Nonnull String username, @Nonnull UUID uuid); + @NonNull + CompletableFuture saveUUIDData(@NonNull String username, @NonNull UUID uuid); /** * Gets a UUID from a username @@ -312,8 +311,8 @@ public interface Storage { * @throws IllegalArgumentException if the username is invalid * @deprecated in favour of {@link UserManager#lookupUuid(String)} */ - @Nonnull - CompletableFuture getUUID(@Nonnull String username); + @NonNull + CompletableFuture getUUID(@NonNull String username); /** * Gets a username from a UUID @@ -324,9 +323,9 @@ public interface Storage { * @since 2.17 * @deprecated in favour of {@link UserManager#lookupUsername(UUID)} */ - @Nonnull + @NonNull @Deprecated - CompletableFuture getName(@Nonnull UUID uuid); + CompletableFuture getName(@NonNull UUID uuid); /** * Returns an executor which will run all passed runnables on the @@ -338,7 +337,7 @@ public interface Storage { * @return an executor instance * @deprecated as plugins should create their own executors */ - @Nonnull + @NonNull @Deprecated Executor getSyncExecutor(); @@ -352,7 +351,7 @@ public interface Storage { * @return an executor instance * @deprecated as plugins should create their own executors */ - @Nonnull + @NonNull @Deprecated Executor getAsyncExecutor(); diff --git a/api/src/main/java/me/lucko/luckperms/api/TemporaryDataMutateResult.java b/api/src/main/java/me/lucko/luckperms/api/TemporaryDataMutateResult.java index 6a394aa2..4bc3fc29 100644 --- a/api/src/main/java/me/lucko/luckperms/api/TemporaryDataMutateResult.java +++ b/api/src/main/java/me/lucko/luckperms/api/TemporaryDataMutateResult.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.api; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Extension of {@link DataMutateResult} for temporary set operations. @@ -39,7 +39,7 @@ public interface TemporaryDataMutateResult { * * @return the result */ - @Nonnull + @NonNull DataMutateResult getResult(); /** @@ -51,7 +51,7 @@ public interface TemporaryDataMutateResult { * * @return the resultant node */ - @Nonnull + @NonNull Node getMergedNode(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/Track.java b/api/src/main/java/me/lucko/luckperms/api/Track.java index a3609289..4fa3b919 100644 --- a/api/src/main/java/me/lucko/luckperms/api/Track.java +++ b/api/src/main/java/me/lucko/luckperms/api/Track.java @@ -27,10 +27,10 @@ package me.lucko.luckperms.api; import me.lucko.luckperms.api.context.ContextSet; -import java.util.List; +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.List; /** * An ordered chain of {@link Group}s. @@ -42,7 +42,7 @@ public interface Track { * * @return the name of this track */ - @Nonnull + @NonNull String getName(); /** @@ -54,7 +54,7 @@ public interface Track { * * @return an ordered {@link List} of the groups on this track */ - @Nonnull + @NonNull List getGroups(); /** @@ -75,7 +75,7 @@ public interface Track { * @throws IllegalStateException if the group instance was not obtained from LuckPerms. */ @Nullable - String getNext(@Nonnull Group current); + String getNext(@NonNull Group current); /** * Gets the previous group on the track, before the one provided @@ -88,7 +88,7 @@ public interface Track { * @throws IllegalStateException if the group instance was not obtained from LuckPerms. */ @Nullable - String getPrevious(@Nonnull Group current); + String getPrevious(@NonNull Group current); /** * Promotes the given user along this track. @@ -98,8 +98,8 @@ public interface Track { * @return the result of the action * @since 4.2 */ - @Nonnull - PromotionResult promote(@Nonnull User user, @Nonnull ContextSet contextSet); + @NonNull + PromotionResult promote(@NonNull User user, @NonNull ContextSet contextSet); /** * Demotes the given user along this track. @@ -109,8 +109,8 @@ public interface Track { * @return the result of the action * @since 4.2 */ - @Nonnull - DemotionResult demote(@Nonnull User user, @Nonnull ContextSet contextSet); + @NonNull + DemotionResult demote(@NonNull User user, @NonNull ContextSet contextSet); /** * Appends a group to the end of this track @@ -120,8 +120,8 @@ public interface Track { * @throws NullPointerException if the group is null * @throws IllegalStateException if the group instance was not obtained from LuckPerms. */ - @Nonnull - DataMutateResult appendGroup(@Nonnull Group group); + @NonNull + DataMutateResult appendGroup(@NonNull Group group); /** * Inserts a group at a certain position on this track @@ -133,8 +133,8 @@ public interface Track { * @throws NullPointerException if the group is null * @throws IllegalStateException if the group instance was not obtained from LuckPerms. */ - @Nonnull - DataMutateResult insertGroup(@Nonnull Group group, int position) throws IndexOutOfBoundsException; + @NonNull + DataMutateResult insertGroup(@NonNull Group group, int position) throws IndexOutOfBoundsException; /** * Removes a group from this track @@ -144,8 +144,8 @@ public interface Track { * @throws NullPointerException if the group is null * @throws IllegalStateException if the group instance was not obtained from LuckPerms. */ - @Nonnull - DataMutateResult removeGroup(@Nonnull Group group); + @NonNull + DataMutateResult removeGroup(@NonNull Group group); /** * Removes a group from this track @@ -154,8 +154,8 @@ public interface Track { * @return the result of the operation * @throws NullPointerException if the group is null */ - @Nonnull - DataMutateResult removeGroup(@Nonnull String group); + @NonNull + DataMutateResult removeGroup(@NonNull String group); /** * Checks if a group features on this track @@ -165,7 +165,7 @@ public interface Track { * @throws NullPointerException if the group is null * @throws IllegalStateException if the group instance was not obtained from LuckPerms. */ - boolean containsGroup(@Nonnull Group group); + boolean containsGroup(@NonNull Group group); /** * Checks if a group features on this track @@ -174,7 +174,7 @@ public interface Track { * @return true if the group is on this track * @throws NullPointerException if the group is null */ - boolean containsGroup(@Nonnull String group); + boolean containsGroup(@NonNull String group); /** * Clear all of the groups from this track diff --git a/api/src/main/java/me/lucko/luckperms/api/Tristate.java b/api/src/main/java/me/lucko/luckperms/api/Tristate.java index bd05e353..4bd832d0 100644 --- a/api/src/main/java/me/lucko/luckperms/api/Tristate.java +++ b/api/src/main/java/me/lucko/luckperms/api/Tristate.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.api; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Represents three different states of a setting. @@ -61,8 +61,7 @@ public enum Tristate { * @param val the boolean value * @return {@link #TRUE} or {@link #FALSE}, if the value is true or false, respectively. */ - @Nonnull - public static Tristate fromBoolean(boolean val) { + public static @NonNull Tristate fromBoolean(boolean val) { return val ? TRUE : FALSE; } @@ -77,8 +76,7 @@ public enum Tristate { * is null, true or false, respectively. * @since 4.1 */ - @Nonnull - public static Tristate fromNullableBoolean(Boolean val) { + public static @NonNull Tristate fromNullableBoolean(Boolean val) { return val == null ? UNDEFINED : val ? TRUE : FALSE; } diff --git a/api/src/main/java/me/lucko/luckperms/api/User.java b/api/src/main/java/me/lucko/luckperms/api/User.java index a3cd3ee8..daaa2f55 100644 --- a/api/src/main/java/me/lucko/luckperms/api/User.java +++ b/api/src/main/java/me/lucko/luckperms/api/User.java @@ -27,10 +27,10 @@ package me.lucko.luckperms.api; import me.lucko.luckperms.api.caching.UserData; -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; /** * A player which holds permission data. @@ -42,7 +42,7 @@ public interface User extends PermissionHolder { * * @return the users Mojang assigned unique id */ - @Nonnull + @NonNull UUID getUuid(); /** @@ -64,7 +64,7 @@ public interface User extends PermissionHolder { * * @return the users primary group */ - @Nonnull + @NonNull String getPrimaryGroup(); /** @@ -78,8 +78,8 @@ public interface User extends PermissionHolder { * @throws IllegalStateException if the user is not a member of that group * @throws NullPointerException if the group is null */ - @Nonnull - DataMutateResult setPrimaryGroup(@Nonnull String group); + @NonNull + DataMutateResult setPrimaryGroup(@NonNull String group); /** * Gets the user's {@link UserData} cache. @@ -87,7 +87,7 @@ public interface User extends PermissionHolder { * @return the users cached data. * @since 3.2 */ - @Nonnull + @NonNull @Override UserData getCachedData(); diff --git a/api/src/main/java/me/lucko/luckperms/api/UuidCache.java b/api/src/main/java/me/lucko/luckperms/api/UuidCache.java index ac47e046..afddb5b0 100644 --- a/api/src/main/java/me/lucko/luckperms/api/UuidCache.java +++ b/api/src/main/java/me/lucko/luckperms/api/UuidCache.java @@ -25,9 +25,9 @@ package me.lucko.luckperms.api; -import java.util.UUID; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.UUID; /** * A UUID cache for online users, between external Mojang UUIDs, and internal @@ -50,9 +50,9 @@ public interface UuidCache { * ProxiedPlayer#getUniqueId * @return the corresponding internal UUID */ - @Nonnull + @NonNull @Deprecated - UUID getUUID(@Nonnull UUID mojangUuid); + UUID getUUID(@NonNull UUID mojangUuid); /** * Gets a users "external", server assigned unique id, from the internal @@ -62,8 +62,8 @@ public interface UuidCache { * User#getUuid * @return the corresponding external UUID */ - @Nonnull + @NonNull @Deprecated - UUID getExternalUUID(@Nonnull UUID internalUuid); + UUID getExternalUUID(@NonNull UUID internalUuid); } diff --git a/api/src/main/java/me/lucko/luckperms/api/caching/CachedData.java b/api/src/main/java/me/lucko/luckperms/api/caching/CachedData.java index f4036640..67d39806 100644 --- a/api/src/main/java/me/lucko/luckperms/api/caching/CachedData.java +++ b/api/src/main/java/me/lucko/luckperms/api/caching/CachedData.java @@ -28,12 +28,12 @@ package me.lucko.luckperms.api.caching; import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.PermissionHolder; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.Objects; import java.util.Set; import java.util.concurrent.CompletableFuture; -import javax.annotation.Nonnull; - /** * Holds cached permission and meta lookup data for a {@link PermissionHolder}. * @@ -57,8 +57,8 @@ public interface CachedData { * @return a permission data instance * @throws NullPointerException if contexts is null */ - @Nonnull - PermissionData getPermissionData(@Nonnull Contexts contexts); + @NonNull + PermissionData getPermissionData(@NonNull Contexts contexts); /** * Gets MetaData from the cache, given a specified context. @@ -68,8 +68,8 @@ public interface CachedData { * @throws NullPointerException if contexts is null * @since 3.2 */ - @Nonnull - MetaData getMetaData(@Nonnull MetaContexts contexts); + @NonNull + MetaData getMetaData(@NonNull MetaContexts contexts); /** * Gets MetaData from the cache, given a specified context. @@ -78,8 +78,8 @@ public interface CachedData { * @return a meta data instance * @throws NullPointerException if contexts is null */ - @Nonnull - MetaData getMetaData(@Nonnull Contexts contexts); + @NonNull + MetaData getMetaData(@NonNull Contexts contexts); /** * Calculates permission data, bypassing the cache. @@ -96,8 +96,8 @@ public interface CachedData { * @return a permission data instance * @throws NullPointerException if contexts is null */ - @Nonnull - PermissionData calculatePermissions(@Nonnull Contexts contexts); + @NonNull + PermissionData calculatePermissions(@NonNull Contexts contexts); /** * Calculates meta data, bypassing the cache. @@ -115,8 +115,8 @@ public interface CachedData { * @throws NullPointerException if contexts is null * @since 3.2 */ - @Nonnull - MetaData calculateMeta(@Nonnull MetaContexts contexts); + @NonNull + MetaData calculateMeta(@NonNull MetaContexts contexts); /** * Calculates meta data, bypassing the cache. @@ -133,8 +133,8 @@ public interface CachedData { * @return a meta data instance * @throws NullPointerException if contexts is null */ - @Nonnull - MetaData calculateMeta(@Nonnull Contexts contexts); + @NonNull + MetaData calculateMeta(@NonNull Contexts contexts); /** * (Re)calculates permission data for a given context. @@ -152,7 +152,7 @@ public interface CachedData { * @param contexts the contexts to recalculate in. * @throws NullPointerException if contexts is null */ - void recalculatePermissions(@Nonnull Contexts contexts); + void recalculatePermissions(@NonNull Contexts contexts); /** * (Re)calculates meta data for a given context. @@ -171,7 +171,7 @@ public interface CachedData { * @throws NullPointerException if contexts is null * @since 3.2 */ - void recalculateMeta(@Nonnull MetaContexts contexts); + void recalculateMeta(@NonNull MetaContexts contexts); /** * (Re)calculates meta data for a given context. @@ -189,7 +189,7 @@ public interface CachedData { * @param contexts the contexts to recalculate in. * @throws NullPointerException if contexts is null */ - void recalculateMeta(@Nonnull Contexts contexts); + void recalculateMeta(@NonNull Contexts contexts); /** * (Re)loads permission data for a given context. @@ -216,8 +216,8 @@ public interface CachedData { * @return a future * @since 4.0 */ - @Nonnull - CompletableFuture reloadPermissions(@Nonnull Contexts contexts); + @NonNull + CompletableFuture reloadPermissions(@NonNull Contexts contexts); /** * (Re)loads meta data for a given context. @@ -244,8 +244,8 @@ public interface CachedData { * @return a future * @since 4.0 */ - @Nonnull - CompletableFuture reloadMeta(@Nonnull MetaContexts contexts); + @NonNull + CompletableFuture reloadMeta(@NonNull MetaContexts contexts); /** * (Re)loads meta data for a given context. @@ -272,8 +272,8 @@ public interface CachedData { * @return a future * @since 4.0 */ - @Nonnull - CompletableFuture reloadMeta(@Nonnull Contexts contexts); + @NonNull + CompletableFuture reloadMeta(@NonNull Contexts contexts); /** * Recalculates permission data for all known contexts. @@ -318,7 +318,7 @@ public interface CachedData { * @return a future * @since 4.0 */ - @Nonnull + @NonNull CompletableFuture reloadPermissions(); /** @@ -342,7 +342,7 @@ public interface CachedData { * @return a future * @since 4.0 */ - @Nonnull + @NonNull CompletableFuture reloadMeta(); /** @@ -357,7 +357,7 @@ public interface CachedData { * @param contexts a set of contexts * @throws NullPointerException if contexts is null */ - default void preCalculate(@Nonnull Set contexts) { + default void preCalculate(@NonNull Set contexts) { contexts.forEach(this::preCalculate); } @@ -373,7 +373,7 @@ public interface CachedData { * @param contexts the contexts to pre-calculate for * @throws NullPointerException if contexts is null */ - default void preCalculate(@Nonnull Contexts contexts) { + default void preCalculate(@NonNull Contexts contexts) { Objects.requireNonNull(contexts, "contexts"); // pre-calculate just by requesting the data from this cache. @@ -389,7 +389,7 @@ public interface CachedData { * @param contexts the contexts to invalidate for * @since 4.0 */ - void invalidatePermissions(@Nonnull Contexts contexts); + void invalidatePermissions(@NonNull Contexts contexts); /** * Invalidates any cached {@link MetaData} instances mapped to the given @@ -398,7 +398,7 @@ public interface CachedData { * @param contexts the contexts to invalidate for * @since 4.0 */ - void invalidateMeta(@Nonnull MetaContexts contexts); + void invalidateMeta(@NonNull MetaContexts contexts); /** * Invalidates any cached {@link MetaData} instances mapped to the given @@ -407,7 +407,7 @@ public interface CachedData { * @param contexts the contexts to invalidate for * @since 4.0 */ - void invalidateMeta(@Nonnull Contexts contexts); + void invalidateMeta(@NonNull Contexts contexts); /** * Invalidates all cached {@link PermissionData} instances. diff --git a/api/src/main/java/me/lucko/luckperms/api/caching/CachedDataContainer.java b/api/src/main/java/me/lucko/luckperms/api/caching/CachedDataContainer.java index 7f22193d..caa80cdb 100644 --- a/api/src/main/java/me/lucko/luckperms/api/caching/CachedDataContainer.java +++ b/api/src/main/java/me/lucko/luckperms/api/caching/CachedDataContainer.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.api.caching; import me.lucko.luckperms.api.Contexts; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Holds cached lookup data in a specific set of contexts. @@ -41,7 +41,7 @@ public interface CachedDataContainer { * * @return the contexts this container is caching */ - @Nonnull + @NonNull Contexts getContexts(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/caching/MetaContexts.java b/api/src/main/java/me/lucko/luckperms/api/caching/MetaContexts.java index 0b1e7282..4550a9e4 100644 --- a/api/src/main/java/me/lucko/luckperms/api/caching/MetaContexts.java +++ b/api/src/main/java/me/lucko/luckperms/api/caching/MetaContexts.java @@ -28,10 +28,9 @@ package me.lucko.luckperms.api.caching; import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.metastacking.MetaStackDefinition; -import java.util.Objects; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.Immutable; +import java.util.Objects; /** * Encapsulates the options and settings for a meta lookup. @@ -41,7 +40,6 @@ import javax.annotation.concurrent.Immutable; * * @since 3.2 */ -@Immutable public final class MetaContexts { /** @@ -52,7 +50,7 @@ public final class MetaContexts { * @param suffixStackDefinition the suffix stack definition to be used * @return the new instance */ - public static MetaContexts of(@Nonnull Contexts contexts, @Nonnull MetaStackDefinition prefixStackDefinition, @Nonnull MetaStackDefinition suffixStackDefinition) { + public static MetaContexts of(@NonNull Contexts contexts, @NonNull MetaStackDefinition prefixStackDefinition, @NonNull MetaStackDefinition suffixStackDefinition) { return new MetaContexts(contexts, prefixStackDefinition, suffixStackDefinition); } @@ -70,31 +68,27 @@ public final class MetaContexts { * @param prefixStackDefinition the prefix stack definition to be used * @param suffixStackDefinition the suffix stack definition to be used */ - public MetaContexts(@Nonnull Contexts contexts, @Nonnull MetaStackDefinition prefixStackDefinition, @Nonnull MetaStackDefinition suffixStackDefinition) { + public MetaContexts(@NonNull Contexts contexts, @NonNull MetaStackDefinition prefixStackDefinition, @NonNull MetaStackDefinition suffixStackDefinition) { this.contexts = Objects.requireNonNull(contexts, "contexts"); this.prefixStackDefinition = Objects.requireNonNull(prefixStackDefinition, "prefixStackDefinition"); this.suffixStackDefinition = Objects.requireNonNull(suffixStackDefinition, "suffixStackDefinition"); this.hashCode = calculateHashCode(); } - @Nonnull - public Contexts getContexts() { + public @NonNull Contexts getContexts() { return this.contexts; } - @Nonnull - public MetaStackDefinition getPrefixStackDefinition() { + public @NonNull MetaStackDefinition getPrefixStackDefinition() { return this.prefixStackDefinition; } - @Nonnull - public MetaStackDefinition getSuffixStackDefinition() { + public @NonNull MetaStackDefinition getSuffixStackDefinition() { return this.suffixStackDefinition; } @Override - @Nonnull - public String toString() { + public @NonNull String toString() { return "MetaContexts(" + "contexts=" + this.getContexts() + ", " + "prefixStackDefinition=" + this.getPrefixStackDefinition() + ", " + diff --git a/api/src/main/java/me/lucko/luckperms/api/caching/MetaData.java b/api/src/main/java/me/lucko/luckperms/api/caching/MetaData.java index dbb46c60..78eb9818 100644 --- a/api/src/main/java/me/lucko/luckperms/api/caching/MetaData.java +++ b/api/src/main/java/me/lucko/luckperms/api/caching/MetaData.java @@ -29,12 +29,12 @@ import com.google.common.collect.ListMultimap; import me.lucko.luckperms.api.metastacking.MetaStackDefinition; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + import java.util.Map; import java.util.SortedMap; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - /** * Holds cached meta lookup data for a specific set of contexts. * @@ -47,7 +47,7 @@ public interface MetaData extends CachedDataContainer { * * @return the contexts this container is caching */ - @Nonnull + @NonNull MetaContexts getMetaContexts(); /** @@ -62,7 +62,7 @@ public interface MetaData extends CachedDataContainer { * @return an immutable multimap of meta * @since 3.3 */ - @Nonnull + @NonNull ListMultimap getMetaMultimap(); /** @@ -73,7 +73,7 @@ public interface MetaData extends CachedDataContainer { * * @return an immutable map of meta */ - @Nonnull + @NonNull Map getMeta(); /** @@ -82,7 +82,7 @@ public interface MetaData extends CachedDataContainer { * * @return a sorted map of prefixes */ - @Nonnull + @NonNull SortedMap getPrefixes(); /** @@ -91,7 +91,7 @@ public interface MetaData extends CachedDataContainer { * * @return a sorted map of suffixes */ - @Nonnull + @NonNull SortedMap getSuffixes(); /** @@ -116,7 +116,7 @@ public interface MetaData extends CachedDataContainer { * @return the definition used for the prefix stack * @since 3.2 */ - @Nonnull + @NonNull MetaStackDefinition getPrefixStackDefinition(); /** @@ -125,7 +125,7 @@ public interface MetaData extends CachedDataContainer { * @return the definition used for the suffix stack * @since 3.2 */ - @Nonnull + @NonNull MetaStackDefinition getSuffixStackDefinition(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/caching/PermissionData.java b/api/src/main/java/me/lucko/luckperms/api/caching/PermissionData.java index 45ac7d9a..e4fe7706 100644 --- a/api/src/main/java/me/lucko/luckperms/api/caching/PermissionData.java +++ b/api/src/main/java/me/lucko/luckperms/api/caching/PermissionData.java @@ -27,9 +27,9 @@ package me.lucko.luckperms.api.caching; import me.lucko.luckperms.api.Tristate; -import java.util.Map; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Map; /** * Holds cached permission lookup data for a specific set of contexts. @@ -45,8 +45,8 @@ public interface PermissionData extends CachedDataContainer { * @return a tristate result * @throws NullPointerException if permission is null */ - @Nonnull - Tristate getPermissionValue(@Nonnull String permission); + @NonNull + Tristate getPermissionValue(@NonNull String permission); /** * Invalidates the underlying permission calculator cache. @@ -60,7 +60,7 @@ public interface PermissionData extends CachedDataContainer { * * @return an immutable set of permissions */ - @Nonnull + @NonNull Map getImmutableBacking(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/context/AbstractContextSet.java b/api/src/main/java/me/lucko/luckperms/api/context/AbstractContextSet.java index 637af6b2..e941e1cf 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/AbstractContextSet.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/AbstractContextSet.java @@ -29,12 +29,12 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; import com.google.common.collect.SetMultimap; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.Collection; import java.util.Objects; import java.util.Set; -import javax.annotation.Nonnull; - abstract class AbstractContextSet implements ContextSet { protected abstract SetMultimap backing(); @@ -42,19 +42,18 @@ abstract class AbstractContextSet implements ContextSet { protected abstract void copyTo(SetMultimap other); @Override - public boolean containsKey(@Nonnull String key) { + public boolean containsKey(@NonNull String key) { return backing().containsKey(sanitizeKey(key)); } - @Nonnull @Override - public Set getValues(@Nonnull String key) { + public @NonNull Set getValues(@NonNull String key) { Collection values = backing().asMap().get(sanitizeKey(key)); return values != null ? ImmutableSet.copyOf(values) : ImmutableSet.of(); } @Override - public boolean has(@Nonnull String key, @Nonnull String value) { + public boolean has(@NonNull String key, @NonNull String value) { return backing().containsEntry(sanitizeKey(key), sanitizeValue(value)); } diff --git a/api/src/main/java/me/lucko/luckperms/api/context/ContextCalculator.java b/api/src/main/java/me/lucko/luckperms/api/context/ContextCalculator.java index 6cfc04b1..b6f22ac6 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/ContextCalculator.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/ContextCalculator.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.api.context; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Calculates whether contexts are applicable to a {@link T subject}. @@ -44,7 +44,7 @@ public interface ContextCalculator { * @return the map * @since 2.13 */ - @Nonnull - MutableContextSet giveApplicableContext(@Nonnull T subject, @Nonnull MutableContextSet accumulator); + @NonNull + MutableContextSet giveApplicableContext(@NonNull T subject, @NonNull MutableContextSet accumulator); } diff --git a/api/src/main/java/me/lucko/luckperms/api/context/ContextManager.java b/api/src/main/java/me/lucko/luckperms/api/context/ContextManager.java index 4018b2bd..ff1fd4c5 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/ContextManager.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/ContextManager.java @@ -28,9 +28,9 @@ package me.lucko.luckperms.api.context; import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.User; -import java.util.Optional; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Optional; /** * Manages {@link ContextCalculator}s, and calculates applicable contexts for a @@ -59,8 +59,8 @@ public interface ContextManager { * @param subject the subject * @return the applicable context for the subject */ - @Nonnull - ImmutableContextSet getApplicableContext(@Nonnull Object subject); + @NonNull + ImmutableContextSet getApplicableContext(@NonNull Object subject); /** * Queries the ContextManager for current context values for the subject. @@ -68,8 +68,8 @@ public interface ContextManager { * @param subject the subject * @return the applicable context for the subject */ - @Nonnull - Contexts getApplicableContexts(@Nonnull Object subject); + @NonNull + Contexts getApplicableContexts(@NonNull Object subject); /** * Queries the ContextManager for current context values for the given User. @@ -83,8 +83,8 @@ public interface ContextManager { * @param user the user * @return the applicable context for the subject */ - @Nonnull - Optional lookupApplicableContext(@Nonnull User user); + @NonNull + Optional lookupApplicableContext(@NonNull User user); /** * Queries the ContextManager for current context values for the given User. @@ -98,8 +98,8 @@ public interface ContextManager { * @param user the user * @return the applicable context for the subject */ - @Nonnull - Optional lookupApplicableContexts(@Nonnull User user); + @NonNull + Optional lookupApplicableContexts(@NonNull User user); /** * Gets the contexts from the static calculators in this manager. @@ -109,7 +109,7 @@ public interface ContextManager { * * @return the current active static contexts */ - @Nonnull + @NonNull ImmutableContextSet getStaticContext(); /** @@ -120,7 +120,7 @@ public interface ContextManager { * * @return the current active static contexts */ - @Nonnull + @NonNull Contexts getStaticContexts(); /** @@ -133,8 +133,8 @@ public interface ContextManager { * @param contextSet the context set * @return a contexts instance */ - @Nonnull - Contexts formContexts(@Nonnull Object subject, @Nonnull ImmutableContextSet contextSet); + @NonNull + Contexts formContexts(@NonNull Object subject, @NonNull ImmutableContextSet contextSet); /** * Forms a {@link Contexts} instance from an {@link ImmutableContextSet}. @@ -145,15 +145,15 @@ public interface ContextManager { * @param contextSet the context set * @return a contexts instance */ - @Nonnull - Contexts formContexts(@Nonnull ImmutableContextSet contextSet); + @NonNull + Contexts formContexts(@NonNull ImmutableContextSet contextSet); /** * Registers a context calculator with the manager. * * @param calculator the calculator */ - void registerCalculator(@Nonnull ContextCalculator calculator); + void registerCalculator(@NonNull ContextCalculator calculator); /** * Registers a static context calculator with the manager. @@ -162,13 +162,13 @@ public interface ContextManager { * * @param calculator the calculator */ - void registerStaticCalculator(@Nonnull StaticContextCalculator calculator); + void registerStaticCalculator(@NonNull StaticContextCalculator calculator); /** * Invalidates the lookup cache for a given subject * * @param subject the subject */ - void invalidateCache(@Nonnull Object subject); + void invalidateCache(@NonNull Object subject); } diff --git a/api/src/main/java/me/lucko/luckperms/api/context/ContextSet.java b/api/src/main/java/me/lucko/luckperms/api/context/ContextSet.java index e74792c2..da78a149 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/ContextSet.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/ContextSet.java @@ -27,14 +27,14 @@ package me.lucko.luckperms.api.context; import com.google.common.collect.Multimap; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.Iterator; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; -import javax.annotation.Nonnull; - /** * A set of contexts. * @@ -71,8 +71,7 @@ public interface ContextSet extends Iterable> { * @return a new ImmutableContextSet containing one context pair * @throws NullPointerException if key or value is null */ - @Nonnull - static ImmutableContextSet singleton(@Nonnull String key, @Nonnull String value) { + static @NonNull ImmutableContextSet singleton(@NonNull String key, @NonNull String value) { return ImmutableContextSet.singleton(key, value); } @@ -87,8 +86,7 @@ public interface ContextSet extends Iterable> { * @throws NullPointerException if any of the keys or values are null * @since 3.1 */ - @Nonnull - static ImmutableContextSet of(@Nonnull String key1, @Nonnull String value1, @Nonnull String key2, @Nonnull String value2) { + static @NonNull ImmutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) { return ImmutableContextSet.of(key1, value1, key2, value2); } @@ -99,8 +97,7 @@ public interface ContextSet extends Iterable> { * @return a new ImmutableContextSet representing the pairs in the iterable * @throws NullPointerException if the iterable is null */ - @Nonnull - static ImmutableContextSet fromEntries(@Nonnull Iterable> iterable) { + static @NonNull ImmutableContextSet fromEntries(@NonNull Iterable> iterable) { return ImmutableContextSet.fromEntries(iterable); } @@ -111,8 +108,7 @@ public interface ContextSet extends Iterable> { * @return a new ImmutableContextSet representing the pairs from the map * @throws NullPointerException if the map is null */ - @Nonnull - static ImmutableContextSet fromMap(@Nonnull Map map) { + static @NonNull ImmutableContextSet fromMap(@NonNull Map map) { return ImmutableContextSet.fromMap(map); } @@ -124,8 +120,7 @@ public interface ContextSet extends Iterable> { * @throws NullPointerException if the multimap is null * @since 2.16 */ - @Nonnull - static ImmutableContextSet fromMultimap(@Nonnull Multimap multimap) { + static @NonNull ImmutableContextSet fromMultimap(@NonNull Multimap multimap) { return ImmutableContextSet.fromMultimap(multimap); } @@ -138,8 +133,7 @@ public interface ContextSet extends Iterable> { * @return a new ImmutableContextSet with the same content and the one provided * @throws NullPointerException if contextSet is null */ - @Nonnull - static ImmutableContextSet fromSet(@Nonnull ContextSet contextSet) { + static @NonNull ImmutableContextSet fromSet(@NonNull ContextSet contextSet) { return ImmutableContextSet.fromSet(contextSet); } @@ -148,8 +142,7 @@ public interface ContextSet extends Iterable> { * * @return an empty ImmutableContextSet */ - @Nonnull - static ImmutableContextSet empty() { + static @NonNull ImmutableContextSet empty() { return ImmutableContextSet.empty(); } @@ -170,7 +163,7 @@ public interface ContextSet extends Iterable> { * * @return an immutable representation of this set */ - @Nonnull + @NonNull ImmutableContextSet makeImmutable(); /** @@ -182,7 +175,7 @@ public interface ContextSet extends Iterable> { * @return a mutable ContextSet * @since 2.16 */ - @Nonnull + @NonNull MutableContextSet mutableCopy(); /** @@ -194,7 +187,7 @@ public interface ContextSet extends Iterable> { * * @return an immutable set */ - @Nonnull + @NonNull Set> toSet(); /** @@ -214,7 +207,7 @@ public interface ContextSet extends Iterable> { * @return an immutable map * @deprecated because the resultant map may not contain all data in the ContextSet */ - @Nonnull + @NonNull @Deprecated Map toMap(); @@ -228,7 +221,7 @@ public interface ContextSet extends Iterable> { * @return a multimap * @since 2.16 */ - @Nonnull + @NonNull Multimap toMultimap(); /** @@ -241,7 +234,7 @@ public interface ContextSet extends Iterable> { * * @return an iterator */ - @Nonnull + @NonNull @Override Iterator> iterator(); @@ -253,7 +246,7 @@ public interface ContextSet extends Iterable> { * @return true if the set contains a value for the key * @throws NullPointerException if the key is null */ - boolean containsKey(@Nonnull String key); + boolean containsKey(@NonNull String key); /** * Returns a {@link Set} of the values mapped to the given key. @@ -265,8 +258,8 @@ public interface ContextSet extends Iterable> { * @return a set of values * @throws NullPointerException if the key is null */ - @Nonnull - Set getValues(@Nonnull String key); + @NonNull + Set getValues(@NonNull String key); /** * Returns any value from this {@link ContextSet} matching the key, if present. @@ -278,8 +271,7 @@ public interface ContextSet extends Iterable> { * @return an optional containing any match * @since 3.1 */ - @Nonnull - default Optional getAnyValue(@Nonnull String key) { + default @NonNull Optional getAnyValue(@NonNull String key) { return getValues(key).stream().findAny(); } @@ -291,7 +283,7 @@ public interface ContextSet extends Iterable> { * @return true if the set contains the context pair * @throws NullPointerException if the key or value is null */ - boolean has(@Nonnull String key, @Nonnull String value); + boolean has(@NonNull String key, @NonNull String value); /** * Returns if the {@link ContextSet} contains a given context pairing. @@ -300,7 +292,7 @@ public interface ContextSet extends Iterable> { * @return true if the set contains the context pair * @throws NullPointerException if the key or value is null */ - default boolean has(@Nonnull Map.Entry entry) { + default boolean has(Map.@NonNull Entry entry) { Objects.requireNonNull(entry, "entry"); return has(entry.getKey(), entry.getValue()); } @@ -317,7 +309,7 @@ public interface ContextSet extends Iterable> { * @return true if all entries in this set are also in the other set * @since 3.1 */ - default boolean isSatisfiedBy(@Nonnull ContextSet other) { + default boolean isSatisfiedBy(@NonNull ContextSet other) { if (this == other) { return true; } diff --git a/api/src/main/java/me/lucko/luckperms/api/context/ImmutableContextSet.java b/api/src/main/java/me/lucko/luckperms/api/context/ImmutableContextSet.java index e8234245..da073c3b 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/ImmutableContextSet.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/ImmutableContextSet.java @@ -30,21 +30,19 @@ import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.SetMultimap; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.Iterator; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.Spliterator; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.Immutable; - /** * An immutable implementation of {@link ContextSet}. * * @since 2.16 */ -@Immutable public final class ImmutableContextSet extends AbstractContextSet implements ContextSet { private static final ImmutableContextSet EMPTY = new ImmutableContextSet(ImmutableSetMultimap.of()); @@ -54,8 +52,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @return a new ImmutableContextSet builder * @since 4.1 */ - @Nonnull - public static Builder builder() { + public static @NonNull Builder builder() { return new Builder(); } @@ -67,8 +64,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @return a new ImmutableContextSet containing one context pair * @throws NullPointerException if key or value is null */ - @Nonnull - public static ImmutableContextSet singleton(@Nonnull String key, @Nonnull String value) { + public static @NonNull ImmutableContextSet singleton(@NonNull String key, @NonNull String value) { return new ImmutableContextSet(ImmutableSetMultimap.of(sanitizeKey(key), sanitizeValue(value))); } @@ -83,8 +79,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @throws NullPointerException if any of the keys or values are null * @since 3.1 */ - @Nonnull - public static ImmutableContextSet of(@Nonnull String key1, @Nonnull String value1, @Nonnull String key2, @Nonnull String value2) { + public static @NonNull ImmutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) { return new ImmutableContextSet(ImmutableSetMultimap.of( sanitizeKey(key1), sanitizeValue(value1), @@ -100,8 +95,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @return a new ImmutableContextSet representing the pairs in the iterable * @throws NullPointerException if the iterable is null */ - @Nonnull - public static ImmutableContextSet fromEntries(@Nonnull Iterable> iterable) { + public static @NonNull ImmutableContextSet fromEntries(@NonNull Iterable> iterable) { Objects.requireNonNull(iterable, "iterable"); ImmutableContextSet.Builder builder = builder(); for (Map.Entry entry : iterable) { @@ -117,8 +111,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @return a new ImmutableContextSet representing the pairs from the map * @throws NullPointerException if the map is null */ - @Nonnull - public static ImmutableContextSet fromMap(@Nonnull Map map) { + public static @NonNull ImmutableContextSet fromMap(@NonNull Map map) { return fromEntries(Objects.requireNonNull(map, "map").entrySet()); } @@ -130,8 +123,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @throws NullPointerException if the multimap is null * @since 2.16 */ - @Nonnull - public static ImmutableContextSet fromMultimap(@Nonnull Multimap multimap) { + public static @NonNull ImmutableContextSet fromMultimap(@NonNull Multimap multimap) { return fromEntries(Objects.requireNonNull(multimap, "multimap").entries()); } @@ -144,8 +136,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @return a new ImmutableContextSet with the same content and the one provided * @throws NullPointerException if contextSet is null */ - @Nonnull - public static ImmutableContextSet fromSet(@Nonnull ContextSet contextSet) { + public static @NonNull ImmutableContextSet fromSet(@NonNull ContextSet contextSet) { return Objects.requireNonNull(contextSet, "contextSet").makeImmutable(); } @@ -154,8 +145,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * * @return an empty ImmutableContextSet */ - @Nonnull - public static ImmutableContextSet empty() { + public static @NonNull ImmutableContextSet empty() { return EMPTY; } @@ -182,29 +172,25 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con return true; } - @Nonnull - @Override - @Deprecated // This set is already immutable! - public ImmutableContextSet makeImmutable() { + @Deprecated + @Override // This set is already immutable! + public @NonNull ImmutableContextSet makeImmutable() { return this; } - @Nonnull @Override - public MutableContextSet mutableCopy() { + public @NonNull MutableContextSet mutableCopy() { return MutableContextSet.fromSet(this); } - @Nonnull @Override - public Set> toSet() { + public @NonNull Set> toSet() { return this.map.entries(); } - @Nonnull - @Override @Deprecated - public Map toMap() { + @Override + public @NonNull Map toMap() { ImmutableMap.Builder m = ImmutableMap.builder(); for (Map.Entry e : this.map.entries()) { m.put(e.getKey(), e.getValue()); @@ -212,15 +198,13 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con return m.build(); } - @Nonnull @Override - public Multimap toMultimap() { + public @NonNull Multimap toMultimap() { return this.map; } - @Nonnull @Override - public Iterator> iterator() { + public @NonNull Iterator> iterator() { return this.map.entries().iterator(); } @@ -271,8 +255,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @throws NullPointerException if the key or value is null * @see MutableContextSet#add(String, String) */ - @Nonnull - public Builder add(@Nonnull String key, @Nonnull String value) { + public @NonNull Builder add(@NonNull String key, @NonNull String value) { put(sanitizeKey(key), sanitizeValue(value)); return this; } @@ -285,8 +268,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @throws NullPointerException if the entry is null * @see MutableContextSet#add(Map.Entry) */ - @Nonnull - public Builder add(@Nonnull Map.Entry entry) { + public @NonNull Builder add(Map.@NonNull Entry entry) { Objects.requireNonNull(entry, "entry"); add(entry.getKey(), entry.getValue()); return this; @@ -300,8 +282,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @throws NullPointerException if iterable is null * @see MutableContextSet#addAll(Iterable) */ - @Nonnull - public Builder addAll(@Nonnull Iterable> iterable) { + public @NonNull Builder addAll(@NonNull Iterable> iterable) { for (Map.Entry e : Objects.requireNonNull(iterable, "iterable")) { add(e); } @@ -316,8 +297,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @throws NullPointerException if the map is null * @see MutableContextSet#addAll(Map) */ - @Nonnull - public Builder addAll(@Nonnull Map map) { + public @NonNull Builder addAll(@NonNull Map map) { addAll(Objects.requireNonNull(map, "map").entrySet()); return this; } @@ -331,8 +311,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @since 3.4 * @see MutableContextSet#addAll(Multimap) */ - @Nonnull - public Builder addAll(@Nonnull Multimap multimap) { + public @NonNull Builder addAll(@NonNull Multimap multimap) { addAll(Objects.requireNonNull(multimap, "multimap").entries()); return this; } @@ -345,8 +324,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * @throws NullPointerException if the contextSet is null * @see MutableContextSet#addAll(ContextSet) */ - @Nonnull - public Builder addAll(@Nonnull ContextSet contextSet) { + public @NonNull Builder addAll(@NonNull ContextSet contextSet) { Objects.requireNonNull(contextSet, "contextSet"); if (contextSet instanceof AbstractContextSet) { AbstractContextSet other = ((AbstractContextSet) contextSet); @@ -365,8 +343,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con * * @return an {@link ImmutableContextSet} from the builder */ - @Nonnull - public ImmutableContextSet build() { + public @NonNull ImmutableContextSet build() { if (this.builder == null) { return empty(); } else { diff --git a/api/src/main/java/me/lucko/luckperms/api/context/MutableContextSet.java b/api/src/main/java/me/lucko/luckperms/api/context/MutableContextSet.java index ed2b9446..7263db4f 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/MutableContextSet.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/MutableContextSet.java @@ -33,14 +33,14 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.common.collect.SetMultimap; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.Iterator; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.Spliterator; -import javax.annotation.Nonnull; - /** * A mutable implementation of {@link ContextSet}. * @@ -56,8 +56,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @return a new MutableContextSet containing one context pair * @throws NullPointerException if key or value is null */ - @Nonnull - public static MutableContextSet singleton(@Nonnull String key, @Nonnull String value) { + public static @NonNull MutableContextSet singleton(@NonNull String key, @NonNull String value) { Objects.requireNonNull(key, "key"); Objects.requireNonNull(value, "value"); MutableContextSet set = MutableContextSet.create(); @@ -76,8 +75,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @throws NullPointerException if any of the keys or values are null * @since 3.1 */ - @Nonnull - public static MutableContextSet of(@Nonnull String key1, @Nonnull String value1, @Nonnull String key2, @Nonnull String value2) { + public static @NonNull MutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) { Objects.requireNonNull(key1, "key1"); Objects.requireNonNull(value1, "value1"); Objects.requireNonNull(key2, "key2"); @@ -95,8 +93,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @return a new MutableContextSet representing the pairs in the iterable * @throws NullPointerException if the iterable is null */ - @Nonnull - public static MutableContextSet fromEntries(@Nonnull Iterable> iterable) { + public static @NonNull MutableContextSet fromEntries(@NonNull Iterable> iterable) { Objects.requireNonNull(iterable, "iterable"); MutableContextSet set = create(); set.addAll(iterable); @@ -110,8 +107,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @return a new MutableContextSet representing the pairs from the map * @throws NullPointerException if the map is null */ - @Nonnull - public static MutableContextSet fromMap(@Nonnull Map map) { + public static @NonNull MutableContextSet fromMap(@NonNull Map map) { Objects.requireNonNull(map, "map"); MutableContextSet set = create(); set.addAll(map); @@ -126,8 +122,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @throws NullPointerException if the multimap is null * @since 2.16 */ - @Nonnull - public static MutableContextSet fromMultimap(@Nonnull Multimap multimap) { + public static @NonNull MutableContextSet fromMultimap(@NonNull Multimap multimap) { Objects.requireNonNull(multimap, "multimap"); MutableContextSet set = create(); set.addAll(multimap); @@ -143,8 +138,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @return a new MutableContextSet with the same content and the one provided * @throws NullPointerException if contextSet is null */ - @Nonnull - public static MutableContextSet fromSet(@Nonnull ContextSet contextSet) { + public static @NonNull MutableContextSet fromSet(@NonNull ContextSet contextSet) { Objects.requireNonNull(contextSet, "contextSet"); if (contextSet instanceof ImmutableContextSet) { @@ -164,8 +158,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * * @return a new MutableContextSet */ - @Nonnull - public static MutableContextSet create() { + public static @NonNull MutableContextSet create() { return new MutableContextSet(); } @@ -196,9 +189,8 @@ public final class MutableContextSet extends AbstractContextSet implements Conte return false; } - @Nonnull @Override - public ImmutableContextSet makeImmutable() { + public @NonNull ImmutableContextSet makeImmutable() { // if the map is empty, don't create a new instance if (this.map.isEmpty()) { return ImmutableContextSet.empty(); @@ -208,27 +200,24 @@ public final class MutableContextSet extends AbstractContextSet implements Conte } } - @Nonnull @Override - public MutableContextSet mutableCopy() { + public @NonNull MutableContextSet mutableCopy() { synchronized (this.map) { return new MutableContextSet(this.map); } } - @Nonnull @Override - public Set> toSet() { + public @NonNull Set> toSet() { synchronized (this.map) { // map.entries() returns immutable Map.Entry instances, so we can just call copyOf return ImmutableSet.copyOf(this.map.entries()); } } - @Nonnull - @Override @Deprecated - public Map toMap() { + @Override + public @NonNull Map toMap() { ImmutableMap.Builder m = ImmutableMap.builder(); synchronized (this.map) { for (Map.Entry e : this.map.entries()) { @@ -238,17 +227,15 @@ public final class MutableContextSet extends AbstractContextSet implements Conte return m.build(); } - @Nonnull @Override - public Multimap toMultimap() { + public @NonNull Multimap toMultimap() { synchronized (this.map) { return ImmutableSetMultimap.copyOf(this.map); } } - @Nonnull @Override - public Iterator> iterator() { + public @NonNull Iterator> iterator() { return toSet().iterator(); } @@ -264,7 +251,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @param value the value to add * @throws NullPointerException if the key or value is null */ - public void add(@Nonnull String key, @Nonnull String value) { + public void add(@NonNull String key, @NonNull String value) { this.map.put(sanitizeKey(key), sanitizeValue(value)); } @@ -274,7 +261,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @param entry the entry to add * @throws NullPointerException if the entry is null */ - public void add(@Nonnull Map.Entry entry) { + public void add(Map.@NonNull Entry entry) { Objects.requireNonNull(entry, "entry"); add(entry.getKey(), entry.getValue()); } @@ -285,7 +272,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @param iterable an iterable of key value context pairs * @throws NullPointerException if iterable is null */ - public void addAll(@Nonnull Iterable> iterable) { + public void addAll(@NonNull Iterable> iterable) { for (Map.Entry e : Objects.requireNonNull(iterable, "iterable")) { add(e); } @@ -297,7 +284,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @param map the map to add from * @throws NullPointerException if the map is null */ - public void addAll(@Nonnull Map map) { + public void addAll(@NonNull Map map) { addAll(Objects.requireNonNull(map, "map").entrySet()); } @@ -308,7 +295,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @throws NullPointerException if the map is null * @since 3.4 */ - public void addAll(@Nonnull Multimap multimap) { + public void addAll(@NonNull Multimap multimap) { addAll(Objects.requireNonNull(multimap, "multimap").entries()); } @@ -318,7 +305,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @param contextSet the set to add from * @throws NullPointerException if the contextSet is null */ - public void addAll(@Nonnull ContextSet contextSet) { + public void addAll(@NonNull ContextSet contextSet) { Objects.requireNonNull(contextSet, "contextSet"); if (contextSet instanceof AbstractContextSet) { AbstractContextSet other = ((AbstractContextSet) contextSet); @@ -337,7 +324,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @param value the value to remove * @throws NullPointerException if the key or value is null */ - public void remove(@Nonnull String key, @Nonnull String value) { + public void remove(@NonNull String key, @NonNull String value) { this.map.remove(sanitizeKey(key), sanitizeValue(value)); } @@ -347,7 +334,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte * @param key the key to remove * @throws NullPointerException if the key is null */ - public void removeAll(@Nonnull String key) { + public void removeAll(@NonNull String key) { this.map.removeAll(sanitizeKey(key)); } diff --git a/api/src/main/java/me/lucko/luckperms/api/context/StaticContextCalculator.java b/api/src/main/java/me/lucko/luckperms/api/context/StaticContextCalculator.java index 5fbd49a7..1160f2c6 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/StaticContextCalculator.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/StaticContextCalculator.java @@ -25,8 +25,8 @@ package me.lucko.luckperms.api.context; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Extension of {@link ContextCalculator} which provides the same context @@ -43,8 +43,8 @@ public interface StaticContextCalculator extends ContextCalculator { * @param accumulator a map of contexts to add to * @return the map */ - @Nonnull - MutableContextSet giveApplicableContext(@Nonnull MutableContextSet accumulator); + @NonNull + MutableContextSet giveApplicableContext(@NonNull MutableContextSet accumulator); /** * Gives the subject all of the applicable contexts they meet @@ -53,10 +53,9 @@ public interface StaticContextCalculator extends ContextCalculator { * @param accumulator a map of contexts to add to * @return the map */ - @Nonnull - @Override @Deprecated - default MutableContextSet giveApplicableContext(@Nullable Object subject, @Nonnull MutableContextSet accumulator) { + @Override + default @NonNull MutableContextSet giveApplicableContext(@Nullable Object subject, @NonNull MutableContextSet accumulator) { return giveApplicableContext(accumulator); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/Cancellable.java b/api/src/main/java/me/lucko/luckperms/api/event/Cancellable.java index fce020ba..112168ae 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/Cancellable.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/Cancellable.java @@ -25,9 +25,9 @@ package me.lucko.luckperms.api.event; -import java.util.concurrent.atomic.AtomicBoolean; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.concurrent.atomic.AtomicBoolean; /** * Represents an event that can be cancelled @@ -39,7 +39,7 @@ public interface Cancellable { * * @return the cancellation */ - @Nonnull + @NonNull @Param(-1) AtomicBoolean getCancellationState(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/EventBus.java b/api/src/main/java/me/lucko/luckperms/api/event/EventBus.java index 5550e1a3..ad051197 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/EventBus.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/EventBus.java @@ -25,11 +25,11 @@ package me.lucko.luckperms.api.event; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.Set; import java.util.function.Consumer; -import javax.annotation.Nonnull; - /** * The LuckPerms event bus. * @@ -51,8 +51,8 @@ public interface EventBus { * @param the event class * @return an event handler instance representing this subscription */ - @Nonnull - EventHandler subscribe(@Nonnull Class eventClass, @Nonnull Consumer handler); + @NonNull + EventHandler subscribe(@NonNull Class eventClass, @NonNull Consumer handler); /** * Registers a new subscription to the given event. @@ -72,8 +72,8 @@ public interface EventBus { * @param handler the event handler * @return an event handler instance representing this subscription */ - @Nonnull - EventHandler subscribe(Object plugin, @Nonnull Class eventClass, @Nonnull Consumer handler); + @NonNull + EventHandler subscribe(Object plugin, @NonNull Class eventClass, @NonNull Consumer handler); /** * Gets a set of all registered handlers for a given event. @@ -82,7 +82,7 @@ public interface EventBus { * @param the event class * @return an immutable set of event handlers */ - @Nonnull - Set> getHandlers(@Nonnull Class eventClass); + @NonNull + Set> getHandlers(@NonNull Class eventClass); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/EventHandler.java b/api/src/main/java/me/lucko/luckperms/api/event/EventHandler.java index 6d6389f9..e84aad97 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/EventHandler.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/EventHandler.java @@ -25,9 +25,9 @@ package me.lucko.luckperms.api.event; -import java.util.function.Consumer; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.function.Consumer; /** * Represents a subscription to a {@link LuckPermsEvent}. @@ -41,7 +41,7 @@ public interface EventHandler extends AutoCloseable { * * @return the event class */ - @Nonnull + @NonNull Class getEventClass(); /** @@ -63,7 +63,7 @@ public interface EventHandler extends AutoCloseable { * * @return the event consumer */ - @Nonnull + @NonNull Consumer getConsumer(); /** diff --git a/api/src/main/java/me/lucko/luckperms/api/event/LuckPermsEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/LuckPermsEvent.java index 2bff5ae0..cd8ec427 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/LuckPermsEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/LuckPermsEvent.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.api.event; import me.lucko.luckperms.api.LuckPermsApi; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * A superinterface for all LuckPerms events. @@ -41,7 +41,7 @@ public interface LuckPermsEvent { * * @return the api instance */ - @Nonnull + @NonNull LuckPermsApi getApi(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/Sourced.java b/api/src/main/java/me/lucko/luckperms/api/event/Sourced.java index 16a75678..5c179f95 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/Sourced.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/Sourced.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.api.event; import me.lucko.luckperms.api.event.source.Source; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Represents an event with a {@link Source}. @@ -44,7 +44,7 @@ public interface Sourced { * * @return the source */ - @Nonnull + @NonNull @Param(-1) Source getSource(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCacheLoadEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCacheLoadEvent.java index 94db1848..8168413b 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCacheLoadEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCacheLoadEvent.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.caching.GroupData; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a groups {@link GroupData} is loaded. @@ -44,7 +44,7 @@ public interface GroupCacheLoadEvent extends LuckPermsEvent { * * @return the group */ - @Nonnull + @NonNull @Param(0) Group getGroup(); @@ -53,7 +53,7 @@ public interface GroupCacheLoadEvent extends LuckPermsEvent { * * @return the loaded data */ - @Nonnull + @NonNull @Param(1) GroupData getLoadedData(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCreateEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCreateEvent.java index 885264e3..0a6bb860 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCreateEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCreateEvent.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; import me.lucko.luckperms.api.event.cause.CreationCause; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a group is created @@ -42,7 +42,7 @@ public interface GroupCreateEvent extends LuckPermsEvent { * * @return the new group */ - @Nonnull + @NonNull @Param(0) Group getGroup(); @@ -51,7 +51,7 @@ public interface GroupCreateEvent extends LuckPermsEvent { * * @return the cause of the creation */ - @Nonnull + @NonNull @Param(1) CreationCause getCause(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDataRecalculateEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDataRecalculateEvent.java index 9afde7c4..628e0661 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDataRecalculateEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDataRecalculateEvent.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.caching.GroupData; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a groups cached data is refreshed @@ -44,7 +44,7 @@ public interface GroupDataRecalculateEvent extends LuckPermsEvent { * * @return the group */ - @Nonnull + @NonNull @Param(0) Group getGroup(); @@ -53,7 +53,7 @@ public interface GroupDataRecalculateEvent extends LuckPermsEvent { * * @return the data */ - @Nonnull + @NonNull @Param(1) GroupData getData(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDeleteEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDeleteEvent.java index a9fa994d..9c129402 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDeleteEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDeleteEvent.java @@ -30,9 +30,9 @@ import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; import me.lucko.luckperms.api.event.cause.DeletionCause; -import java.util.Set; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Set; /** * Called when a group is deleted @@ -44,7 +44,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent { * * @return the name of the deleted group */ - @Nonnull + @NonNull @Param(0) String getGroupName(); @@ -53,7 +53,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent { * * @return a copy of the groups existing data */ - @Nonnull + @NonNull @Param(1) Set getExistingData(); @@ -62,7 +62,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent { * * @return the cause of the deletion */ - @Nonnull + @NonNull @Param(2) DeletionCause getCause(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadEvent.java index b6dbc0c2..975f2e95 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadEvent.java @@ -29,7 +29,7 @@ import me.lucko.luckperms.api.Group; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a group is loaded into memory from the storage. @@ -43,7 +43,7 @@ public interface GroupLoadEvent extends LuckPermsEvent { * * @return the group that was loaded */ - @Nonnull + @NonNull @Param(0) Group getGroup(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/log/LogBroadcastEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/log/LogBroadcastEvent.java index 81188d33..7c34bb62 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/log/LogBroadcastEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/log/LogBroadcastEvent.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.event.Cancellable; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a log entry is about to be sent to notifiable players on the platform @@ -42,7 +42,7 @@ public interface LogBroadcastEvent extends LuckPermsEvent, Cancellable { * * @return the log entry to be broadcasted */ - @Nonnull + @NonNull @Param(0) LogEntry getEntry(); @@ -52,7 +52,7 @@ public interface LogBroadcastEvent extends LuckPermsEvent, Cancellable { * @return the origin of the log * @since 3.3 */ - @Nonnull + @NonNull @Param(1) Origin getOrigin(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/log/LogNetworkPublishEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/log/LogNetworkPublishEvent.java index e0b2af09..d2db4d43 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/log/LogNetworkPublishEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/log/LogNetworkPublishEvent.java @@ -30,9 +30,9 @@ import me.lucko.luckperms.api.event.Cancellable; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import java.util.UUID; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.UUID; /** * Called when a log is about to be published to the network via the MessagingService @@ -46,7 +46,7 @@ public interface LogNetworkPublishEvent extends LuckPermsEvent, Cancellable { * * @return the id of the log entry being published */ - @Nonnull + @NonNull @Param(0) UUID getLogId(); @@ -55,7 +55,7 @@ public interface LogNetworkPublishEvent extends LuckPermsEvent, Cancellable { * * @return the log entry to be published */ - @Nonnull + @NonNull @Param(1) LogEntry getEntry(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/log/LogNotifyEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/log/LogNotifyEvent.java index e7e5fc39..c0350046 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/log/LogNotifyEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/log/LogNotifyEvent.java @@ -31,7 +31,7 @@ import me.lucko.luckperms.api.event.Cancellable; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a log entry is about to be sent to specific notifiable object on @@ -50,7 +50,7 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable { * * @return the log entry to be sent */ - @Nonnull + @NonNull @Param(0) LogEntry getEntry(); @@ -59,7 +59,7 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable { * * @return the origin of the log */ - @Nonnull + @NonNull @Param(1) Origin getOrigin(); @@ -68,7 +68,7 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable { * * @return the object to notify */ - @Nonnull + @NonNull @Param(2) Entity getNotifiable(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/log/LogPublishEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/log/LogPublishEvent.java index 9298a395..2751333a 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/log/LogPublishEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/log/LogPublishEvent.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.event.Cancellable; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a log is about to be published to the storage file/table @@ -42,7 +42,7 @@ public interface LogPublishEvent extends LuckPermsEvent, Cancellable { * * @return the log entry to be published */ - @Nonnull + @NonNull @Param(0) LogEntry getEntry(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/log/LogReceiveEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/log/LogReceiveEvent.java index d107649f..c3b8350d 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/log/LogReceiveEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/log/LogReceiveEvent.java @@ -29,9 +29,9 @@ import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import java.util.UUID; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.UUID; /** * Called when a log entry is received via the MessagingService @@ -45,7 +45,7 @@ public interface LogReceiveEvent extends LuckPermsEvent { * * @return the id of the log entry being received */ - @Nonnull + @NonNull @Param(0) UUID getLogId(); @@ -54,7 +54,7 @@ public interface LogReceiveEvent extends LuckPermsEvent { * * @return the log entry being received */ - @Nonnull + @NonNull @Param(1) LogEntry getEntry(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/node/NodeAddEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeAddEvent.java index 544101d9..881e8238 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/node/NodeAddEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeAddEvent.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.api.event.node; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a node is added to a holder @@ -40,7 +40,7 @@ public interface NodeAddEvent extends NodeMutateEvent { * * @return the node that was added */ - @Nonnull + @NonNull @Param(3) Node getNode(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/node/NodeMutateEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeMutateEvent.java index 405005b0..da6e4b43 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/node/NodeMutateEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeMutateEvent.java @@ -32,9 +32,9 @@ import me.lucko.luckperms.api.User; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import java.util.Set; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Set; /** * Called when a node is added to/removed from a user/group @@ -46,7 +46,7 @@ public interface NodeMutateEvent extends LuckPermsEvent { * * @return the event target */ - @Nonnull + @NonNull @Param(0) PermissionHolder getTarget(); @@ -55,7 +55,7 @@ public interface NodeMutateEvent extends LuckPermsEvent { * * @return the data before the change */ - @Nonnull + @NonNull @Param(1) Set getDataBefore(); @@ -64,7 +64,7 @@ public interface NodeMutateEvent extends LuckPermsEvent { * * @return the data after the change */ - @Nonnull + @NonNull @Param(2) Set getDataAfter(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/node/NodeRemoveEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeRemoveEvent.java index 2d04c7cc..9a4fe96b 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/node/NodeRemoveEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeRemoveEvent.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.api.event.node; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a node is removed from a holder @@ -40,7 +40,7 @@ public interface NodeRemoveEvent extends NodeMutateEvent { * * @return the node that was removed */ - @Nonnull + @NonNull @Param(3) Node getNode(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/player/PlayerDataSaveEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/player/PlayerDataSaveEvent.java index cb280138..ea5d4673 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/player/PlayerDataSaveEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/player/PlayerDataSaveEvent.java @@ -30,9 +30,9 @@ import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; import me.lucko.luckperms.api.manager.UserManager; -import java.util.UUID; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.UUID; /** * Called when player data is saved to the storage. @@ -48,7 +48,7 @@ public interface PlayerDataSaveEvent extends LuckPermsEvent { * * @return the uuid */ - @Nonnull + @NonNull @Param(0) UUID getUuid(); @@ -57,7 +57,7 @@ public interface PlayerDataSaveEvent extends LuckPermsEvent { * * @return the username */ - @Nonnull + @NonNull @Param(1) String getUsername(); @@ -66,7 +66,7 @@ public interface PlayerDataSaveEvent extends LuckPermsEvent { * * @return the result */ - @Nonnull + @NonNull @Param(2) PlayerSaveResult getResult(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/source/EntitySource.java b/api/src/main/java/me/lucko/luckperms/api/event/source/EntitySource.java index 746ebc45..071a10d0 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/source/EntitySource.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/source/EntitySource.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.api.event.source; import me.lucko.luckperms.api.Entity; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Represents an {@link Entity} which was the {@link Source} of something. @@ -41,7 +41,7 @@ public interface EntitySource extends Source { * * @return the entity */ - @Nonnull + @NonNull Entity getEntity(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/source/Source.java b/api/src/main/java/me/lucko/luckperms/api/event/source/Source.java index ded9e6d5..86143db0 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/source/Source.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/source/Source.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.api.event.source; import me.lucko.luckperms.api.Entity; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Represents the source of an event. @@ -43,7 +43,7 @@ public interface Source { * * @return the type */ - @Nonnull + @NonNull Type getType(); /** diff --git a/api/src/main/java/me/lucko/luckperms/api/event/sync/PreNetworkSyncEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/sync/PreNetworkSyncEvent.java index 9f67c769..a23aaa6e 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/sync/PreNetworkSyncEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/sync/PreNetworkSyncEvent.java @@ -29,9 +29,9 @@ import me.lucko.luckperms.api.event.Cancellable; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import java.util.UUID; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.UUID; /** * Called before a received network sync task runs @@ -43,7 +43,7 @@ public interface PreNetworkSyncEvent extends LuckPermsEvent, Cancellable { * * @return the id of the sync request */ - @Nonnull + @NonNull @Param(0) UUID getSyncId(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/TrackCreateEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackCreateEvent.java index 24fdc73c..bbc5a0ab 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/track/TrackCreateEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackCreateEvent.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; import me.lucko.luckperms.api.event.cause.CreationCause; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a track is created @@ -42,7 +42,7 @@ public interface TrackCreateEvent extends LuckPermsEvent { * * @return the new track */ - @Nonnull + @NonNull @Param(0) Track getTrack(); @@ -51,7 +51,7 @@ public interface TrackCreateEvent extends LuckPermsEvent { * * @return the cause of the creation */ - @Nonnull + @NonNull @Param(1) CreationCause getCause(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/TrackDeleteEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackDeleteEvent.java index e9b41bfc..e9c3a4f7 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/track/TrackDeleteEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackDeleteEvent.java @@ -29,9 +29,9 @@ import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; import me.lucko.luckperms.api.event.cause.DeletionCause; -import java.util.List; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.List; /** * Called when a track is deleted @@ -43,7 +43,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent { * * @return the name of the deleted track */ - @Nonnull + @NonNull @Param(0) String getTrackName(); @@ -52,7 +52,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent { * * @return a copy of the tracks existing data */ - @Nonnull + @NonNull @Param(1) List getExistingData(); @@ -61,7 +61,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent { * * @return the cause of the deletion */ - @Nonnull + @NonNull @Param(2) DeletionCause getCause(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/TrackLoadEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackLoadEvent.java index 368e27aa..3e38d3b4 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/track/TrackLoadEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackLoadEvent.java @@ -29,7 +29,7 @@ import me.lucko.luckperms.api.Track; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a track is loaded into memory from the storage. @@ -43,7 +43,7 @@ public interface TrackLoadEvent extends LuckPermsEvent { * * @return the track that was loaded */ - @Nonnull + @NonNull @Param(0) Track getTrack(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackAddGroupEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackAddGroupEvent.java index 1ace501e..b69e9eea 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackAddGroupEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackAddGroupEvent.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.api.event.track.mutate; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a group is added to a track @@ -39,7 +39,7 @@ public interface TrackAddGroupEvent extends TrackMutateEvent { * * @return the group that was added */ - @Nonnull + @NonNull @Param(3) String getGroup(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackMutateEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackMutateEvent.java index 145534af..516c50bc 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackMutateEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackMutateEvent.java @@ -29,9 +29,9 @@ import me.lucko.luckperms.api.Track; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import java.util.List; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.List; /** * Called when a track is changed @@ -43,7 +43,7 @@ public interface TrackMutateEvent extends LuckPermsEvent { * * @return the track that was mutated */ - @Nonnull + @NonNull @Param(0) Track getTrack(); @@ -52,7 +52,7 @@ public interface TrackMutateEvent extends LuckPermsEvent { * * @return the data before the change */ - @Nonnull + @NonNull @Param(1) List getDataBefore(); @@ -61,7 +61,7 @@ public interface TrackMutateEvent extends LuckPermsEvent { * * @return the data after the change */ - @Nonnull + @NonNull @Param(2) List getDataAfter(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackRemoveGroupEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackRemoveGroupEvent.java index 3c6aaec3..abe2d239 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackRemoveGroupEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackRemoveGroupEvent.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.api.event.track.mutate; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a group is removed from a track @@ -39,7 +39,7 @@ public interface TrackRemoveGroupEvent extends TrackMutateEvent { * * @return the group that was removed */ - @Nonnull + @NonNull @Param(3) String getGroup(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/UserCacheLoadEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/UserCacheLoadEvent.java index be2dcb2f..5d3370c9 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/user/UserCacheLoadEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/user/UserCacheLoadEvent.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.caching.UserData; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a users {@link UserData} is loaded. @@ -42,7 +42,7 @@ public interface UserCacheLoadEvent extends LuckPermsEvent { * * @return the user */ - @Nonnull + @NonNull @Param(0) User getUser(); @@ -51,7 +51,7 @@ public interface UserCacheLoadEvent extends LuckPermsEvent { * * @return the loaded data */ - @Nonnull + @NonNull @Param(1) UserData getLoadedData(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/UserDataRecalculateEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/UserDataRecalculateEvent.java index bf57916e..7dba5f82 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/user/UserDataRecalculateEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/user/UserDataRecalculateEvent.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.caching.UserData; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a users cached data is refreshed @@ -42,7 +42,7 @@ public interface UserDataRecalculateEvent extends LuckPermsEvent { * * @return the user */ - @Nonnull + @NonNull @Param(0) User getUser(); @@ -51,7 +51,7 @@ public interface UserDataRecalculateEvent extends LuckPermsEvent { * * @return the data */ - @Nonnull + @NonNull @Param(1) UserData getData(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/UserFirstLoginEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/UserFirstLoginEvent.java index 2f2068b2..d1cbe3dd 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/user/UserFirstLoginEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/user/UserFirstLoginEvent.java @@ -28,9 +28,9 @@ package me.lucko.luckperms.api.event.user; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import java.util.UUID; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.UUID; /** * Called when the user logs into the network for the first time. @@ -50,7 +50,7 @@ public interface UserFirstLoginEvent extends LuckPermsEvent { * * @return the uuid of the user */ - @Nonnull + @NonNull @Param(0) UUID getUuid(); @@ -59,7 +59,7 @@ public interface UserFirstLoginEvent extends LuckPermsEvent { * * @return the username of the user */ - @Nonnull + @NonNull @Param(1) String getUsername(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoadEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoadEvent.java index f67e94e4..1338b64b 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoadEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoadEvent.java @@ -29,7 +29,7 @@ import me.lucko.luckperms.api.User; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a user is loaded into memory from the storage. @@ -41,7 +41,7 @@ public interface UserLoadEvent extends LuckPermsEvent { * * @return the user that was loaded */ - @Nonnull + @NonNull @Param(0) User getUser(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoginProcessEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoginProcessEvent.java index c95f5b3d..fa27dab8 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoginProcessEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoginProcessEvent.java @@ -29,9 +29,9 @@ import me.lucko.luckperms.api.User; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; -import java.util.UUID; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.UUID; /** * Called when LuckPerms has finished processing a certain Player's connection. @@ -52,7 +52,7 @@ public interface UserLoginProcessEvent extends LuckPermsEvent { * * @return the uuid of the connection which was processed */ - @Nonnull + @NonNull @Param(0) UUID getUuid(); @@ -61,7 +61,7 @@ public interface UserLoginProcessEvent extends LuckPermsEvent { * * @return the username of the connection which was processed */ - @Nonnull + @NonNull @Param(1) String getUsername(); @@ -70,7 +70,7 @@ public interface UserLoginProcessEvent extends LuckPermsEvent { * * @return the user instance */ - @Nonnull + @NonNull @Param(2) User getUser(); diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserDemoteEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserDemoteEvent.java index 02fd581c..ffd686bd 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserDemoteEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserDemoteEvent.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.api.event.user.track; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a user is demoted down a track. @@ -34,9 +34,8 @@ import javax.annotation.Nonnull; */ public interface UserDemoteEvent extends UserTrackEvent { - @Nonnull @Override - default TrackAction getAction() { + default @NonNull TrackAction getAction() { return TrackAction.DEMOTION; } } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserPromoteEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserPromoteEvent.java index edbcc242..2068703b 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserPromoteEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserPromoteEvent.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.api.event.user.track; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Called when a user is promoted up a track. @@ -34,9 +34,8 @@ import javax.annotation.Nonnull; */ public interface UserPromoteEvent extends UserTrackEvent { - @Nonnull @Override - default TrackAction getAction() { + default @NonNull TrackAction getAction() { return TrackAction.PROMOTION; } } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserTrackEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserTrackEvent.java index cf3385c5..a86d3608 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserTrackEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserTrackEvent.java @@ -31,9 +31,9 @@ import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.Param; import me.lucko.luckperms.api.event.Sourced; -import java.util.Optional; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Optional; /** * Called when a user interacts with a track through a promotion or demotion @@ -45,7 +45,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced { * * @return the track involved in the event */ - @Nonnull + @NonNull @Param(0) Track getTrack(); @@ -54,7 +54,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced { * * @return the user involved in the event */ - @Nonnull + @NonNull @Param(1) User getUser(); @@ -63,7 +63,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced { * * @return the action performed */ - @Nonnull + @NonNull TrackAction getAction(); /** @@ -73,7 +73,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced { * * @return the group the user was promoted/demoted from */ - @Nonnull + @NonNull @Param(2) Optional getGroupFrom(); @@ -82,7 +82,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced { * * @return the group the user was promoted/demoted to */ - @Nonnull + @NonNull @Param(3) Optional getGroupTo(); diff --git a/api/src/main/java/me/lucko/luckperms/api/manager/GroupManager.java b/api/src/main/java/me/lucko/luckperms/api/manager/GroupManager.java index 6537082a..aab88424 100644 --- a/api/src/main/java/me/lucko/luckperms/api/manager/GroupManager.java +++ b/api/src/main/java/me/lucko/luckperms/api/manager/GroupManager.java @@ -29,6 +29,9 @@ import me.lucko.luckperms.api.Group; import me.lucko.luckperms.api.HeldPermission; import me.lucko.luckperms.api.Storage; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + import java.util.List; import java.util.Optional; import java.util.Set; @@ -36,9 +39,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.function.Consumer; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - /** * Represents the object responsible for managing {@link Group} instances. * @@ -74,8 +74,8 @@ public interface GroupManager { * @throws NullPointerException if the name is null * @since 4.1 */ - @Nonnull - CompletableFuture createAndLoadGroup(@Nonnull String name); + @NonNull + CompletableFuture createAndLoadGroup(@NonNull String name); /** * Loads a group from the plugin's storage provider into memory. @@ -95,8 +95,8 @@ public interface GroupManager { * @throws NullPointerException if the name is null * @since 4.1 */ - @Nonnull - CompletableFuture> loadGroup(@Nonnull String name); + @NonNull + CompletableFuture> loadGroup(@NonNull String name); /** * Saves a group's data back to the plugin's storage provider. @@ -115,8 +115,8 @@ public interface GroupManager { * @throws IllegalStateException if the group instance was not obtained from LuckPerms. * @since 4.1 */ - @Nonnull - CompletableFuture saveGroup(@Nonnull Group group); + @NonNull + CompletableFuture saveGroup(@NonNull Group group); /** * Permanently deletes a group from the plugin's storage provider. @@ -134,8 +134,8 @@ public interface GroupManager { * @throws IllegalStateException if the group instance was not obtained from LuckPerms. * @since 4.1 */ - @Nonnull - CompletableFuture deleteGroup(@Nonnull Group group); + @NonNull + CompletableFuture deleteGroup(@NonNull Group group); /** * Loads all groups into memory. @@ -149,7 +149,7 @@ public interface GroupManager { * @return a future to encapsulate the operation. * @since 4.1 */ - @Nonnull + @NonNull CompletableFuture loadAllGroups(); /** @@ -160,8 +160,8 @@ public interface GroupManager { * @throws NullPointerException if the permission is null * @since 4.2 */ - @Nonnull - CompletableFuture>> getWithPermission(@Nonnull String permission); + @NonNull + CompletableFuture>> getWithPermission(@NonNull String permission); /** * Gets a loaded group. @@ -171,7 +171,7 @@ public interface GroupManager { * @throws NullPointerException if the name is null */ @Nullable - Group getGroup(@Nonnull String name); + Group getGroup(@NonNull String name); /** * Gets a loaded group. @@ -182,8 +182,7 @@ public interface GroupManager { * @return an optional {@link Group} object * @throws NullPointerException if the name is null */ - @Nonnull - default Optional getGroupOpt(@Nonnull String name) { + default @NonNull Optional getGroupOpt(@NonNull String name) { return Optional.ofNullable(getGroup(name)); } @@ -192,7 +191,7 @@ public interface GroupManager { * * @return a {@link Set} of {@link Group} objects */ - @Nonnull + @NonNull Set getLoadedGroups(); /** @@ -202,6 +201,6 @@ public interface GroupManager { * @return true if the group is loaded * @throws NullPointerException if the name is null */ - boolean isLoaded(@Nonnull String name); + boolean isLoaded(@NonNull String name); } diff --git a/api/src/main/java/me/lucko/luckperms/api/manager/TrackManager.java b/api/src/main/java/me/lucko/luckperms/api/manager/TrackManager.java index c7682895..25d9bf0d 100644 --- a/api/src/main/java/me/lucko/luckperms/api/manager/TrackManager.java +++ b/api/src/main/java/me/lucko/luckperms/api/manager/TrackManager.java @@ -28,15 +28,15 @@ package me.lucko.luckperms.api.manager; import me.lucko.luckperms.api.Storage; import me.lucko.luckperms.api.Track; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.function.Consumer; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - /** * Represents the object responsible for managing {@link Track} instances. * @@ -72,8 +72,8 @@ public interface TrackManager { * @throws NullPointerException if the name is null * @since 4.1 */ - @Nonnull - CompletableFuture createAndLoadTrack(@Nonnull String name); + @NonNull + CompletableFuture createAndLoadTrack(@NonNull String name); /** * Loads a track from the plugin's storage provider into memory. @@ -93,8 +93,8 @@ public interface TrackManager { * @throws NullPointerException if the name is null * @since 4.1 */ - @Nonnull - CompletableFuture> loadTrack(@Nonnull String name); + @NonNull + CompletableFuture> loadTrack(@NonNull String name); /** * Saves a track's data back to the plugin's storage provider. @@ -113,8 +113,8 @@ public interface TrackManager { * @throws IllegalStateException if the track instance was not obtained from LuckPerms. * @since 4.1 */ - @Nonnull - CompletableFuture saveTrack(@Nonnull Track track); + @NonNull + CompletableFuture saveTrack(@NonNull Track track); /** * Permanently deletes a track from the plugin's storage provider. @@ -132,8 +132,8 @@ public interface TrackManager { * @throws IllegalStateException if the track instance was not obtained from LuckPerms. * @since 4.1 */ - @Nonnull - CompletableFuture deleteTrack(@Nonnull Track track); + @NonNull + CompletableFuture deleteTrack(@NonNull Track track); /** * Loads all tracks into memory. @@ -147,7 +147,7 @@ public interface TrackManager { * @return a future to encapsulate the operation. * @since 4.1 */ - @Nonnull + @NonNull CompletableFuture loadAllTracks(); /** @@ -158,7 +158,7 @@ public interface TrackManager { * @throws NullPointerException if the name is null */ @Nullable - Track getTrack(@Nonnull String name); + Track getTrack(@NonNull String name); /** * Gets a loaded track. @@ -169,8 +169,7 @@ public interface TrackManager { * @return an optional {@link Track} object * @throws NullPointerException if the name is null */ - @Nonnull - default Optional getTrackOpt(@Nonnull String name) { + default @NonNull Optional getTrackOpt(@NonNull String name) { return Optional.ofNullable(getTrack(name)); } @@ -179,7 +178,7 @@ public interface TrackManager { * * @return a {@link Set} of {@link Track} objects */ - @Nonnull + @NonNull Set getLoadedTracks(); /** @@ -189,6 +188,6 @@ public interface TrackManager { * @return true if the track is loaded * @throws NullPointerException if the name is null */ - boolean isLoaded(@Nonnull String name); + boolean isLoaded(@NonNull String name); } diff --git a/api/src/main/java/me/lucko/luckperms/api/manager/UserManager.java b/api/src/main/java/me/lucko/luckperms/api/manager/UserManager.java index 3d96dd84..815a1fdd 100644 --- a/api/src/main/java/me/lucko/luckperms/api/manager/UserManager.java +++ b/api/src/main/java/me/lucko/luckperms/api/manager/UserManager.java @@ -30,6 +30,9 @@ import me.lucko.luckperms.api.PlayerSaveResult; import me.lucko.luckperms.api.Storage; import me.lucko.luckperms.api.User; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + import java.util.List; import java.util.Optional; import java.util.Set; @@ -38,9 +41,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.function.Consumer; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - /** * Represents the object responsible for managing {@link User} instances. * @@ -77,8 +77,8 @@ public interface UserManager { * @throws NullPointerException if the uuid is null * @since 4.1 */ - @Nonnull - CompletableFuture loadUser(@Nonnull UUID uuid, @Nullable String username); + @NonNull + CompletableFuture loadUser(@NonNull UUID uuid, @Nullable String username); /** * Loads a user from the plugin's storage provider into memory. @@ -95,8 +95,7 @@ public interface UserManager { * @throws NullPointerException if the uuid is null * @since 4.1 */ - @Nonnull - default CompletableFuture loadUser(@Nonnull UUID uuid) { + default @NonNull CompletableFuture loadUser(@NonNull UUID uuid) { return loadUser(uuid, null); } @@ -111,8 +110,8 @@ public interface UserManager { * @throws IllegalArgumentException if the username is invalid * @since 4.2 */ - @Nonnull - CompletableFuture lookupUuid(@Nonnull String username); + @NonNull + CompletableFuture lookupUuid(@NonNull String username); /** * Uses the LuckPerms cache to find a username for the given uuid. @@ -123,8 +122,8 @@ public interface UserManager { * @throws IllegalArgumentException if the username is invalid * @since 4.2 */ - @Nonnull - CompletableFuture lookupUsername(@Nonnull UUID uuid); + @NonNull + CompletableFuture lookupUsername(@NonNull UUID uuid); /** * Saves a user's data back to the plugin's storage provider. @@ -143,8 +142,8 @@ public interface UserManager { * @throws IllegalStateException if the user instance was not obtained from LuckPerms. * @since 4.1 */ - @Nonnull - CompletableFuture saveUser(@Nonnull User user); + @NonNull + CompletableFuture saveUser(@NonNull User user); /** * Saves data about a player to the uuid caching system. @@ -156,8 +155,8 @@ public interface UserManager { * @throws IllegalArgumentException if the username is invalid * @since 4.2 */ - @Nonnull - CompletableFuture savePlayerData(@Nonnull UUID uuid, @Nonnull String username); + @NonNull + CompletableFuture savePlayerData(@NonNull UUID uuid, @NonNull String username); /** * Gets a set all "unique" user UUIDs. @@ -167,7 +166,7 @@ public interface UserManager { * @return a set of uuids * @since 4.2 */ - @Nonnull + @NonNull CompletableFuture> getUniqueUsers(); /** @@ -178,8 +177,8 @@ public interface UserManager { * @throws NullPointerException if the permission is null * @since 4.2 */ - @Nonnull - CompletableFuture>> getWithPermission(@Nonnull String permission); + @NonNull + CompletableFuture>> getWithPermission(@NonNull String permission); /** * Gets a loaded user. @@ -189,7 +188,7 @@ public interface UserManager { * @throws NullPointerException if the uuid is null */ @Nullable - User getUser(@Nonnull UUID uuid); + User getUser(@NonNull UUID uuid); /** * Gets a loaded user. @@ -198,8 +197,7 @@ public interface UserManager { * @return an optional {@link User} object * @throws NullPointerException if the uuid is null */ - @Nonnull - default Optional getUserOpt(@Nonnull UUID uuid) { + default @NonNull Optional getUserOpt(@NonNull UUID uuid) { return Optional.ofNullable(getUser(uuid)); } @@ -211,7 +209,7 @@ public interface UserManager { * @throws NullPointerException if the name is null */ @Nullable - User getUser(@Nonnull String name); + User getUser(@NonNull String name); /** * Gets a loaded user. @@ -220,8 +218,7 @@ public interface UserManager { * @return an optional {@link User} object * @throws NullPointerException if the name is null */ - @Nonnull - default Optional getUserOpt(@Nonnull String name) { + default @NonNull Optional getUserOpt(@NonNull String name) { return Optional.ofNullable(getUser(name)); } @@ -230,7 +227,7 @@ public interface UserManager { * * @return a {@link Set} of {@link User} objects */ - @Nonnull + @NonNull Set getLoadedUsers(); /** @@ -240,7 +237,7 @@ public interface UserManager { * @return true if the user is loaded * @throws NullPointerException if the uuid is null */ - boolean isLoaded(@Nonnull UUID uuid); + boolean isLoaded(@NonNull UUID uuid); /** * Unload a user from the internal storage, if they're not currently online. @@ -248,6 +245,6 @@ public interface UserManager { * @param user the user to unload * @throws NullPointerException if the user is null */ - void cleanupUser(@Nonnull User user); + void cleanupUser(@NonNull User user); } diff --git a/api/src/main/java/me/lucko/luckperms/api/messenger/IncomingMessageConsumer.java b/api/src/main/java/me/lucko/luckperms/api/messenger/IncomingMessageConsumer.java index c568c1f6..4da213d6 100644 --- a/api/src/main/java/me/lucko/luckperms/api/messenger/IncomingMessageConsumer.java +++ b/api/src/main/java/me/lucko/luckperms/api/messenger/IncomingMessageConsumer.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.api.messenger; import me.lucko.luckperms.api.messenger.message.Message; import me.lucko.luckperms.api.messenger.message.OutgoingMessage; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Encapsulates the LuckPerms system which accepts incoming {@link Message}s @@ -52,7 +52,7 @@ public interface IncomingMessageConsumer { * @param message the message * @return true if the message was accepted by the plugin */ - boolean consumeIncomingMessage(@Nonnull Message message); + boolean consumeIncomingMessage(@NonNull Message message); /** * Consumes a message in an encoded string format. @@ -73,6 +73,6 @@ public interface IncomingMessageConsumer { * @param encodedString the encoded string * @return true if the message was accepted by the plugin */ - boolean consumeIncomingMessageAsString(@Nonnull String encodedString); + boolean consumeIncomingMessageAsString(@NonNull String encodedString); } diff --git a/api/src/main/java/me/lucko/luckperms/api/messenger/Messenger.java b/api/src/main/java/me/lucko/luckperms/api/messenger/Messenger.java index 54bb8fe2..a4928538 100644 --- a/api/src/main/java/me/lucko/luckperms/api/messenger/Messenger.java +++ b/api/src/main/java/me/lucko/luckperms/api/messenger/Messenger.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.api.messenger; import me.lucko.luckperms.api.messenger.message.Message; import me.lucko.luckperms.api.messenger.message.OutgoingMessage; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Represents an object which dispatches {@link OutgoingMessage}s. @@ -52,7 +52,7 @@ public interface Messenger extends AutoCloseable { * * @param outgoingMessage the outgoing message */ - void sendOutgoingMessage(@Nonnull OutgoingMessage outgoingMessage); + void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage); /** * Performs the necessary action to gracefully shutdown the messenger. diff --git a/api/src/main/java/me/lucko/luckperms/api/messenger/MessengerProvider.java b/api/src/main/java/me/lucko/luckperms/api/messenger/MessengerProvider.java index 97669c83..033c931a 100644 --- a/api/src/main/java/me/lucko/luckperms/api/messenger/MessengerProvider.java +++ b/api/src/main/java/me/lucko/luckperms/api/messenger/MessengerProvider.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.api.messenger; import me.lucko.luckperms.api.LuckPermsApi; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Represents a provider for {@link Messenger} instances. @@ -45,7 +45,7 @@ public interface MessengerProvider { * * @return the provider name */ - @Nonnull + @NonNull String getName(); /** @@ -59,7 +59,7 @@ public interface MessengerProvider { * incoming messages to * @return a new messenger agent instance */ - @Nonnull - Messenger obtain(@Nonnull IncomingMessageConsumer incomingMessageConsumer); + @NonNull + Messenger obtain(@NonNull IncomingMessageConsumer incomingMessageConsumer); } diff --git a/api/src/main/java/me/lucko/luckperms/api/messenger/message/Message.java b/api/src/main/java/me/lucko/luckperms/api/messenger/message/Message.java index 55b23b1d..fcddc8e9 100644 --- a/api/src/main/java/me/lucko/luckperms/api/messenger/message/Message.java +++ b/api/src/main/java/me/lucko/luckperms/api/messenger/message/Message.java @@ -27,9 +27,9 @@ package me.lucko.luckperms.api.messenger.message; import me.lucko.luckperms.api.messenger.Messenger; -import java.util.UUID; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.UUID; /** * Represents a message sent received via a {@link Messenger}. @@ -46,7 +46,7 @@ public interface Message { * * @return the id of the message */ - @Nonnull + @NonNull UUID getId(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/messenger/message/OutgoingMessage.java b/api/src/main/java/me/lucko/luckperms/api/messenger/message/OutgoingMessage.java index 86e459b3..55a2ee23 100644 --- a/api/src/main/java/me/lucko/luckperms/api/messenger/message/OutgoingMessage.java +++ b/api/src/main/java/me/lucko/luckperms/api/messenger/message/OutgoingMessage.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.api.messenger.message; import me.lucko.luckperms.api.messenger.IncomingMessageConsumer; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Represents an outgoing {@link Message}. @@ -56,7 +56,7 @@ public interface OutgoingMessage extends Message { * * @return an encoded string form of the message */ - @Nonnull + @NonNull String asEncodedString(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/messenger/message/type/LogMessage.java b/api/src/main/java/me/lucko/luckperms/api/messenger/message/type/LogMessage.java index 8bf93aab..5951a073 100644 --- a/api/src/main/java/me/lucko/luckperms/api/messenger/message/type/LogMessage.java +++ b/api/src/main/java/me/lucko/luckperms/api/messenger/message/type/LogMessage.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.api.messenger.message.type; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.messenger.message.Message; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Represents an "log" message. @@ -44,7 +44,7 @@ public interface LogMessage extends Message { * * @return the log entry */ - @Nonnull + @NonNull LogEntry getLogEntry(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/messenger/message/type/UserUpdateMessage.java b/api/src/main/java/me/lucko/luckperms/api/messenger/message/type/UserUpdateMessage.java index 7d8656d0..82a7776c 100644 --- a/api/src/main/java/me/lucko/luckperms/api/messenger/message/type/UserUpdateMessage.java +++ b/api/src/main/java/me/lucko/luckperms/api/messenger/message/type/UserUpdateMessage.java @@ -27,9 +27,9 @@ package me.lucko.luckperms.api.messenger.message.type; import me.lucko.luckperms.api.messenger.message.Message; -import java.util.UUID; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.UUID; /** * Represents an "user update" message. @@ -45,7 +45,7 @@ public interface UserUpdateMessage extends Message { * * @return the user */ - @Nonnull + @NonNull UUID getUser(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/metastacking/MetaStackDefinition.java b/api/src/main/java/me/lucko/luckperms/api/metastacking/MetaStackDefinition.java index 4d6b7f09..2ca51d46 100644 --- a/api/src/main/java/me/lucko/luckperms/api/metastacking/MetaStackDefinition.java +++ b/api/src/main/java/me/lucko/luckperms/api/metastacking/MetaStackDefinition.java @@ -25,10 +25,9 @@ package me.lucko.luckperms.api.metastacking; -import java.util.List; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.Immutable; +import java.util.List; /** * Represents a meta stack model, consisting of a chain of elements, separated by spacers. @@ -41,7 +40,6 @@ import javax.annotation.concurrent.Immutable; * * @since 2.3 */ -@Immutable public interface MetaStackDefinition { /** @@ -49,7 +47,7 @@ public interface MetaStackDefinition { * * @return the elements in this stack */ - @Nonnull + @NonNull List getElements(); /** @@ -57,7 +55,7 @@ public interface MetaStackDefinition { * * @return the start spacer */ - @Nonnull + @NonNull String getStartSpacer(); /** @@ -65,7 +63,7 @@ public interface MetaStackDefinition { * * @return the middle spacer */ - @Nonnull + @NonNull String getMiddleSpacer(); /** @@ -73,7 +71,7 @@ public interface MetaStackDefinition { * * @return the end spacer */ - @Nonnull + @NonNull String getEndSpacer(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/metastacking/MetaStackElement.java b/api/src/main/java/me/lucko/luckperms/api/metastacking/MetaStackElement.java index daddc269..047b674f 100644 --- a/api/src/main/java/me/lucko/luckperms/api/metastacking/MetaStackElement.java +++ b/api/src/main/java/me/lucko/luckperms/api/metastacking/MetaStackElement.java @@ -29,11 +29,10 @@ import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.LocalizedNode; import me.lucko.luckperms.api.Node; -import java.util.Map; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; +import java.util.Map; /** * Represents an element within a {@link MetaStackDefinition}. @@ -42,7 +41,6 @@ import javax.annotation.concurrent.Immutable; * * @since 3.2 */ -@Immutable public interface MetaStackElement { /** @@ -55,6 +53,6 @@ public interface MetaStackElement { * @param current the current value being used. If this returns true, the current value will be replaced by this entry * @return true if the node should be accumulated into this element, replacing the current value */ - boolean shouldAccumulate(@Nonnull LocalizedNode node, @Nonnull ChatMetaType type, @Nullable Map.Entry current); + boolean shouldAccumulate(@NonNull LocalizedNode node, @NonNull ChatMetaType type, Map.@Nullable Entry current); } diff --git a/api/src/main/java/me/lucko/luckperms/api/metastacking/MetaStackFactory.java b/api/src/main/java/me/lucko/luckperms/api/metastacking/MetaStackFactory.java index 0eccae0d..2ededcef 100644 --- a/api/src/main/java/me/lucko/luckperms/api/metastacking/MetaStackFactory.java +++ b/api/src/main/java/me/lucko/luckperms/api/metastacking/MetaStackFactory.java @@ -25,11 +25,11 @@ package me.lucko.luckperms.api.metastacking; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.List; import java.util.Optional; -import javax.annotation.Nonnull; - /** * Factory to create meta stack elements and definitions. * @@ -43,8 +43,8 @@ public interface MetaStackFactory { * @param definition the definition * @return the parsed element, if present */ - @Nonnull - Optional fromString(@Nonnull String definition); + @NonNull + Optional fromString(@NonNull String definition); /** * Parses a list of {@link MetaStackElement}s from string, using the pre-defined elements in the plugin. @@ -54,8 +54,8 @@ public interface MetaStackFactory { * @param definitions the definition strings * @return a list of parsed elements */ - @Nonnull - List fromStrings(@Nonnull List definitions); + @NonNull + List fromStrings(@NonNull List definitions); /** * Creates a new {@link MetaStackDefinition} with the given properties. @@ -66,7 +66,7 @@ public interface MetaStackFactory { * @param endSpacer the spacer to be included at the end of the stacks output * @return the new stack definition instance */ - @Nonnull - MetaStackDefinition createDefinition(@Nonnull List elements, @Nonnull String startSpacer, @Nonnull String middleSpacer, @Nonnull String endSpacer); + @NonNull + MetaStackDefinition createDefinition(@NonNull List elements, @NonNull String startSpacer, @NonNull String middleSpacer, @NonNull String endSpacer); } diff --git a/api/src/main/java/me/lucko/luckperms/api/nodetype/NodeTypeKey.java b/api/src/main/java/me/lucko/luckperms/api/nodetype/NodeTypeKey.java index 32f2dedc..651bfac5 100644 --- a/api/src/main/java/me/lucko/luckperms/api/nodetype/NodeTypeKey.java +++ b/api/src/main/java/me/lucko/luckperms/api/nodetype/NodeTypeKey.java @@ -25,11 +25,11 @@ package me.lucko.luckperms.api.nodetype; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import javax.annotation.Nonnull; - /** * Marks an instance used as a key for a {@link NodeType}. * @@ -46,8 +46,7 @@ public interface NodeTypeKey { * * @return the name of the represented type */ - @Nonnull - default String getTypeName() { + default @NonNull String getTypeName() { ParameterizedType thisType = (ParameterizedType) getClass().getGenericSuperclass(); Type nodeType = thisType.getActualTypeArguments()[0]; return ((Class) nodeType).getSimpleName(); diff --git a/api/src/main/java/me/lucko/luckperms/api/nodetype/types/DisplayNameType.java b/api/src/main/java/me/lucko/luckperms/api/nodetype/types/DisplayNameType.java index 34547034..f68d5308 100644 --- a/api/src/main/java/me/lucko/luckperms/api/nodetype/types/DisplayNameType.java +++ b/api/src/main/java/me/lucko/luckperms/api/nodetype/types/DisplayNameType.java @@ -29,7 +29,7 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.nodetype.NodeType; import me.lucko.luckperms.api.nodetype.NodeTypeKey; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * A sub-type of {@link Node} used to mark the display name of the node's holder. @@ -48,7 +48,7 @@ public interface DisplayNameType extends NodeType { * * @return the display name */ - @Nonnull + @NonNull String getDisplayName(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/nodetype/types/InheritanceType.java b/api/src/main/java/me/lucko/luckperms/api/nodetype/types/InheritanceType.java index 8f5ba38d..3800b706 100644 --- a/api/src/main/java/me/lucko/luckperms/api/nodetype/types/InheritanceType.java +++ b/api/src/main/java/me/lucko/luckperms/api/nodetype/types/InheritanceType.java @@ -29,7 +29,7 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.nodetype.NodeType; import me.lucko.luckperms.api.nodetype.NodeTypeKey; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * A sub-type of {@link Node} used to mark that the holder of the node should inherit @@ -51,7 +51,7 @@ public interface InheritanceType extends NodeType { * * @return the name of the group */ - @Nonnull + @NonNull String getGroupName(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/nodetype/types/MetaType.java b/api/src/main/java/me/lucko/luckperms/api/nodetype/types/MetaType.java index 0f9c094c..bb63c12c 100644 --- a/api/src/main/java/me/lucko/luckperms/api/nodetype/types/MetaType.java +++ b/api/src/main/java/me/lucko/luckperms/api/nodetype/types/MetaType.java @@ -29,9 +29,9 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.nodetype.NodeType; import me.lucko.luckperms.api.nodetype.NodeTypeKey; -import java.util.Map; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Map; /** * A sub-type of {@link Node} used to store meta assignments. @@ -50,7 +50,7 @@ public interface MetaType extends NodeType, Map.Entry { * * @return the meta key */ - @Nonnull + @NonNull String getKey(); /** @@ -58,7 +58,7 @@ public interface MetaType extends NodeType, Map.Entry { * * @return the meta value */ - @Nonnull + @NonNull String getValue(); @Override diff --git a/api/src/main/java/me/lucko/luckperms/api/nodetype/types/PrefixType.java b/api/src/main/java/me/lucko/luckperms/api/nodetype/types/PrefixType.java index c3a052dc..ad4bee07 100644 --- a/api/src/main/java/me/lucko/luckperms/api/nodetype/types/PrefixType.java +++ b/api/src/main/java/me/lucko/luckperms/api/nodetype/types/PrefixType.java @@ -29,9 +29,9 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.nodetype.NodeType; import me.lucko.luckperms.api.nodetype.NodeTypeKey; -import java.util.Map; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Map; /** * A sub-type of {@link Node} used to store prefix assignments. @@ -57,7 +57,7 @@ public interface PrefixType extends NodeType { * * @return the prefix */ - @Nonnull + @NonNull String getPrefix(); /** @@ -65,7 +65,6 @@ public interface PrefixType extends NodeType { * * @return a map entry representation of the priority and prefix string */ - @Nonnull - Map.Entry getAsEntry(); + Map.@NonNull Entry getAsEntry(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/nodetype/types/RegexType.java b/api/src/main/java/me/lucko/luckperms/api/nodetype/types/RegexType.java index 470df647..e965085d 100644 --- a/api/src/main/java/me/lucko/luckperms/api/nodetype/types/RegexType.java +++ b/api/src/main/java/me/lucko/luckperms/api/nodetype/types/RegexType.java @@ -29,11 +29,11 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.nodetype.NodeType; import me.lucko.luckperms.api.nodetype.NodeTypeKey; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.Optional; import java.util.regex.Pattern; -import javax.annotation.Nonnull; - /** * A sub-type of {@link Node} used to store regex permissions. * @@ -51,7 +51,7 @@ public interface RegexType extends NodeType { * * @return the pattern string */ - @Nonnull + @NonNull String getPatternString(); /** @@ -61,7 +61,7 @@ public interface RegexType extends NodeType { * * @return the pattern */ - @Nonnull + @NonNull Optional getPattern(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/nodetype/types/SuffixType.java b/api/src/main/java/me/lucko/luckperms/api/nodetype/types/SuffixType.java index 3a5b7187..4cb2a95d 100644 --- a/api/src/main/java/me/lucko/luckperms/api/nodetype/types/SuffixType.java +++ b/api/src/main/java/me/lucko/luckperms/api/nodetype/types/SuffixType.java @@ -29,9 +29,9 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.nodetype.NodeType; import me.lucko.luckperms.api.nodetype.NodeTypeKey; -import java.util.Map; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Map; /** * A sub-type of {@link Node} used to store suffix assignments. @@ -57,7 +57,7 @@ public interface SuffixType extends NodeType { * * @return the suffix */ - @Nonnull + @NonNull String getSuffix(); /** @@ -65,7 +65,6 @@ public interface SuffixType extends NodeType { * * @return a map entry representation of the priority and suffix string */ - @Nonnull - Map.Entry getAsEntry(); + Map.@NonNull Entry getAsEntry(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/platform/PlatformInfo.java b/api/src/main/java/me/lucko/luckperms/api/platform/PlatformInfo.java index edc75872..f5ea9430 100644 --- a/api/src/main/java/me/lucko/luckperms/api/platform/PlatformInfo.java +++ b/api/src/main/java/me/lucko/luckperms/api/platform/PlatformInfo.java @@ -25,11 +25,11 @@ package me.lucko.luckperms.api.platform; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.Set; import java.util.UUID; -import javax.annotation.Nonnull; - /** * Provides information about the platform LuckPerms is running on. * @@ -42,7 +42,7 @@ public interface PlatformInfo { * * @return the version of the plugin running on the platform */ - @Nonnull + @NonNull String getVersion(); /** @@ -57,7 +57,7 @@ public interface PlatformInfo { * * @return the type of platform LuckPerms is running on */ - @Nonnull + @NonNull PlatformType getType(); /** @@ -65,7 +65,7 @@ public interface PlatformInfo { * * @return the unique connections */ - @Nonnull + @NonNull Set getUniqueConnections(); /** diff --git a/api/src/main/java/me/lucko/luckperms/api/platform/PlatformType.java b/api/src/main/java/me/lucko/luckperms/api/platform/PlatformType.java index c5da9bce..1e1190e0 100644 --- a/api/src/main/java/me/lucko/luckperms/api/platform/PlatformType.java +++ b/api/src/main/java/me/lucko/luckperms/api/platform/PlatformType.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.api.platform; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Represents a type of platform which LuckPerms can run on. @@ -51,8 +51,7 @@ public enum PlatformType { * * @return a readable name */ - @Nonnull - public String getFriendlyName() { + public @NonNull String getFriendlyName() { return this.friendlyName; } } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/contexts/WorldCalculator.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/contexts/WorldCalculator.java index e7b76392..e03f7809 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/contexts/WorldCalculator.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/contexts/WorldCalculator.java @@ -32,8 +32,7 @@ import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import org.bukkit.entity.Player; - -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; public class WorldCalculator implements ContextCalculator { private final LuckPermsPlugin plugin; @@ -42,9 +41,8 @@ public class WorldCalculator implements ContextCalculator { this.plugin = plugin; } - @Nonnull @Override - public MutableContextSet giveApplicableContext(@Nonnull Player subject, @Nonnull MutableContextSet accumulator) { + public @NonNull MutableContextSet giveApplicableContext(@NonNull Player subject, @NonNull MutableContextSet accumulator) { String world = subject.getWorld().getName().toLowerCase(); while (!accumulator.has(Contexts.WORLD_KEY, world)) { accumulator.add(Contexts.WORLD_KEY, world); diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/messaging/BukkitMessagingFactory.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/messaging/BukkitMessagingFactory.java index 2631fa71..fc990f47 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/messaging/BukkitMessagingFactory.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/messaging/BukkitMessagingFactory.java @@ -33,7 +33,7 @@ import me.lucko.luckperms.common.messaging.InternalMessagingService; import me.lucko.luckperms.common.messaging.LuckPermsMessagingService; import me.lucko.luckperms.common.messaging.MessagingFactory; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; public class BukkitMessagingFactory extends MessagingFactory { public BukkitMessagingFactory(LPBukkitPlugin plugin) { @@ -65,15 +65,13 @@ public class BukkitMessagingFactory extends MessagingFactory { private class PluginMessageMessengerProvider implements MessengerProvider { - @Nonnull @Override - public String getName() { + public @NonNull String getName() { return "PluginMessage"; } - @Nonnull @Override - public Messenger obtain(@Nonnull IncomingMessageConsumer incomingMessageConsumer) { + public @NonNull Messenger obtain(@NonNull IncomingMessageConsumer incomingMessageConsumer) { PluginMessageMessenger messenger = new PluginMessageMessenger(getPlugin(), incomingMessageConsumer); messenger.init(); return messenger; @@ -82,15 +80,13 @@ public class BukkitMessagingFactory extends MessagingFactory { private class LilyPadMessengerProvider implements MessengerProvider { - @Nonnull @Override - public String getName() { + public @NonNull String getName() { return "LilyPad"; } - @Nonnull @Override - public Messenger obtain(@Nonnull IncomingMessageConsumer incomingMessageConsumer) { + public @NonNull Messenger obtain(@NonNull IncomingMessageConsumer incomingMessageConsumer) { LilyPadMessenger messenger = new LilyPadMessenger(getPlugin(), incomingMessageConsumer); messenger.init(); return messenger; diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/messaging/LilyPadMessenger.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/messaging/LilyPadMessenger.java index b2dd76e2..c0a11d2b 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/messaging/LilyPadMessenger.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/messaging/LilyPadMessenger.java @@ -30,6 +30,8 @@ import me.lucko.luckperms.api.messenger.Messenger; import me.lucko.luckperms.api.messenger.message.OutgoingMessage; import me.lucko.luckperms.bukkit.LPBukkitPlugin; +import org.checkerframework.checker.nullness.qual.NonNull; + import lilypad.client.connect.api.Connect; import lilypad.client.connect.api.event.EventListener; import lilypad.client.connect.api.event.MessageEvent; @@ -39,8 +41,6 @@ import lilypad.client.connect.api.request.impl.MessageRequest; import java.nio.charset.StandardCharsets; import java.util.Collections; -import javax.annotation.Nonnull; - /** * An implementation of {@link Messenger} using LilyPad. */ @@ -68,7 +68,7 @@ public class LilyPadMessenger implements Messenger { } @Override - public void sendOutgoingMessage(@Nonnull OutgoingMessage outgoingMessage) { + public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) { MessageRequest request = new MessageRequest(Collections.emptyList(), CHANNEL, outgoingMessage.asEncodedString().getBytes(StandardCharsets.UTF_8)); try { this.connect.request(request); diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/messaging/PluginMessageMessenger.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/messaging/PluginMessageMessenger.java index 225747ed..de454e20 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/messaging/PluginMessageMessenger.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/messaging/PluginMessageMessenger.java @@ -38,11 +38,10 @@ import me.lucko.luckperms.bukkit.LPBukkitPlugin; import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; import org.bukkit.scheduler.BukkitRunnable; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Collection; -import javax.annotation.Nonnull; - /** * An implementation of {@link Messenger} using the plugin messaging channels. */ @@ -69,7 +68,7 @@ public class PluginMessageMessenger implements Messenger, PluginMessageListener } @Override - public void sendOutgoingMessage(@Nonnull OutgoingMessage outgoingMessage) { + public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) { new BukkitRunnable() { @Override public void run() { diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/permissible/LPPermissible.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/permissible/LPPermissible.java index 80d49191..81abebe4 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/permissible/LPPermissible.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/permissible/LPPermissible.java @@ -41,6 +41,7 @@ import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionAttachment; import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.plugin.Plugin; +import org.checkerframework.checker.nullness.qual.NonNull; import java.lang.reflect.Field; import java.util.Collection; @@ -52,8 +53,6 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; -import javax.annotation.Nonnull; - /** * PermissibleBase for LuckPerms. * @@ -361,7 +360,7 @@ public class LPPermissible extends PermissibleBase { } @Override - public boolean addAll(@Nonnull Collection c) { + public boolean addAll(@NonNull Collection c) { boolean modified = false; for (PermissionAttachment e : c) { if (add(e)) { @@ -387,31 +386,31 @@ public class LPPermissible extends PermissibleBase { return ImmutableList.copyOf(LPPermissible.this.lpAttachments).listIterator(); } - @Nonnull @Override - public Object[] toArray() { + public @NonNull Object[] toArray() { return ImmutableList.copyOf(LPPermissible.this.lpAttachments).toArray(); } - @Nonnull @Override - public T[] toArray(@Nonnull T[] a) { + public @NonNull T[] toArray(@NonNull T[] a) { return ImmutableList.copyOf(LPPermissible.this.lpAttachments).toArray(a); } @Override public int size() { throw new UnsupportedOperationException(); } @Override public boolean isEmpty() { throw new UnsupportedOperationException(); } - @Override public boolean containsAll(@Nonnull Collection c) { throw new UnsupportedOperationException(); } - @Override public boolean addAll(int index, @Nonnull Collection c) { throw new UnsupportedOperationException(); } - @Override public boolean removeAll(@Nonnull Collection c) { throw new UnsupportedOperationException(); } - @Override public boolean retainAll(@Nonnull Collection c) { throw new UnsupportedOperationException(); } + @Override public boolean containsAll(@NonNull Collection c) { throw new UnsupportedOperationException(); } + @Override public boolean addAll(int index, @NonNull Collection c) { throw new UnsupportedOperationException(); } + @Override public boolean removeAll(@NonNull Collection c) { throw new UnsupportedOperationException(); } + @Override public boolean retainAll(@NonNull Collection c) { throw new UnsupportedOperationException(); } @Override public PermissionAttachment get(int index) { throw new UnsupportedOperationException(); } @Override public PermissionAttachment set(int index, PermissionAttachment element) { throw new UnsupportedOperationException(); } @Override public void add(int index, PermissionAttachment element) { throw new UnsupportedOperationException(); } @Override public PermissionAttachment remove(int index) { throw new UnsupportedOperationException(); } @Override public int indexOf(Object o) { throw new UnsupportedOperationException(); } @Override public int lastIndexOf(Object o) { throw new UnsupportedOperationException(); } - @Nonnull @Override public ListIterator listIterator(int index) { throw new UnsupportedOperationException(); } - @Nonnull @Override public List subList(int fromIndex, int toIndex) { throw new UnsupportedOperationException(); } + @Override + public @NonNull ListIterator listIterator(int index) { throw new UnsupportedOperationException(); } + @Override + public @NonNull List subList(int fromIndex, int toIndex) { throw new UnsupportedOperationException(); } } } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/server/LPDefaultsMap.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/server/LPDefaultsMap.java index 993f8571..e89b2def 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/server/LPDefaultsMap.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/server/LPDefaultsMap.java @@ -37,6 +37,7 @@ import me.lucko.luckperms.common.buffers.Cache; import org.bukkit.permissions.Permission; import org.bukkit.plugin.PluginManager; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Collection; import java.util.Collections; @@ -45,8 +46,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import javax.annotation.Nonnull; - /** * A replacement map for the 'defaultPerms' instance in Bukkit's SimplePluginManager. * @@ -68,8 +67,8 @@ public final class LPDefaultsMap implements Map> { private final Set nonOpSet = new DefaultPermissionSet(false); // fully resolved defaults (accounts for child permissions too) - private DefaultsCache opCache = new DefaultsCache(true); - private DefaultsCache nonOpCache = new DefaultsCache(false); + private final DefaultsCache opCache = new DefaultsCache(true); + private final DefaultsCache nonOpCache = new DefaultsCache(false); // #values and #entrySet results - both immutable private final Collection> values = ImmutableList.of(this.opSet, this.nonOpSet); @@ -111,9 +110,12 @@ public final class LPDefaultsMap implements Map> { } // return wrappers around this map impl - @Nonnull @Override public Collection> values() { return this.values; } - @Nonnull @Override public Set>> entrySet() { return this.entrySet; } - @Nonnull @Override public Set keySet() { return KEY_SET; } + @Override + public @NonNull Collection> values() { return this.values; } + @Override + public @NonNull Set>> entrySet() { return this.entrySet; } + @Override + public @NonNull Set keySet() { return KEY_SET; } // return accurate results for the Map spec @Override public int size() { return 2; } @@ -124,7 +126,7 @@ public final class LPDefaultsMap implements Map> { // throw unsupported operation exceptions @Override public Set put(Boolean key, Set value) { throw new UnsupportedOperationException(); } @Override public Set remove(Object key) { throw new UnsupportedOperationException(); } - @Override public void putAll(@Nonnull Map> m) { throw new UnsupportedOperationException(); } + @Override public void putAll(@NonNull Map> m) { throw new UnsupportedOperationException(); } @Override public void clear() { throw new UnsupportedOperationException(); } private final class DefaultsCache extends Cache> { @@ -134,9 +136,8 @@ public final class LPDefaultsMap implements Map> { this.op = op; } - @Nonnull @Override - protected Map supply() { + protected @NonNull Map supply() { Map builder = new HashMap<>(); for (Permission perm : LPDefaultsMap.this.get(this.op)) { String name = perm.getName().toLowerCase(); @@ -163,14 +164,14 @@ public final class LPDefaultsMap implements Map> { } @Override - public boolean add(@Nonnull Permission element) { + public boolean add(@NonNull Permission element) { boolean ret = super.add(element); invalidate(this.op); return ret; } @Override - public boolean addAll(@Nonnull Collection collection) { + public boolean addAll(@NonNull Collection collection) { boolean ret = super.addAll(collection); invalidate(this.op); return ret; diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/server/LPPermissionMap.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/server/LPPermissionMap.java index dc8dbd6a..d3f4bd7c 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/server/LPPermissionMap.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/server/LPPermissionMap.java @@ -36,6 +36,8 @@ import me.lucko.luckperms.common.treeview.PermissionRegistry; import org.bukkit.permissions.Permission; import org.bukkit.plugin.PluginManager; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Collections; import java.util.HashMap; @@ -43,10 +45,6 @@ import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - /** * A replacement map for the 'permissions' instance in Bukkit's SimplePluginManager. * @@ -95,7 +93,7 @@ public final class LPPermissionMap extends ForwardingMap { } @Override - public Permission put(@Nonnull String key, @Nonnull Permission value) { + public Permission put(@NonNull String key, @NonNull Permission value) { Objects.requireNonNull(key, "key"); Objects.requireNonNull(value, "value"); @@ -106,7 +104,7 @@ public final class LPPermissionMap extends ForwardingMap { } @Override - public void putAll(@Nonnull Map m) { + public void putAll(@NonNull Map m) { for (Map.Entry ent : m.entrySet()) { put(ent.getKey(), ent.getValue()); } @@ -163,9 +161,8 @@ public final class LPPermissionMap extends ForwardingMap { this.value = value; } - @CheckForNull @Override - public Map load(@Nonnull String key) { + public Map load(@NonNull String key) { Map children = new HashMap<>(); resolveChildren(children, Collections.singletonMap(key, this.value), false); children.remove(key, this.value); diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/server/LPSubscriptionMap.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/server/LPSubscriptionMap.java index 74d4f7cf..ecd9308a 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/server/LPSubscriptionMap.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/server/LPSubscriptionMap.java @@ -34,6 +34,7 @@ import me.lucko.luckperms.common.utils.ImmutableCollectors; import org.bukkit.entity.Player; import org.bukkit.permissions.Permissible; import org.bukkit.plugin.PluginManager; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Collection; import java.util.HashMap; @@ -43,8 +44,6 @@ import java.util.Set; import java.util.WeakHashMap; import java.util.stream.Collectors; -import javax.annotation.Nonnull; - /** * A replacement map for the 'permSubs' instance in Bukkit's SimplePluginManager. * @@ -217,9 +216,8 @@ public final class LPSubscriptionMap extends HashMap keySet() { + public @NonNull Set keySet() { // gather players (LPPermissibles) Set players = LPSubscriptionMap.this.plugin.getBootstrap().getServer().getOnlinePlayers().stream() .filter(player -> player.isPermissionSet(this.permission)) @@ -229,9 +227,8 @@ public final class LPSubscriptionMap extends HashMap> entrySet() { + public @NonNull Set> entrySet() { return keySet().stream() .map(p -> { Boolean ret = get(p); @@ -266,7 +263,7 @@ public final class LPSubscriptionMap extends HashMap m) { + public void putAll(@NonNull Map m) { this.backing.putAll(m); } @@ -275,9 +272,8 @@ public final class LPSubscriptionMap extends HashMap values() { + public @NonNull Collection values() { return this.backing.values(); } } diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/contexts/BackendServerCalculator.java b/bungee/src/main/java/me/lucko/luckperms/bungee/contexts/BackendServerCalculator.java index 95cba2d2..11a24d24 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/contexts/BackendServerCalculator.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/contexts/BackendServerCalculator.java @@ -33,7 +33,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import net.md_5.bungee.api.connection.ProxiedPlayer; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; public class BackendServerCalculator implements ContextCalculator { @@ -47,9 +47,8 @@ public class BackendServerCalculator implements ContextCalculator this.plugin = plugin; } - @Nonnull @Override - public MutableContextSet giveApplicableContext(@Nonnull ProxiedPlayer subject, @Nonnull MutableContextSet accumulator) { + public @NonNull MutableContextSet giveApplicableContext(@NonNull ProxiedPlayer subject, @NonNull MutableContextSet accumulator) { String server = getServer(subject); while (server != null && !accumulator.has(Contexts.WORLD_KEY, server)) { accumulator.add(Contexts.WORLD_KEY, server); diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/contexts/RedisBungeeCalculator.java b/bungee/src/main/java/me/lucko/luckperms/bungee/contexts/RedisBungeeCalculator.java index 30e239d3..04772eac 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/contexts/RedisBungeeCalculator.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/contexts/RedisBungeeCalculator.java @@ -31,14 +31,13 @@ import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.context.StaticContextCalculator; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; public class RedisBungeeCalculator implements StaticContextCalculator { private static final String PROXY_KEY = "proxy"; - @Nonnull @Override - public MutableContextSet giveApplicableContext(@Nonnull MutableContextSet accumulator) { + public @NonNull MutableContextSet giveApplicableContext(@NonNull MutableContextSet accumulator) { RedisBungeeAPI redisBungee = RedisBungee.getApi(); if (redisBungee != null) { accumulator.add(PROXY_KEY, redisBungee.getServerId()); diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/messaging/BungeeMessagingFactory.java b/bungee/src/main/java/me/lucko/luckperms/bungee/messaging/BungeeMessagingFactory.java index 311462a3..912c7a47 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/messaging/BungeeMessagingFactory.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/messaging/BungeeMessagingFactory.java @@ -33,7 +33,7 @@ import me.lucko.luckperms.common.messaging.InternalMessagingService; import me.lucko.luckperms.common.messaging.LuckPermsMessagingService; import me.lucko.luckperms.common.messaging.MessagingFactory; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; public class BungeeMessagingFactory extends MessagingFactory { public BungeeMessagingFactory(LPBungeePlugin plugin) { @@ -65,15 +65,13 @@ public class BungeeMessagingFactory extends MessagingFactory { private class PluginMessageMessengerProvider implements MessengerProvider { - @Nonnull @Override - public String getName() { + public @NonNull String getName() { return "PluginMessage"; } - @Nonnull @Override - public Messenger obtain(@Nonnull IncomingMessageConsumer incomingMessageConsumer) { + public @NonNull Messenger obtain(@NonNull IncomingMessageConsumer incomingMessageConsumer) { PluginMessageMessenger messenger = new PluginMessageMessenger(getPlugin(), incomingMessageConsumer); messenger.init(); return messenger; @@ -82,15 +80,13 @@ public class BungeeMessagingFactory extends MessagingFactory { private class RedisBungeeMessengerProvider implements MessengerProvider { - @Nonnull @Override - public String getName() { + public @NonNull String getName() { return "RedisBungee"; } - @Nonnull @Override - public Messenger obtain(@Nonnull IncomingMessageConsumer incomingMessageConsumer) { + public @NonNull Messenger obtain(@NonNull IncomingMessageConsumer incomingMessageConsumer) { RedisBungeeMessenger messenger = new RedisBungeeMessenger(getPlugin(), incomingMessageConsumer); messenger.init(); return messenger; diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/messaging/PluginMessageMessenger.java b/bungee/src/main/java/me/lucko/luckperms/bungee/messaging/PluginMessageMessenger.java index 4a68fff8..d55ce1db 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/messaging/PluginMessageMessenger.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/messaging/PluginMessageMessenger.java @@ -40,7 +40,7 @@ import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.event.EventHandler; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * An implementation of {@link Messenger} using the plugin messaging channels. @@ -67,7 +67,7 @@ public class PluginMessageMessenger implements Messenger, Listener { } @Override - public void sendOutgoingMessage(@Nonnull OutgoingMessage outgoingMessage) { + public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF(outgoingMessage.asEncodedString()); diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/messaging/RedisBungeeMessenger.java b/bungee/src/main/java/me/lucko/luckperms/bungee/messaging/RedisBungeeMessenger.java index 8d19d4fb..18872b6e 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/messaging/RedisBungeeMessenger.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/messaging/RedisBungeeMessenger.java @@ -37,7 +37,7 @@ import me.lucko.luckperms.bungee.LPBungeePlugin; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.event.EventHandler; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * An implementation of {@link Messenger} using Redis, via RedisBungee's API. @@ -70,7 +70,7 @@ public class RedisBungeeMessenger implements Messenger, Listener { } @Override - public void sendOutgoingMessage(@Nonnull OutgoingMessage outgoingMessage) { + public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) { this.redisBungee.sendChannelMessage(CHANNEL, outgoingMessage.asEncodedString()); } diff --git a/common/build.gradle b/common/build.gradle index 63414cb3..fe9e73d2 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,7 +1,7 @@ dependencies { compile project(':api') - compile 'com.google.code.findbugs:jsr305:3.0.2' + compile 'org.checkerframework:checker-qual:2.5.5' compile('net.kyori:text:1.11-1.6.4') { exclude(module: 'checker-qual') exclude(module: 'guava') diff --git a/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java b/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java index a16a9c55..db0cfcf9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java +++ b/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java @@ -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 getActed() { + public @NonNull Optional 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); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/DemotionResults.java b/common/src/main/java/me/lucko/luckperms/common/api/DemotionResults.java index 95420718..d89be017 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/DemotionResults.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/DemotionResults.java @@ -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 getGroupFrom() { + public @NonNull Optional getGroupFrom() { return Optional.ofNullable(this.groupFrom); } - @Nonnull @Override - public Optional getGroupTo() { + public @NonNull Optional getGroupTo() { return Optional.ofNullable(this.groupTo); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/LuckPermsApiProvider.java b/common/src/main/java/me/lucko/luckperms/common/api/LuckPermsApiProvider.java index 1d694092..91fab3ec 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/LuckPermsApiProvider.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/LuckPermsApiProvider.java @@ -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 runUpdateTask() { + public @NonNull CompletableFuture 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 getMessagingService() { + public @NonNull Optional 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; } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/PromotionResults.java b/common/src/main/java/me/lucko/luckperms/common/api/PromotionResults.java index 39474dda..59813607 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/PromotionResults.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/PromotionResults.java @@ -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 getGroupFrom() { + public @NonNull Optional getGroupFrom() { return Optional.ofNullable(this.groupFrom); } - @Nonnull @Override - public Optional getGroupTo() { + public @NonNull Optional getGroupTo() { return Optional.ofNullable(this.groupTo); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiContextManager.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiContextManager.java index 59f7b7bd..b5267f4f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiContextManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiContextManager.java @@ -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 lookupApplicableContext(@Nonnull User user) { + public @NonNull Optional lookupApplicableContext(@NonNull User user) { Objects.requireNonNull(user, "user"); return this.plugin.getContextForUser(ApiUser.cast(user)).map(c -> c.getContexts().makeImmutable()); } - @Nonnull @Override - public Optional lookupApplicableContexts(@Nonnull User user) { + public @NonNull Optional 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)); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiGroupManager.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiGroupManager.java index c8b8e16b..eb456256 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiGroupManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiGroupManager.java @@ -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> 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 createAndLoadGroup(@Nonnull String name) { + public @NonNull CompletableFuture 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> loadGroup(@Nonnull String name) { + public @NonNull CompletableFuture> 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 saveGroup(@Nonnull me.lucko.luckperms.api.Group group) { + public @NonNull CompletableFuture saveGroup(me.lucko.luckperms.api.@NonNull Group group) { Objects.requireNonNull(group, "group"); return this.plugin.getStorage().saveGroup(ApiGroup.cast(group)); } - @Nonnull @Override - public CompletableFuture deleteGroup(@Nonnull me.lucko.luckperms.api.Group group) { + public @NonNull CompletableFuture 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 loadAllGroups() { + public @NonNull CompletableFuture loadAllGroups() { return this.plugin.getStorage().loadAllGroups(); } - @Nonnull @Override - public CompletableFuture>> getWithPermission(@Nonnull String permission) { + public @NonNull CompletableFuture>> 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 getLoadedGroups() { + public @NonNull Set 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); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiTrackManager.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiTrackManager.java index 8fcdf6b7..9b67e6e1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiTrackManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiTrackManager.java @@ -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> 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 createAndLoadTrack(@Nonnull String name) { + public @NonNull CompletableFuture 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> loadTrack(@Nonnull String name) { + public @NonNull CompletableFuture> 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 saveTrack(@Nonnull me.lucko.luckperms.api.Track track) { + public @NonNull CompletableFuture saveTrack(me.lucko.luckperms.api.@NonNull Track track) { Objects.requireNonNull(track, "track"); return this.plugin.getStorage().saveTrack(ApiTrack.cast(track)); } - @Nonnull @Override - public CompletableFuture deleteTrack(@Nonnull me.lucko.luckperms.api.Track track) { + public @NonNull CompletableFuture 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 loadAllTracks() { + public @NonNull CompletableFuture 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 getLoadedTracks() { + public @NonNull Set 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); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiUserManager.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiUserManager.java index de66e873..61ad45e2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiUserManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/manager/ApiUserManager.java @@ -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> 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 loadUser(@Nonnull UUID uuid, @Nullable String username) { + public @NonNull CompletableFuture loadUser(@NonNull UUID uuid, @Nullable String username) { Objects.requireNonNull(uuid, "uuid"); ApiUtils.checkUsername(username); @@ -73,76 +72,69 @@ public class ApiUserManager extends ApiAbstractManager lookupUuid(@Nonnull String username) { + public @NonNull CompletableFuture lookupUuid(@NonNull String username) { Objects.requireNonNull(username, "username"); return this.plugin.getStorage().getPlayerUuid(username); } - @Nonnull @Override - public CompletableFuture lookupUsername(@Nonnull UUID uuid) { + public @NonNull CompletableFuture lookupUsername(@NonNull UUID uuid) { Objects.requireNonNull(uuid, "uuid"); return this.plugin.getStorage().getPlayerName(uuid); } - @Nonnull @Override - public CompletableFuture saveUser(@Nonnull me.lucko.luckperms.api.User user) { + public @NonNull CompletableFuture saveUser(me.lucko.luckperms.api.@NonNull User user) { Objects.requireNonNull(user, "user"); return this.plugin.getStorage().saveUser(ApiUser.cast(user)); } - @Nonnull @Override - public CompletableFuture savePlayerData(@Nonnull UUID uuid, @Nonnull String username) { + public @NonNull CompletableFuture 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> getUniqueUsers() { + public @NonNull CompletableFuture> getUniqueUsers() { return this.plugin.getStorage().getUniqueUsers(); } - @Nonnull @Override - public CompletableFuture>> getWithPermission(@Nonnull String permission) { + public @NonNull CompletableFuture>> 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 getLoadedUsers() { + public @NonNull Set 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()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiActionLogger.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiActionLogger.java index a8d45ee4..b69ea22a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiActionLogger.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiActionLogger.java @@ -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 getLog() { + public @NonNull CompletableFuture getLog() { return this.plugin.getStorage().getLog().thenApply(ApiLog::new); } - @Nonnull @Override - public CompletableFuture submit(@Nonnull LogEntry entry) { + public @NonNull CompletableFuture submit(@NonNull LogEntry entry) { return CompletableFuture.runAsync(() -> this.plugin.getLogDispatcher().dispatchFromApi((ExtendedLogEntry) entry), this.plugin.getBootstrap().getScheduler().async()); } - @Nonnull @Override - public CompletableFuture submitToStorage(@Nonnull LogEntry entry) { + public @NonNull CompletableFuture submitToStorage(@NonNull LogEntry entry) { return this.plugin.getStorage().logAction(entry); } - @Nonnull @Override - public CompletableFuture broadcastAction(@Nonnull LogEntry entry) { + public @NonNull CompletableFuture broadcastAction(@NonNull LogEntry entry) { return CompletableFuture.runAsync(() -> this.plugin.getLogDispatcher().broadcastFromApi((ExtendedLogEntry) entry), this.plugin.getBootstrap().getScheduler().async()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiConfiguration.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiConfiguration.java index 6eb4e597..3f7bd4c2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiConfiguration.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiConfiguration.java @@ -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 getSplitStorageOptions() { + public @NonNull Map 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); diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiMessagingService.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiMessagingService.java index f64f5cee..0246482a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiMessagingService.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiMessagingService.java @@ -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)); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiMetaStackFactory.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiMetaStackFactory.java index 0bb37d4d..c72e47fd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiMetaStackFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiMetaStackFactory.java @@ -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 fromString(@Nonnull String definition) { + public @NonNull Optional fromString(@NonNull String definition) { Objects.requireNonNull(definition, "definition"); return Optional.ofNullable(StandardStackElements.parseFromString(this.plugin, definition)); } - @Nonnull @Override - public List fromStrings(@Nonnull List definitions) { + public @NonNull List fromStrings(@NonNull List 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 elements, @Nonnull String startSpacer, @Nonnull String middleSpacer, @Nonnull String endSpacer) { + public @NonNull MetaStackDefinition createDefinition(@NonNull List elements, @NonNull String startSpacer, @NonNull String middleSpacer, @NonNull String endSpacer) { return new SimpleMetaStackDefinition(elements, startSpacer, middleSpacer, endSpacer); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiNodeFactory.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiNodeFactory.java index 266804df..a48ae79c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiNodeFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiNodeFactory.java @@ -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); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiPlatformInfo.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiPlatformInfo.java index 1fc55224..eed31a10 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiPlatformInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiPlatformInfo.java @@ -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 getUniqueConnections() { + public @NonNull Set getUniqueConnections() { return Collections.unmodifiableSet(this.plugin.getConnectionListener().getUniqueConnections()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/NoopUuidCache.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/NoopUuidCache.java index a00bfd1d..35ca7c4e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/NoopUuidCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/NoopUuidCache.java @@ -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; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiGroup.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiGroup.java index d468d350..bc79596e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiGroup.java @@ -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(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiLog.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiLog.java index 75d59954..4e7feb6d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiLog.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiLog.java @@ -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 getContent() { + public @NonNull SortedSet getContent() { return (SortedSet) this.handle.getContent(); } - @Nonnull @Override - public SortedSet getContent(@Nonnull UUID actor) { + public @NonNull SortedSet getContent(@NonNull UUID actor) { Objects.requireNonNull(actor, "actor"); return (SortedSet) this.handle.getContent(actor); } - @Nonnull @Override - public SortedSet getUserHistory(@Nonnull UUID uuid) { + public @NonNull SortedSet getUserHistory(@NonNull UUID uuid) { Objects.requireNonNull(uuid, "uuid"); return (SortedSet) this.handle.getUserHistory(uuid); } - @Nonnull @Override - public SortedSet getGroupHistory(@Nonnull String name) { + public @NonNull SortedSet getGroupHistory(@NonNull String name) { Objects.requireNonNull(name, "name"); return (SortedSet) this.handle.getGroupHistory(checkName(name)); } - @Nonnull @Override - public SortedSet getTrackHistory(@Nonnull String name) { + public @NonNull SortedSet getTrackHistory(@NonNull String name) { Objects.requireNonNull(name, "name"); return (SortedSet) this.handle.getTrackHistory(checkName(name)); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiPermissionHolder.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiPermissionHolder.java index 6aebabe2..0c03e55e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiPermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiPermissionHolder.java @@ -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 refreshCachedData() { + public @NonNull CompletableFuture refreshCachedData() { return CompletableFuture.runAsync(() -> this.handle.getCachedData().invalidate()); } - @Nonnull @Override - public ImmutableSetMultimap getNodes() { + public @NonNull ImmutableSetMultimap getNodes() { //noinspection unchecked return (ImmutableSetMultimap) this.handle.enduringData().immutable(); } - @Nonnull @Override - public ImmutableSetMultimap getTransientNodes() { + public @NonNull ImmutableSetMultimap getTransientNodes() { //noinspection unchecked return (ImmutableSetMultimap) this.handle.transientData().immutable(); } - @Nonnull @Override - public List getOwnNodes() { + public @NonNull List getOwnNodes() { return ImmutableList.copyOf(this.handle.getOwnNodes()); } - @Nonnull @Override - public SortedSet getPermissions() { + public @NonNull SortedSet getPermissions() { return ImmutableSortedSet.copyOfSorted(this.handle.getOwnNodesSorted()); } - @Nonnull @Override - public Set getEnduringPermissions() { + public @NonNull Set getEnduringPermissions() { return ImmutableSet.copyOf(this.handle.enduringData().immutable().values()); } - @Nonnull @Override - public Set getTransientPermissions() { + public @NonNull Set getTransientPermissions() { return ImmutableSet.copyOf(this.handle.transientData().immutable().values()); } - @Nonnull @Override - public SortedSet getAllNodes(@Nonnull Contexts contexts) { + public @NonNull SortedSet getAllNodes(@NonNull Contexts contexts) { Objects.requireNonNull(contexts, "contexts"); List nodes = new LinkedList<>(); @@ -153,9 +142,8 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol return ImmutableSortedSet.copyOfSorted(ret); } - @Nonnull @Override - public SortedSet getAllNodes() { + public @NonNull SortedSet getAllNodes() { List 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 getAllNodesFiltered(@Nonnull Contexts contexts) { + public @NonNull Set getAllNodesFiltered(@NonNull Contexts contexts) { Objects.requireNonNull(contexts, "contexts"); List 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 exportNodes(@Nonnull Contexts contexts, boolean lowerCase) { + public @NonNull Map 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 test) { + public void clearMatching(@NonNull Predicate 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 test) { + public void clearMatchingTransient(@NonNull Predicate 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 resolveInheritances(@Nonnull Contexts contexts) { + public @NonNull List resolveInheritances(@NonNull Contexts contexts) { Objects.requireNonNull(contexts, "contexts"); return ImmutableList.copyOf(this.handle.resolveInheritances(contexts)); } - @Nonnull @Override - public List resolveInheritances() { + public @NonNull List resolveInheritances() { return ImmutableList.copyOf(this.handle.resolveInheritances()); } - @Nonnull @Override - public Set getPermanentPermissionNodes() { + public @NonNull Set getPermanentPermissionNodes() { return this.handle.getOwnNodes().stream().filter(Node::isPermanent).collect(ImmutableCollectors.toSet()); } - @Nonnull @Override - public Set getTemporaryPermissionNodes() { + public @NonNull Set getTemporaryPermissionNodes() { return this.handle.getOwnNodes().stream().filter(Node::isPrefix).collect(ImmutableCollectors.toSet()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiStorage.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiStorage.java index 23524810..6b31fb98 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiStorage.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiStorage.java @@ -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 logAction(@Nonnull LogEntry entry) { + public @NonNull CompletableFuture logAction(@NonNull LogEntry entry) { Objects.requireNonNull(entry, "entry"); return this.handle.logAction(entry) .thenApply(r -> true) .exceptionally(consumeExceptionToFalse()); } - @Nonnull @Override - public CompletableFuture getLog() { + public @NonNull CompletableFuture getLog() { return this.handle.getLog().thenApply(ApiLog::new).exceptionally(consumeExceptionToNull()); } - @Nonnull @Override - public CompletableFuture loadUser(@Nonnull UUID uuid, String username) { + public @NonNull CompletableFuture 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 saveUser(@Nonnull User user) { + public @NonNull CompletableFuture saveUser(@NonNull User user) { Objects.requireNonNull(user, "user"); return this.handle.saveUser(ApiUser.cast(user)) .thenApply(r -> true) .exceptionally(consumeExceptionToFalse()); } - @Nonnull @Override - public CompletableFuture> getUniqueUsers() { + public @NonNull CompletableFuture> getUniqueUsers() { return this.handle.getUniqueUsers().exceptionally(consumeExceptionToNull()); } - @Nonnull @Override - public CompletableFuture>> getUsersWithPermission(@Nonnull String permission) { + public @NonNull CompletableFuture>> getUsersWithPermission(@NonNull String permission) { Objects.requireNonNull(permission, "permission"); return this.handle.getUsersWithPermission(Constraint.of(StandardComparison.EQUAL, permission)).exceptionally(consumeExceptionToNull()); } - @Nonnull @Override - public CompletableFuture createAndLoadGroup(@Nonnull String name) { + public @NonNull CompletableFuture 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 loadGroup(@Nonnull String name) { + public @NonNull CompletableFuture loadGroup(@NonNull String name) { Objects.requireNonNull(name, "name"); return this.handle.loadGroup(checkName(name)) .thenApply(Optional::isPresent) .exceptionally(consumeExceptionToFalse()); } - @Nonnull @Override - public CompletableFuture loadAllGroups() { + public @NonNull CompletableFuture loadAllGroups() { return this.handle.loadAllGroups() .thenApply(r -> true) .exceptionally(consumeExceptionToFalse()); } - @Nonnull @Override - public CompletableFuture saveGroup(@Nonnull Group group) { + public @NonNull CompletableFuture saveGroup(@NonNull Group group) { Objects.requireNonNull(group, "group"); return this.handle.saveGroup(ApiGroup.cast(group)) .thenApply(r -> true) .exceptionally(consumeExceptionToFalse()); } - @Nonnull @Override - public CompletableFuture deleteGroup(@Nonnull Group group) { + public @NonNull CompletableFuture 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>> getGroupsWithPermission(@Nonnull String permission) { + public @NonNull CompletableFuture>> getGroupsWithPermission(@NonNull String permission) { Objects.requireNonNull(permission, "permission"); return this.handle.getGroupsWithPermission(Constraint.of(StandardComparison.EQUAL, permission)).exceptionally(consumeExceptionToNull()); } - @Nonnull @Override - public CompletableFuture createAndLoadTrack(@Nonnull String name) { + public @NonNull CompletableFuture 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 loadTrack(@Nonnull String name) { + public @NonNull CompletableFuture loadTrack(@NonNull String name) { Objects.requireNonNull(name, "name"); return this.handle.loadTrack(checkName(name)) .thenApply(Optional::isPresent) .exceptionally(consumeExceptionToFalse()); } - @Nonnull @Override - public CompletableFuture loadAllTracks() { + public @NonNull CompletableFuture loadAllTracks() { return this.handle.loadAllTracks() .thenApply(r -> true) .exceptionally(consumeExceptionToFalse()); } - @Nonnull @Override - public CompletableFuture saveTrack(@Nonnull Track track) { + public @NonNull CompletableFuture saveTrack(@NonNull Track track) { Objects.requireNonNull(track, "track"); return this.handle.saveTrack(ApiTrack.cast(track)) .thenApply(r -> true) .exceptionally(consumeExceptionToFalse()); } - @Nonnull @Override - public CompletableFuture deleteTrack(@Nonnull Track track) { + public @NonNull CompletableFuture 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 saveUUIDData(@Nonnull String username, @Nonnull UUID uuid) { + public @NonNull CompletableFuture 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 getUUID(@Nonnull String username) { + public @NonNull CompletableFuture getUUID(@NonNull String username) { Objects.requireNonNull(username, "username"); return this.handle.getPlayerUuid(checkUsername(username)); } - @Nonnull @Override - public CompletableFuture getName(@Nonnull UUID uuid) { + public @NonNull CompletableFuture getName(@NonNull UUID uuid) { Objects.requireNonNull(uuid, "uuid"); return this.handle.getPlayerName(uuid); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiTrack.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiTrack.java index bc996e48..cbc99f14 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiTrack.java @@ -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 getGroups() { + public @NonNull List 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); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiUser.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiUser.java index 42164f22..32585861 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiUser.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/model/ApiUser.java @@ -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(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/buffers/BufferedRequest.java b/common/src/main/java/me/lucko/luckperms/common/buffers/BufferedRequest.java index abe30cbe..2e95da8c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/buffers/BufferedRequest.java +++ b/common/src/main/java/me/lucko/luckperms/common/buffers/BufferedRequest.java @@ -107,7 +107,7 @@ public abstract class BufferedRequest { 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]; diff --git a/common/src/main/java/me/lucko/luckperms/common/buffers/Cache.java b/common/src/main/java/me/lucko/luckperms/common/buffers/Cache.java index 0ed2464f..2121802a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/buffers/Cache.java +++ b/common/src/main/java/me/lucko/luckperms/common/buffers/Cache.java @@ -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 { private volatile T value = null; - @Nonnull - protected abstract T supply(); + protected abstract @NonNull T supply(); public final T get() { T val = this.value; diff --git a/common/src/main/java/me/lucko/luckperms/common/buffers/ExpiringCache.java b/common/src/main/java/me/lucko/luckperms/common/buffers/ExpiringCache.java index 751fe0e0..b5f296f9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/buffers/ExpiringCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/buffers/ExpiringCache.java @@ -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 implements Supplier { this.durationNanos = unit.toNanos(duration); } - @Nonnull - protected abstract T supply(); + protected abstract @NonNull T supply(); @Override public T get() { diff --git a/common/src/main/java/me/lucko/luckperms/common/bulkupdate/BulkUpdate.java b/common/src/main/java/me/lucko/luckperms/common/bulkupdate/BulkUpdate.java index 1e49b9fe..a6b24e3b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/bulkupdate/BulkUpdate.java +++ b/common/src/main/java/me/lucko/luckperms/common/bulkupdate/BulkUpdate.java @@ -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()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/bulkupdate/action/Action.java b/common/src/main/java/me/lucko/luckperms/common/bulkupdate/action/Action.java index 9f80fa7d..e34d7b5a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/bulkupdate/action/Action.java +++ b/common/src/main/java/me/lucko/luckperms/common/bulkupdate/action/Action.java @@ -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); diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/AbstractCachedData.java b/common/src/main/java/me/lucko/luckperms/common/caching/AbstractCachedData.java index 1038bd0a..d11efa57 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/AbstractCachedData.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/AbstractCachedData.java @@ -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 reloadPermissions(@Nonnull Contexts contexts) { + public final @NonNull CompletableFuture 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 reloadMeta(@Nonnull MetaContexts contexts) { + public final @NonNull CompletableFuture 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 reloadMeta(@Nonnull Contexts contexts) { + public final @NonNull CompletableFuture 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 reloadPermissions() { + public final @NonNull CompletableFuture reloadPermissions() { Set keys = this.permission.synchronous().asMap().keySet(); return CompletableFuture.allOf(keys.stream().map(this::reloadPermissions).toArray(CompletableFuture[]::new)); } - @Nonnull @Override - public final CompletableFuture reloadMeta() { + public final @NonNull CompletableFuture reloadMeta() { Set 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 { @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 { @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); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/type/MetaCache.java b/common/src/main/java/me/lucko/luckperms/common/caching/type/MetaCache.java index 7479123e..1c30f164 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/type/MetaCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/type/MetaCache.java @@ -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 getMetaMultimap() { + public @NonNull ListMultimap getMetaMultimap() { return this.metaMultimap; } - @Nonnull @Override - public Map getMeta() { + public @NonNull Map getMeta() { return this.meta; } - @Nonnull @Override - public SortedMap getPrefixes() { + public @NonNull SortedMap getPrefixes() { return this.prefixes; } - @Nonnull @Override - public SortedMap getSuffixes() { + public @NonNull SortedMap getSuffixes() { return this.suffixes; } diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/type/PermissionCache.java b/common/src/main/java/me/lucko/luckperms/common/caching/type/PermissionCache.java index 1603a08c..0c6f6c43 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/type/PermissionCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/type/PermissionCache.java @@ -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 getImmutableBacking() { + public @NonNull Map 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; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/calculators/PermissionCalculator.java b/common/src/main/java/me/lucko/luckperms/common/calculators/PermissionCalculator.java index 6cf72346..b10d3275 100644 --- a/common/src/main/java/me/lucko/luckperms/common/calculators/PermissionCalculator.java +++ b/common/src/main/java/me/lucko/luckperms/common/calculators/PermissionCalculator.java @@ -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 { } @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. diff --git a/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java b/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java index 1d47072d..e19f4609 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java @@ -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 groups = plugin.getGroupManager().getAll().values(); + Collection 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 { diff --git a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/Command.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/Command.java index 182b67d9..349078e9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/Command.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/Command.java @@ -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 { * * 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 argumentCheck = Predicates.alwaysFalse(); + private final @NonNull Predicate argumentCheck; /** * Child commands. Nullable. */ - @Nullable - private final List> children; + private final @Nullable List> children; - public Command(@Nonnull LocalizedCommandSpec spec, @Nonnull String name, @Nullable CommandPermission permission, @Nonnull Predicate argumentCheck, @Nullable List> children) { + public Command(@NonNull LocalizedCommandSpec spec, @NonNull String name, @Nullable CommandPermission permission, @NonNull Predicate argumentCheck, @Nullable List> children) { this.spec = spec; this.name = name; this.permission = permission; @@ -91,11 +86,11 @@ public abstract class Command { this.children = children == null ? null : ImmutableList.copyOf(children); } - public Command(@Nonnull LocalizedCommandSpec spec, @Nonnull String name, @Nullable CommandPermission permission, @Nonnull Predicate argumentCheck) { + public Command(@NonNull LocalizedCommandSpec spec, @NonNull String name, @Nullable CommandPermission permission, @NonNull Predicate argumentCheck) { this(spec, name, permission, argumentCheck, null); } - public Command(@Nonnull LocalizedCommandSpec spec, @Nonnull String name, @Nonnull Predicate argumentCheck) { + public Command(@NonNull LocalizedCommandSpec spec, @NonNull String name, @NonNull Predicate argumentCheck) { this(spec, name, null, argumentCheck, null); } @@ -104,8 +99,7 @@ public abstract class Command { * * @return the command spec */ - @Nonnull - public LocalizedCommandSpec getSpec() { + public @NonNull LocalizedCommandSpec getSpec() { return this.spec; } @@ -116,8 +110,7 @@ public abstract class Command { * * @return the command name */ - @Nonnull - public String getName() { + public @NonNull String getName() { return this.name; } @@ -126,8 +119,7 @@ public abstract class Command { * * @return the command permission */ - @Nonnull - public Optional getPermission() { + public @NonNull Optional getPermission() { return Optional.ofNullable(this.permission); } @@ -137,8 +129,7 @@ public abstract class Command { * * @return the argument checking predicate */ - @Nonnull - public Predicate getArgumentCheck() { + public @NonNull Predicate getArgumentCheck() { return this.argumentCheck; } @@ -147,8 +138,7 @@ public abstract class Command { * * @return any child commands */ - @Nonnull - public Optional>> getChildren() { + public @NonNull Optional>> getChildren() { return Optional.ofNullable(this.children); } diff --git a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/MainCommand.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/MainCommand.java index 04c0e17d..8ea3694e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/MainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/MainCommand.java @@ -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 extends Command { // 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 extends Command { return getChildren().get().stream().anyMatch(sc -> sc.isAuthorized(sender)); } - @Nonnull @Override - public Optional>> getChildren() { + public @NonNull Optional>> getChildren() { return super.getChildren(); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/command/tabcomplete/TabCompleter.java b/common/src/main/java/me/lucko/luckperms/common/command/tabcomplete/TabCompleter.java index 2aca683f..161224dd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/tabcomplete/TabCompleter.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/tabcomplete/TabCompleter.java @@ -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; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationMainCommand.java index e566f644..1579ec73 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationMainCommand.java @@ -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 { private static final Map PLUGINS = ImmutableBiMap.builder() // bukkit @@ -68,9 +68,8 @@ public class MigrationMainCommand extends MainCommand { super(CommandSpec.MIGRATION.localize(locale), "Migration", 1, null); } - @Nonnull @Override - public synchronized Optional>> getChildren() { + public synchronized @NonNull Optional>> getChildren() { if (this.commands == null) { this.commands = getAvailableCommands(getSpec().getLocaleManager()); diff --git a/common/src/main/java/me/lucko/luckperms/common/contexts/ContextManager.java b/common/src/main/java/me/lucko/luckperms/common/contexts/ContextManager.java index e83ed8d9..e5a213ab 100644 --- a/common/src/main/java/me/lucko/luckperms/common/contexts/ContextManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/contexts/ContextManager.java @@ -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 { super(50L, TimeUnit.MILLISECONDS); } - @Nonnull @Override - public Contexts supply() { + public @NonNull Contexts supply() { return calculateStatic(); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/contexts/ContextsCache.java b/common/src/main/java/me/lucko/luckperms/common/contexts/ContextsCache.java index c8f5914f..4b1642c8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/contexts/ContextsCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/contexts/ContextsCache.java @@ -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 extends ExpiringCache implements C this.contextManager = contextManager; } - @Nonnull @Override - protected Contexts supply() { + protected @NonNull Contexts supply() { return this.contextManager.calculate(this.subject); } diff --git a/common/src/main/java/me/lucko/luckperms/common/contexts/LPStaticContextsCalculator.java b/common/src/main/java/me/lucko/luckperms/common/contexts/LPStaticContextsCalculator.java index 614545ab..b0cf26e4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/contexts/LPStaticContextsCalculator.java +++ b/common/src/main/java/me/lucko/luckperms/common/contexts/LPStaticContextsCalculator.java @@ -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); diff --git a/common/src/main/java/me/lucko/luckperms/common/event/AbstractEventBus.java b/common/src/main/java/me/lucko/luckperms/common/event/AbstractEventBus.java index 2593c9d3..fc20f62f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/AbstractEventBus.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/AbstractEventBus.java @@ -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

implements EventBus, AutoCloseable { /** @@ -88,17 +88,15 @@ public abstract class AbstractEventBus

implements EventBus, AutoCloseable { return this.bus.hasSubscribers(eventClass); } - @Nonnull @Override - public EventHandler subscribe(@Nonnull Class eventClass, @Nonnull Consumer handler) { + public @NonNull EventHandler subscribe(@NonNull Class eventClass, @NonNull Consumer handler) { Objects.requireNonNull(eventClass, "eventClass"); Objects.requireNonNull(handler, "handler"); return registerSubscription(eventClass, handler, null); } - @Nonnull @Override - public EventHandler subscribe(Object plugin, @Nonnull Class eventClass, @Nonnull Consumer handler) { + public @NonNull EventHandler subscribe(Object plugin, @NonNull Class eventClass, @NonNull Consumer handler) { Objects.requireNonNull(plugin, "plugin"); Objects.requireNonNull(eventClass, "eventClass"); Objects.requireNonNull(handler, "handler"); @@ -119,9 +117,8 @@ public abstract class AbstractEventBus

implements EventBus, AutoCloseable { return eventHandler; } - @Nonnull @Override - public Set> getHandlers(@Nonnull Class eventClass) { + public @NonNull Set> getHandlers(@NonNull Class eventClass) { return this.bus.getHandlers(eventClass); } @@ -154,7 +151,7 @@ public abstract class AbstractEventBus

implements EventBus, AutoCloseable { } @Override - protected boolean shouldPost(LuckPermsEvent event, EventSubscriber subscriber) { + protected boolean shouldPost(@NonNull LuckPermsEvent event, @NonNull EventSubscriber subscriber) { return true; } diff --git a/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java b/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java index 77b40b41..0b61e5eb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java @@ -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; diff --git a/common/src/main/java/me/lucko/luckperms/common/event/LuckPermsEventHandler.java b/common/src/main/java/me/lucko/luckperms/common/event/LuckPermsEventHandler.java index 656be80c..043a867f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/LuckPermsEventHandler.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/LuckPermsEventHandler.java @@ -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 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 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 implements EventHan } } - @Nonnull @Override - public Class getEventClass() { + public @NonNull Class getEventClass() { return this.eventClass; } - @Nonnull @Override - public Consumer getConsumer() { + public @NonNull Consumer getConsumer() { return this.consumer; } - @Nullable - public Object getPlugin() { + public @Nullable Object getPlugin() { return this.plugin; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/event/model/EntitySourceImpl.java b/common/src/main/java/me/lucko/luckperms/common/event/model/EntitySourceImpl.java index 684dce43..5c63b229 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/model/EntitySourceImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/model/EntitySourceImpl.java @@ -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; } diff --git a/common/src/main/java/me/lucko/luckperms/common/event/model/SenderEntity.java b/common/src/main/java/me/lucko/luckperms/common/event/model/SenderEntity.java index ce923559..12e82603 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/model/SenderEntity.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/model/SenderEntity.java @@ -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 { diff --git a/common/src/main/java/me/lucko/luckperms/common/event/model/UnknownSource.java b/common/src/main/java/me/lucko/luckperms/common/event/model/UnknownSource.java index e6d84bfa..46617ede 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/model/UnknownSource.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/model/UnknownSource.java @@ -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; } diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/command/Argument.java b/common/src/main/java/me/lucko/luckperms/common/locale/command/Argument.java index 16b4701f..75765c05 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/command/Argument.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/command/Argument.java @@ -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) { diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpecData.java b/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpecData.java index fc57333d..c44ab27c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpecData.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpecData.java @@ -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 getArgs() { + public @Nullable Map getArgs() { return this.args; } diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java index dccc6da9..1913d86f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java @@ -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. diff --git a/common/src/main/java/me/lucko/luckperms/common/managers/AbstractManager.java b/common/src/main/java/me/lucko/luckperms/common/managers/AbstractManager.java index 24acef9d..9dc3a4ad 100644 --- a/common/src/main/java/me/lucko/luckperms/common/managers/AbstractManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/managers/AbstractManager.java @@ -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, T extends C> private final LoadingCache objects = Caffeine.newBuilder() .build(new CacheLoader() { @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. } }); diff --git a/common/src/main/java/me/lucko/luckperms/common/messaging/LuckPermsMessagingService.java b/common/src/main/java/me/lucko/luckperms/common/messaging/LuckPermsMessagingService.java index 8df1f5fb..da6c89f0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/messaging/LuckPermsMessagingService.java +++ b/common/src/main/java/me/lucko/luckperms/common/messaging/LuckPermsMessagingService.java @@ -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(); diff --git a/common/src/main/java/me/lucko/luckperms/common/messaging/MessagingFactory.java b/common/src/main/java/me/lucko/luckperms/common/messaging/MessagingFactory.java index 76939527..1fec860a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/messaging/MessagingFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/messaging/MessagingFactory.java @@ -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

{ private final P plugin; @@ -103,15 +103,13 @@ public class MessagingFactory

{ 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

{ 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"); diff --git a/common/src/main/java/me/lucko/luckperms/common/messaging/message/AbstractMessage.java b/common/src/main/java/me/lucko/luckperms/common/messaging/message/AbstractMessage.java index 683d7a8d..8b189293 100644 --- a/common/src/main/java/me/lucko/luckperms/common/messaging/message/AbstractMessage.java +++ b/common/src/main/java/me/lucko/luckperms/common/messaging/message/AbstractMessage.java @@ -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; } diff --git a/common/src/main/java/me/lucko/luckperms/common/messaging/message/LogMessageImpl.java b/common/src/main/java/me/lucko/luckperms/common/messaging/message/LogMessageImpl.java index fb5bbf37..35a75c2b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/messaging/message/LogMessageImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/messaging/message/LogMessageImpl.java @@ -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) ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/messaging/message/UpdateMessageImpl.java b/common/src/main/java/me/lucko/luckperms/common/messaging/message/UpdateMessageImpl.java index 876393b1..042768e4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/messaging/message/UpdateMessageImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/messaging/message/UpdateMessageImpl.java @@ -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); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/messaging/message/UserUpdateMessageImpl.java b/common/src/main/java/me/lucko/luckperms/common/messaging/message/UserUpdateMessageImpl.java index 61bbf8d1..fd5501be 100644 --- a/common/src/main/java/me/lucko/luckperms/common/messaging/message/UserUpdateMessageImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/messaging/message/UserUpdateMessageImpl.java @@ -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() ); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/messaging/redis/RedisMessenger.java b/common/src/main/java/me/lucko/luckperms/common/messaging/redis/RedisMessenger.java index 16cf7671..2f1e0818 100644 --- a/common/src/main/java/me/lucko/luckperms/common/messaging/redis/RedisMessenger.java +++ b/common/src/main/java/me/lucko/luckperms/common/messaging/redis/RedisMessenger.java @@ -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) { diff --git a/common/src/main/java/me/lucko/luckperms/common/messaging/sql/AbstractSqlMessenger.java b/common/src/main/java/me/lucko/luckperms/common/messaging/sql/AbstractSqlMessenger.java index 6ad698cb..66412740 100644 --- a/common/src/main/java/me/lucko/luckperms/common/messaging/sql/AbstractSqlMessenger.java +++ b/common/src/main/java/me/lucko/luckperms/common/messaging/sql/AbstractSqlMessenger.java @@ -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()); diff --git a/common/src/main/java/me/lucko/luckperms/common/metastacking/FluentMetaStackElement.java b/common/src/main/java/me/lucko/luckperms/common/metastacking/FluentMetaStackElement.java index 63e2c42a..b1a2d38b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/metastacking/FluentMetaStackElement.java +++ b/common/src/main/java/me/lucko/luckperms/common/metastacking/FluentMetaStackElement.java @@ -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 current) { + public boolean shouldAccumulate(@NonNull LocalizedNode node, @NonNull ChatMetaType type, Map.@Nullable Entry current) { for (MetaStackElement element : this.subElements) { if (!element.shouldAccumulate(node, type, current)) { return false; diff --git a/common/src/main/java/me/lucko/luckperms/common/metastacking/SimpleMetaStackDefinition.java b/common/src/main/java/me/lucko/luckperms/common/metastacking/SimpleMetaStackDefinition.java index f468dda0..c431e724 100644 --- a/common/src/main/java/me/lucko/luckperms/common/metastacking/SimpleMetaStackDefinition.java +++ b/common/src/main/java/me/lucko/luckperms/common/metastacking/SimpleMetaStackDefinition.java @@ -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 elements; @@ -53,27 +53,23 @@ public final class SimpleMetaStackDefinition implements MetaStackDefinition { this.hashCode = calculateHashCode(); } - @Nonnull @Override - public List getElements() { + public @NonNull List 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; } diff --git a/common/src/main/java/me/lucko/luckperms/common/metastacking/StandardStackElements.java b/common/src/main/java/me/lucko/luckperms/common/metastacking/StandardStackElements.java index 65dee06d..24e54ed7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/metastacking/StandardStackElements.java +++ b/common/src/main/java/me/lucko/luckperms/common/metastacking/StandardStackElements.java @@ -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 current) { + public boolean shouldAccumulate(@NonNull LocalizedNode node, @NonNull ChatMetaType type, Map.@Nullable Entry 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 current) { + public boolean shouldAccumulate(@NonNull LocalizedNode node, @NonNull ChatMetaType type, Map.@Nullable Entry 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 current) { + public boolean shouldAccumulate(@NonNull LocalizedNode node, @NonNull ChatMetaType type, Map.@Nullable Entry 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 current) { + public boolean shouldAccumulate(@NonNull LocalizedNode node, @NonNull ChatMetaType type, Map.@Nullable Entry current) { return !this.groupName.equals(node.getLocation()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/model/DisplayNameCache.java b/common/src/main/java/me/lucko/luckperms/common/model/DisplayNameCache.java index 94dc65e7..be1b90ef 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/DisplayNameCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/DisplayNameCache.java @@ -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> { this.group = group; } - @Nonnull @Override - protected Optional supply() { + protected @NonNull Optional supply() { // query for a displayname node for (Node n : this.group.getOwnNodes(this.group.getPlugin().getContextManager().getStaticContext())) { Optional displayName = n.getTypeData(DisplayNameType.KEY); diff --git a/common/src/main/java/me/lucko/luckperms/common/model/NodeMap.java b/common/src/main/java/me/lucko/luckperms/common/model/NodeMap.java index f77bbbd9..b8bcecfd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/NodeMap.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/NodeMap.java @@ -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 supply() { + protected @NonNull ImmutableSetMultimap supply() { return ImmutableSetMultimap.copyOf(this.handle.map); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java b/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java index b064f56b..5439154a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java @@ -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; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/model/Track.java b/common/src/main/java/me/lucko/luckperms/common/model/Track.java index e40d66c7..193c7b9e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/Track.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/Track.java @@ -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 { /** diff --git a/common/src/main/java/me/lucko/luckperms/common/model/User.java b/common/src/main/java/me/lucko/luckperms/common/model/User.java index a2dfc3ea..233d2b2b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/User.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/User.java @@ -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 { private final ApiUser apiDelegate = new ApiUser(this); @@ -48,8 +48,7 @@ public class User extends PermissionHolder implements Identifiable { * * @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; diff --git a/common/src/main/java/me/lucko/luckperms/common/model/WeightCache.java b/common/src/main/java/me/lucko/luckperms/common/model/WeightCache.java index 3923de9f..7fd32294 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/WeightCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/WeightCache.java @@ -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 { 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())) { diff --git a/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeBuilder.java b/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeBuilder.java index 095fc20b..906cd50d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeBuilder.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeBuilder.java @@ -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 entry) { + public Node.@NonNull Builder withExtraContext(Map.@NonNull Entry entry) { Objects.requireNonNull(entry, "entry"); withExtraContext(entry.getKey(), entry.getValue()); return this; } - @Nonnull @Override - public Node.Builder withExtraContext(@Nonnull Map map) { + public Node.@NonNull Builder withExtraContext(@NonNull Map map) { Objects.requireNonNull(map, "map"); withExtraContext(ContextSet.fromMap(map)); return this; } - @Nonnull @Override - public Node.Builder withExtraContext(@Nonnull Set> context) { + public Node.@NonNull Builder withExtraContext(@NonNull Set> 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()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/node/model/ForwardingNode.java b/common/src/main/java/me/lucko/luckperms/common/node/model/ForwardingNode.java index 2333c072..fd6fe4c1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/model/ForwardingNode.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/model/ForwardingNode.java @@ -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 getServer() { + public @NonNull Optional getServer() { return delegate().getServer(); } - @Nonnull @Override - public Optional getWorld() { + public @NonNull Optional 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 resolveShorthand() { + public @NonNull List 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 getMeta() throws IllegalStateException { + public Map.@NonNull Entry getMeta() throws IllegalStateException { return delegate().getMeta(); } @@ -219,9 +209,8 @@ public abstract class ForwardingNode implements Node { return delegate().isPrefix(); } - @Nonnull @Override - public Map.Entry getPrefix() throws IllegalStateException { + public Map.@NonNull Entry getPrefix() throws IllegalStateException { return delegate().getPrefix(); } @@ -230,9 +219,8 @@ public abstract class ForwardingNode implements Node { return delegate().isSuffix(); } - @Nonnull @Override - public Map.Entry getSuffix() throws IllegalStateException { + public Map.@NonNull Entry getSuffix() throws IllegalStateException { return delegate().getSuffix(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/node/model/ImmutableLocalizedNode.java b/common/src/main/java/me/lucko/luckperms/common/node/model/ImmutableLocalizedNode.java index 613e8695..0b67082f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/model/ImmutableLocalizedNode.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/model/ImmutableLocalizedNode.java @@ -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; } diff --git a/common/src/main/java/me/lucko/luckperms/common/node/model/ImmutableNode.java b/common/src/main/java/me/lucko/luckperms/common/node/model/ImmutableNode.java index dad2f0ce..267e832e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/model/ImmutableNode.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/model/ImmutableNode.java @@ -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 getServer() { + public @NonNull Optional getServer() { return this.optServer; } - @Nonnull @Override - public Optional getWorld() { + public @NonNull Optional 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 resolveShorthand() { + public @NonNull List 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) { diff --git a/common/src/main/java/me/lucko/luckperms/common/node/model/NodeHeldPermission.java b/common/src/main/java/me/lucko/luckperms/common/node/model/NodeHeldPermission.java index c9f20aed..57eac27d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/model/NodeHeldPermission.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/model/NodeHeldPermission.java @@ -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> implements HeldPermission { public static > NodeHeldPermission of(T holder, NodeDataContainer node) { return of(holder, node.toNode()); @@ -51,9 +51,8 @@ public final class NodeHeldPermission> 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> implements HeldPe return this.node.getValue(); } - @Nonnull @Override - public Optional getServer() { + public @NonNull Optional getServer() { return this.node.getServer(); } - @Nonnull @Override - public Optional getWorld() { + public @NonNull Optional getWorld() { return this.node.getWorld(); } @@ -84,15 +81,13 @@ public final class NodeHeldPermission> 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; } diff --git a/common/src/main/java/me/lucko/luckperms/common/node/model/NodeTypes.java b/common/src/main/java/me/lucko/luckperms/common/node/model/NodeTypes.java index 6a62acbd..4490deef 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/model/NodeTypes.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/model/NodeTypes.java @@ -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, NodeType> parseTypes(String s) { + public static @NonNull Map, NodeType> parseTypes(String s) { Map, 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 getAsEntry() { + public Map.@NonNull Entry 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 getAsEntry() { + public Map.@NonNull Entry 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 getPattern() { + public @NonNull Optional getPattern() { return Optional.ofNullable(get().getPattern()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/bootstrap/LuckPermsBootstrap.java b/common/src/main/java/me/lucko/luckperms/common/plugin/bootstrap/LuckPermsBootstrap.java index a6227a09..af542d6f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/bootstrap/LuckPermsBootstrap.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/bootstrap/LuckPermsBootstrap.java @@ -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; } diff --git a/common/src/main/java/me/lucko/luckperms/common/primarygroup/AllParentsByWeightHolder.java b/common/src/main/java/me/lucko/luckperms/common/primarygroup/AllParentsByWeightHolder.java index 2b6c20c9..85681aa1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/primarygroup/AllParentsByWeightHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/primarygroup/AllParentsByWeightHolder.java @@ -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 calculateValue(Contexts contexts) { + protected @NonNull Optional 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 diff --git a/common/src/main/java/me/lucko/luckperms/common/primarygroup/ContextualHolder.java b/common/src/main/java/me/lucko/luckperms/common/primarygroup/ContextualHolder.java index e2a4b6fb..2da5cdd6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/primarygroup/ContextualHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/primarygroup/ContextualHolder.java @@ -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 calculateValue(Contexts contexts); + protected abstract @NonNull Optional calculateValue(Contexts contexts); public void invalidateCache() { this.cache.invalidateAll(); diff --git a/common/src/main/java/me/lucko/luckperms/common/primarygroup/ParentsByWeightHolder.java b/common/src/main/java/me/lucko/luckperms/common/primarygroup/ParentsByWeightHolder.java index b5be11f1..64db7e19 100644 --- a/common/src/main/java/me/lucko/luckperms/common/primarygroup/ParentsByWeightHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/primarygroup/ParentsByWeightHolder.java @@ -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 calculateValue(Contexts contexts) { + protected @NonNull Optional calculateValue(Contexts contexts) { Set groups = new LinkedHashSet<>(); for (Node node : this.user.getOwnGroupNodes(contexts.getContexts())) { Group group = this.user.getPlugin().getGroupManager().getIfLoaded(node.getGroupName()); diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/PlayerSaveResultImpl.java b/common/src/main/java/me/lucko/luckperms/common/storage/PlayerSaveResultImpl.java index 073e68b5..55b9f841 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/PlayerSaveResultImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/PlayerSaveResultImpl.java @@ -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; - @Nullable private final String oldUsername; - @Nullable private final Set otherUuids; + private final @Nullable String oldUsername; + private final @Nullable Set otherUuids; private PlayerSaveResultImpl(EnumSet status, @Nullable String oldUsername, @Nullable Set 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 otherUuids) { + public PlayerSaveResultImpl withOtherUuidsPresent(@NonNull Set otherUuids) { EnumSet 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 getStatus() { + public @NonNull Set 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 getOtherUuids() { + public @Nullable Set getOtherUuids() { return this.otherUuids; } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/dao/AbstractDao.java b/common/src/main/java/me/lucko/luckperms/common/storage/dao/AbstractDao.java index 75f4a9e9..2342ec97 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/dao/AbstractDao.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/dao/AbstractDao.java @@ -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; } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/FileUuidCache.java b/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/FileUuidCache.java index 01dfd02c..b9fe4782 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/FileUuidCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/FileUuidCache.java @@ -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 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 uuids = this.lookupMap.lookupUuid(username); return Iterables.getFirst(uuids, null); } diff --git a/common/src/main/java/me/lucko/luckperms/common/treeview/ImmutableTreeNode.java b/common/src/main/java/me/lucko/luckperms/common/treeview/ImmutableTreeNode.java index 8041b649..406428d5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/treeview/ImmutableTreeNode.java +++ b/common/src/main/java/me/lucko/luckperms/common/treeview/ImmutableTreeNode.java @@ -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 { } @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); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/treeview/TreeNode.java b/common/src/main/java/me/lucko/luckperms/common/treeview/TreeNode.java index 209e7f68..4feba27a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/treeview/TreeNode.java +++ b/common/src/main/java/me/lucko/luckperms/common/treeview/TreeNode.java @@ -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 childMap = getChildMap(); if (!allowInsert(this)) { return null; diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/ExpiringSet.java b/common/src/main/java/me/lucko/luckperms/common/utils/ExpiringSet.java index 780ba756..33baf38f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/ExpiringSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/ExpiringSet.java @@ -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 extends ForwardingSet { } @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 extends ForwardingSet { } @Override - public boolean addAll(@Nonnull Collection collection) { + public boolean addAll(@NonNull Collection collection) { for (E element : collection) { add(element); } @@ -68,7 +68,7 @@ public class ExpiringSet extends ForwardingSet { } @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 extends ForwardingSet { } @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 diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/PatternCache.java b/common/src/main/java/me/lucko/luckperms/common/utils/PatternCache.java index b9246460..921fc022 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/PatternCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/PatternCache.java @@ -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 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; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/Uuids.java b/common/src/main/java/me/lucko/luckperms/common/utils/Uuids.java index 26ae3965..8b6c34ca 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/Uuids.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/Uuids.java @@ -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 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")); diff --git a/common/src/main/java/me/lucko/luckperms/common/web/HttpClient.java b/common/src/main/java/me/lucko/luckperms/common/web/HttpClient.java index d0441509..1f331dfc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/web/HttpClient.java +++ b/common/src/main/java/me/lucko/luckperms/common/web/HttpClient.java @@ -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()) diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/contexts/WorldCalculator.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/contexts/WorldCalculator.java index 73b9d151..42572889 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/contexts/WorldCalculator.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/contexts/WorldCalculator.java @@ -31,9 +31,9 @@ import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import cn.nukkit.Player; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import cn.nukkit.Player; public class WorldCalculator implements ContextCalculator { private final LuckPermsPlugin plugin; @@ -42,9 +42,8 @@ public class WorldCalculator implements ContextCalculator { this.plugin = plugin; } - @Nonnull @Override - public MutableContextSet giveApplicableContext(@Nonnull Player subject, @Nonnull MutableContextSet accumulator) { + public @NonNull MutableContextSet giveApplicableContext(@NonNull Player subject, @NonNull MutableContextSet accumulator) { String world = subject.getLevel().getName().toLowerCase(); while (!accumulator.has(Contexts.WORLD_KEY, world)) { accumulator.add(Contexts.WORLD_KEY, world); diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/PermissionDefault.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/PermissionDefault.java index 9cd38e25..1ba3eb95 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/PermissionDefault.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/PermissionDefault.java @@ -25,13 +25,13 @@ package me.lucko.luckperms.nukkit.model; +import org.checkerframework.checker.nullness.qual.Nullable; + import cn.nukkit.permission.Permission; import java.util.HashMap; import java.util.Map; -import javax.annotation.Nullable; - /** * Represents the possible default values for permissions */ @@ -83,13 +83,11 @@ public enum PermissionDefault { * @param name Name of the default * @return Specified value, or null if not found */ - @Nullable - public static PermissionDefault getByName(String name) { + public static @Nullable PermissionDefault getByName(String name) { return LOOKUP.get(name.toLowerCase().replaceAll("[^a-z!]", "")); } - @Nullable - public static PermissionDefault fromPermission(@Nullable Permission permission) { + public static @Nullable PermissionDefault fromPermission(@Nullable Permission permission) { if (permission == null) { return null; } diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/dummy/DummyPermissibleBase.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/dummy/DummyPermissibleBase.java index 599643da..82fb09e7 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/dummy/DummyPermissibleBase.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/dummy/DummyPermissibleBase.java @@ -25,6 +25,8 @@ package me.lucko.luckperms.nukkit.model.dummy; +import org.checkerframework.checker.nullness.qual.NonNull; + import cn.nukkit.permission.PermissibleBase; import cn.nukkit.permission.Permission; import cn.nukkit.permission.PermissionAttachment; @@ -128,7 +130,7 @@ public class DummyPermissibleBase extends PermissibleBase { } @Override - public boolean addAll(Collection c) { + public boolean addAll(@NonNull Collection c) { // do nothing return true; } diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/permissible/LPPermissible.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/permissible/LPPermissible.java index 36ac4eff..183e7d00 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/permissible/LPPermissible.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/permissible/LPPermissible.java @@ -36,6 +36,8 @@ import me.lucko.luckperms.common.verbose.CheckOrigin; import me.lucko.luckperms.nukkit.LPNukkitPlugin; import me.lucko.luckperms.nukkit.model.PermissionDefault; +import org.checkerframework.checker.nullness.qual.NonNull; + import cn.nukkit.Player; import cn.nukkit.permission.PermissibleBase; import cn.nukkit.permission.Permission; @@ -52,8 +54,6 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; -import javax.annotation.Nonnull; - /** * PermissibleBase for LuckPerms. * @@ -347,7 +347,7 @@ public class LPPermissible extends PermissibleBase { } @Override - public boolean addAll(@Nonnull Collection c) { + public boolean addAll(@NonNull Collection c) { boolean modified = false; for (PermissionAttachment e : c) { if (add(e)) { @@ -368,22 +368,20 @@ public class LPPermissible extends PermissibleBase { return ImmutableList.copyOf(LPPermissible.this.lpAttachments).iterator(); } - @Nonnull @Override - public Object[] toArray() { + public @NonNull Object[] toArray() { return ImmutableList.copyOf(LPPermissible.this.lpAttachments).toArray(); } - @Nonnull @Override - public T[] toArray(@Nonnull T[] a) { + public @NonNull T[] toArray(@NonNull T[] a) { return ImmutableList.copyOf(LPPermissible.this.lpAttachments).toArray(a); } @Override public int size() { throw new UnsupportedOperationException(); } @Override public boolean isEmpty() { throw new UnsupportedOperationException(); } - @Override public boolean containsAll(@Nonnull Collection c) { throw new UnsupportedOperationException(); } - @Override public boolean removeAll(@Nonnull Collection c) { throw new UnsupportedOperationException(); } - @Override public boolean retainAll(@Nonnull Collection c) { throw new UnsupportedOperationException(); } + @Override public boolean containsAll(@NonNull Collection c) { throw new UnsupportedOperationException(); } + @Override public boolean removeAll(@NonNull Collection c) { throw new UnsupportedOperationException(); } + @Override public boolean retainAll(@NonNull Collection c) { throw new UnsupportedOperationException(); } } } diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/server/LPDefaultsMap.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/server/LPDefaultsMap.java index 7f419bc6..b8bea811 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/server/LPDefaultsMap.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/server/LPDefaultsMap.java @@ -32,6 +32,8 @@ import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.common.buffers.Cache; import me.lucko.luckperms.nukkit.LPNukkitPlugin; +import org.checkerframework.checker.nullness.qual.NonNull; + import cn.nukkit.permission.Permission; import cn.nukkit.plugin.PluginManager; @@ -40,8 +42,6 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import javax.annotation.Nonnull; - /** * A replacement map for the 'defaultPerms' instance in Nukkit's SimplePluginManager. * @@ -61,8 +61,8 @@ public final class LPDefaultsMap { private final Map nonOpSet = new DefaultPermissionSet(false); // fully resolved defaults (accounts for child permissions too) - private DefaultsCache opCache = new DefaultsCache(true); - private DefaultsCache nonOpCache = new DefaultsCache(false); + private final DefaultsCache opCache = new DefaultsCache(true); + private final DefaultsCache nonOpCache = new DefaultsCache(false); public LPDefaultsMap(LPNukkitPlugin plugin, Map> existingData) { this.plugin = plugin; @@ -118,7 +118,7 @@ public final class LPDefaultsMap { } @Override - public Permission put(String key, Permission value) { + public Permission put(@NonNull String key, @NonNull Permission value) { Permission ret = super.put(key, value); invalidate(this.op); return ret; @@ -132,7 +132,7 @@ public final class LPDefaultsMap { } @Override - public void putAll(Map map) { + public void putAll(@NonNull Map map) { super.putAll(map); invalidate(this.op); } @@ -145,9 +145,8 @@ public final class LPDefaultsMap { this.op = op; } - @Nonnull @Override - protected Map supply() { + protected @NonNull Map supply() { Map builder = new HashMap<>(); for (Permission perm : LPDefaultsMap.this.get(this.op).values()) { String name = perm.getName().toLowerCase(); diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/server/LPPermissionMap.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/server/LPPermissionMap.java index 00c5887e..4d0e7035 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/server/LPPermissionMap.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/server/LPPermissionMap.java @@ -34,6 +34,8 @@ import com.google.common.collect.ImmutableMap; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.treeview.PermissionRegistry; +import org.checkerframework.checker.nullness.qual.NonNull; + import cn.nukkit.permission.Permission; import cn.nukkit.plugin.PluginManager; @@ -42,9 +44,6 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - /** * A replacement map for the 'permissions' instance in Nukkit's SimplePluginManager. * @@ -93,7 +92,7 @@ public final class LPPermissionMap extends ForwardingMap { } @Override - public Permission put(@Nonnull String key, @Nonnull Permission value) { + public Permission put(@NonNull String key, @NonNull Permission value) { this.plugin.getPermissionRegistry().insert(key); Permission ret = super.put(key, value); update(); @@ -101,7 +100,7 @@ public final class LPPermissionMap extends ForwardingMap { } @Override - public void putAll(@Nonnull Map m) { + public void putAll(@NonNull Map m) { for (Map.Entry ent : m.entrySet()) { put(ent.getKey(), ent.getValue()); } @@ -122,9 +121,8 @@ public final class LPPermissionMap extends ForwardingMap { this.value = value; } - @CheckForNull @Override - public Map load(@Nonnull String key) { + public Map load(@NonNull String key) { Map children = new HashMap<>(); resolveChildren(children, Collections.singletonMap(key, this.value), false); children.remove(key, this.value); diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/server/LPSubscriptionMap.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/server/LPSubscriptionMap.java index 54890ae1..6804c92a 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/server/LPSubscriptionMap.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/server/LPSubscriptionMap.java @@ -29,6 +29,8 @@ import com.google.common.collect.Sets; import me.lucko.luckperms.nukkit.LPNukkitPlugin; +import org.checkerframework.checker.nullness.qual.NonNull; + import cn.nukkit.Player; import cn.nukkit.permission.Permissible; import cn.nukkit.plugin.PluginManager; @@ -221,7 +223,7 @@ public final class LPSubscriptionMap extends HashMap> { } @Override - public T[] toArray(T[] a) { + public T[] toArray(@NonNull T[] a) { return getContentView().toArray(a); } @@ -236,7 +238,7 @@ public final class LPSubscriptionMap extends HashMap> { } @Override - public boolean addAll(Collection c) { + public boolean addAll(@NonNull Collection c) { return this.backing.addAll(c); } @@ -246,17 +248,17 @@ public final class LPSubscriptionMap extends HashMap> { } @Override - public boolean containsAll(Collection c) { + public boolean containsAll(@NonNull Collection c) { return getContentView().containsAll(c); } @Override - public boolean retainAll(Collection c) { + public boolean retainAll(@NonNull Collection c) { return this.backing.retainAll(c); } @Override - public boolean removeAll(Collection c) { + public boolean removeAll(@NonNull Collection c) { return this.backing.removeAll(c); } diff --git a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/DescriptionBuilder.java b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/DescriptionBuilder.java index c283c30e..04db2e41 100644 --- a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/DescriptionBuilder.java +++ b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/DescriptionBuilder.java @@ -32,6 +32,8 @@ import me.lucko.luckperms.sponge.service.model.LPPermissionService; import me.lucko.luckperms.sponge.service.model.LPSubject; import me.lucko.luckperms.sponge.service.model.LPSubjectCollection; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.service.permission.PermissionDescription; import org.spongepowered.api.service.permission.PermissionService; @@ -41,46 +43,39 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - public final class DescriptionBuilder implements PermissionDescription.Builder { - @Nonnull private final LPPermissionService service; - @Nonnull private final PluginContainer container; - @Nonnull private final Map roles = new HashMap<>(); - @Nullable private String id = null; - @Nullable private Text description = null; + private final @NonNull LPPermissionService service; + private final @NonNull PluginContainer container; + private final @NonNull Map roles = new HashMap<>(); + private @Nullable String id = null; + private @Nullable Text description = null; - public DescriptionBuilder(@Nonnull LPPermissionService service, @Nonnull PluginContainer container) { + public DescriptionBuilder(@NonNull LPPermissionService service, @NonNull PluginContainer container) { this.service = Objects.requireNonNull(service, "service"); this.container = Objects.requireNonNull(container, "container"); } - @Nonnull @Override - public PermissionDescription.Builder id(@Nonnull String id) { + public PermissionDescription.@NonNull Builder id(@NonNull String id) { this.id = Objects.requireNonNull(id, "id"); return this; } - @Nonnull @Override - public PermissionDescription.Builder description(@Nonnull Text description) { + public PermissionDescription.@NonNull Builder description(@NonNull Text description) { this.description = Objects.requireNonNull(description, "description"); return this; } - @Nonnull @Override - public PermissionDescription.Builder assign(@Nonnull String role, boolean value) { + public PermissionDescription.@NonNull Builder assign(@NonNull String role, boolean value) { Objects.requireNonNull(role, "role"); this.roles.put(role, Tristate.fromBoolean(value)); return this; } - @Nonnull @Override - public PermissionDescription register() throws IllegalStateException { + public @NonNull PermissionDescription register() throws IllegalStateException { if (this.id == null) { throw new IllegalStateException("id cannot be null"); } diff --git a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/PermissionDescriptionProxy.java b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/PermissionDescriptionProxy.java index 4aeb2d66..017d52ce 100644 --- a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/PermissionDescriptionProxy.java +++ b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/PermissionDescriptionProxy.java @@ -29,6 +29,7 @@ import me.lucko.luckperms.common.utils.ImmutableCollectors; import me.lucko.luckperms.sponge.service.model.LPPermissionDescription; import me.lucko.luckperms.sponge.service.model.LPPermissionService; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.Sponge; import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.service.permission.PermissionDescription; @@ -37,8 +38,6 @@ import org.spongepowered.api.text.Text; import java.util.Map; -import javax.annotation.Nonnull; - public final class PermissionDescriptionProxy implements PermissionDescription { private final LPPermissionService service; private final LPPermissionDescription handle; @@ -48,27 +47,23 @@ public final class PermissionDescriptionProxy implements PermissionDescription { this.handle = handle; } - @Nonnull @Override - public String getId() { + public @NonNull String getId() { return this.handle.getId(); } - @Nonnull @Override - public Text getDescription() { + public @NonNull Text getDescription() { return this.handle.getDescription().orElse(Text.EMPTY); } - @Nonnull @Override - public PluginContainer getOwner() { + public @NonNull PluginContainer getOwner() { return this.handle.getOwner().orElseGet(() -> Sponge.getGame().getPluginManager().fromInstance(this.service.getPlugin()).orElseThrow(() -> new RuntimeException("Unable to get LuckPerms instance."))); } - @Nonnull @Override - public Map getAssignedSubjects(@Nonnull String s) { + public @NonNull Map getAssignedSubjects(@NonNull String s) { return this.handle.getAssignedSubjects(s).entrySet().stream() .collect(ImmutableCollectors.toMap( e -> new SubjectProxy(this.service, e.getKey().toReference()), diff --git a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/PermissionServiceProxy.java b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/PermissionServiceProxy.java index 6f24b5d5..7a0f9cde 100644 --- a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/PermissionServiceProxy.java +++ b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/PermissionServiceProxy.java @@ -29,6 +29,7 @@ import me.lucko.luckperms.common.utils.ImmutableCollectors; import me.lucko.luckperms.sponge.service.model.LPPermissionDescription; import me.lucko.luckperms.sponge.service.model.LPPermissionService; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.Sponge; import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.service.context.ContextCalculator; @@ -41,8 +42,6 @@ import java.util.Collection; import java.util.Map; import java.util.Optional; -import javax.annotation.Nonnull; - public final class PermissionServiceProxy implements PermissionService { private final LPPermissionService handle; @@ -50,33 +49,28 @@ public final class PermissionServiceProxy implements PermissionService { this.handle = handle; } - @Nonnull @Override - public SubjectCollection getUserSubjects() { + public @NonNull SubjectCollection getUserSubjects() { return this.handle.getUserSubjects().sponge(); } - @Nonnull @Override - public SubjectCollection getGroupSubjects() { + public @NonNull SubjectCollection getGroupSubjects() { return this.handle.getGroupSubjects().sponge(); } - @Nonnull @Override - public Subject getDefaults() { + public @NonNull Subject getDefaults() { return this.handle.getRootDefaults().sponge(); } - @Nonnull @Override - public SubjectCollection getSubjects(@Nonnull String s) { + public @NonNull SubjectCollection getSubjects(@NonNull String s) { return this.handle.getCollection(s).sponge(); } - @Nonnull @Override - public Map getKnownSubjects() { + public @NonNull Map getKnownSubjects() { return this.handle.getLoadedCollections().entrySet().stream() .collect(ImmutableCollectors.toMap( Map.Entry::getKey, @@ -85,7 +79,7 @@ public final class PermissionServiceProxy implements PermissionService { } @Override - public Optional newDescriptionBuilder(@Nonnull Object o) { + public Optional newDescriptionBuilder(@NonNull Object o) { Optional container = Sponge.getGame().getPluginManager().fromInstance(o); if (!container.isPresent()) { throw new IllegalArgumentException("Couldn't find a plugin container for " + o.getClass().getSimpleName()); @@ -94,20 +88,18 @@ public final class PermissionServiceProxy implements PermissionService { return Optional.of(new DescriptionBuilder(this.handle, container.get())); } - @Nonnull @Override - public Optional getDescription(@Nonnull String s) { + public @NonNull Optional getDescription(@NonNull String s) { return this.handle.getDescription(s).map(LPPermissionDescription::sponge); } - @Nonnull @Override - public Collection getDescriptions() { + public @NonNull Collection getDescriptions() { return this.handle.getDescriptions().stream().map(LPPermissionDescription::sponge).collect(ImmutableCollectors.toSet()); } @Override - public void registerContextCalculator(@Nonnull ContextCalculator contextCalculator) { + public void registerContextCalculator(@NonNull ContextCalculator contextCalculator) { this.handle.registerContextCalculator(contextCalculator); } diff --git a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectCollectionProxy.java b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectCollectionProxy.java index 5475e062..d179932b 100644 --- a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectCollectionProxy.java +++ b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectCollectionProxy.java @@ -31,6 +31,7 @@ import me.lucko.luckperms.sponge.service.model.LPPermissionService; import me.lucko.luckperms.sponge.service.model.LPSubject; import me.lucko.luckperms.sponge.service.model.LPSubjectCollection; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.service.context.Context; import org.spongepowered.api.service.permission.Subject; import org.spongepowered.api.service.permission.SubjectCollection; @@ -39,8 +40,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; - @SuppressWarnings("unchecked") public final class SubjectCollectionProxy implements SubjectCollection { private final LPPermissionService service; @@ -51,28 +50,25 @@ public final class SubjectCollectionProxy implements SubjectCollection { this.handle = handle; } - @Nonnull @Override - public String getIdentifier() { + public @NonNull String getIdentifier() { return this.handle.getIdentifier(); } - @Nonnull @Override - public Subject get(@Nonnull String s) { + public @NonNull Subject get(@NonNull String s) { // force load the subject. // after this call, users will expect that the subject is loaded in memory. return this.handle.loadSubject(s).thenApply(LPSubject::sponge).join(); } @Override - public boolean hasRegistered(@Nonnull String s) { + public boolean hasRegistered(@NonNull String s) { return this.handle.hasRegistered(s).join(); } - @Nonnull @Override - public Iterable getAllSubjects() { + public @NonNull Iterable getAllSubjects() { // this will lazily load all subjects. it will initially just get the identifiers of each subject, and will initialize dummy // providers for those identifiers. when any methods against the dummy are called, the actual data will be loaded. // this behaviour should be replaced when CompletableFutures are added to Sponge @@ -83,9 +79,8 @@ public final class SubjectCollectionProxy implements SubjectCollection { ).join(); } - @Nonnull @Override - public Map getAllWithPermission(@Nonnull String s) { + public @NonNull Map getAllWithPermission(@NonNull String s) { // again, these methods will lazily load subjects. return (Map) this.handle.getAllWithPermission(s) .thenApply(map -> map.entrySet().stream() @@ -96,9 +91,8 @@ public final class SubjectCollectionProxy implements SubjectCollection { ).join(); } - @Nonnull @Override - public Map getAllWithPermission(@Nonnull Set set, @Nonnull String s) { + public @NonNull Map getAllWithPermission(@NonNull Set set, @NonNull String s) { return (Map) this.handle.getAllWithPermission(CompatibilityUtil.convertContexts(set), s) .thenApply(map -> map.entrySet().stream() .collect(ImmutableCollectors.toMap( @@ -108,9 +102,8 @@ public final class SubjectCollectionProxy implements SubjectCollection { ).join(); } - @Nonnull @Override - public Subject getDefaults() { + public @NonNull Subject getDefaults() { return this.handle.getDefaults().sponge(); } diff --git a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectDataProxy.java b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectDataProxy.java index 44584251..cbfd3aa8 100644 --- a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectDataProxy.java +++ b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectDataProxy.java @@ -32,6 +32,7 @@ import me.lucko.luckperms.sponge.service.model.LPSubject; import me.lucko.luckperms.sponge.service.model.LPSubjectData; import me.lucko.luckperms.sponge.service.model.LPSubjectReference; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.service.context.Context; import org.spongepowered.api.service.permission.Subject; import org.spongepowered.api.service.permission.SubjectData; @@ -42,8 +43,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; -import javax.annotation.Nonnull; - @SuppressWarnings("unchecked") public final class SubjectDataProxy implements SubjectData { private final LPPermissionService service; @@ -62,9 +61,8 @@ public final class SubjectDataProxy implements SubjectData { this.ref.resolveLp().thenApply(LPSubject::getTransientSubjectData); } - @Nonnull @Override - public Map, Map> getAllPermissions() { + public @NonNull Map, Map> getAllPermissions() { return (Map) handle().thenApply(handle -> handle.getAllPermissions().entrySet().stream() .collect(ImmutableCollectors.toMap( e -> CompatibilityUtil.convertContexts(e.getKey()), @@ -72,14 +70,13 @@ public final class SubjectDataProxy implements SubjectData { ))).join(); } - @Nonnull @Override - public Map getPermissions(@Nonnull Set contexts) { + public @NonNull Map getPermissions(@NonNull Set contexts) { return handle().thenApply(handle -> handle.getPermissions(CompatibilityUtil.convertContexts(contexts))).join(); } @Override - public boolean setPermission(@Nonnull Set contexts, @Nonnull String permission, @Nonnull Tristate value) { + public boolean setPermission(@NonNull Set contexts, @NonNull String permission, @NonNull Tristate value) { handle().thenCompose(handle -> handle.setPermission( CompatibilityUtil.convertContexts(contexts), permission, @@ -95,14 +92,13 @@ public final class SubjectDataProxy implements SubjectData { } @Override - public boolean clearPermissions(@Nonnull Set contexts) { + public boolean clearPermissions(@NonNull Set contexts) { handle().thenCompose(handle -> handle.clearPermissions(CompatibilityUtil.convertContexts(contexts))); return true; } - @Nonnull @Override - public Map, List> getAllParents() { + public @NonNull Map, List> getAllParents() { return (Map) handle().thenApply(handle -> handle.getAllParents().entrySet().stream() .collect(ImmutableCollectors.toMap( e -> CompatibilityUtil.convertContexts(e.getKey()), @@ -113,16 +109,15 @@ public final class SubjectDataProxy implements SubjectData { )).join(); } - @Nonnull @Override - public List getParents(@Nonnull Set contexts) { + public @NonNull List getParents(@NonNull Set contexts) { return (List) handle().thenApply(handle -> handle.getParents(CompatibilityUtil.convertContexts(contexts)).stream() .map(s -> new SubjectProxy(this.service, s)) .collect(ImmutableCollectors.toList())).join(); } @Override - public boolean addParent(@Nonnull Set contexts, @Nonnull Subject parent) { + public boolean addParent(@NonNull Set contexts, @NonNull Subject parent) { handle().thenCompose(handle -> handle.addParent( CompatibilityUtil.convertContexts(contexts), this.service.getReferenceFactory().obtain(parent) @@ -131,7 +126,7 @@ public final class SubjectDataProxy implements SubjectData { } @Override - public boolean removeParent(@Nonnull Set contexts, @Nonnull Subject parent) { + public boolean removeParent(@NonNull Set contexts, @NonNull Subject parent) { handle().thenCompose(handle -> handle.removeParent( CompatibilityUtil.convertContexts(contexts), this.service.getReferenceFactory().obtain(parent) @@ -146,14 +141,13 @@ public final class SubjectDataProxy implements SubjectData { } @Override - public boolean clearParents(@Nonnull Set contexts) { + public boolean clearParents(@NonNull Set contexts) { handle().thenCompose(handle -> handle.clearParents(CompatibilityUtil.convertContexts(contexts))); return true; } - @Nonnull @Override - public Map, Map> getAllOptions() { + public @NonNull Map, Map> getAllOptions() { return (Map) handle().thenApply(handle -> handle.getAllOptions().entrySet().stream() .collect(ImmutableCollectors.toMap( e -> CompatibilityUtil.convertContexts(e.getKey()), @@ -161,14 +155,13 @@ public final class SubjectDataProxy implements SubjectData { ))).join(); } - @Nonnull @Override - public Map getOptions(@Nonnull Set contexts) { + public @NonNull Map getOptions(@NonNull Set contexts) { return handle().thenApply(handle -> handle.getOptions(CompatibilityUtil.convertContexts(contexts))).join(); } @Override - public boolean setOption(@Nonnull Set contexts, @Nonnull String key, String value) { + public boolean setOption(@NonNull Set contexts, @NonNull String key, String value) { if (value == null) { handle().thenCompose(handle -> handle.unsetOption(CompatibilityUtil.convertContexts(contexts), key)); return true; @@ -179,7 +172,7 @@ public final class SubjectDataProxy implements SubjectData { } @Override - public boolean clearOptions(@Nonnull Set contexts) { + public boolean clearOptions(@NonNull Set contexts) { handle().thenCompose(handle -> handle.clearOptions(CompatibilityUtil.convertContexts(contexts))); return true; } diff --git a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectProxy.java b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectProxy.java index 7393f3af..a2afd688 100644 --- a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectProxy.java +++ b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectProxy.java @@ -35,6 +35,7 @@ import me.lucko.luckperms.sponge.service.model.LPSubject; import me.lucko.luckperms.sponge.service.model.LPSubjectReference; import me.lucko.luckperms.sponge.service.model.ProxiedSubject; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.service.context.Context; import org.spongepowered.api.service.permission.Subject; @@ -47,8 +48,6 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; -import javax.annotation.Nonnull; - @SuppressWarnings("unchecked") public final class SubjectProxy implements Subject, ProxiedSubject { private final LPPermissionService service; @@ -74,21 +73,18 @@ public final class SubjectProxy implements Subject, ProxiedSubject { return this.contextsSupplier; } - @Nonnull @Override - public LPSubjectReference asSubjectReference() { + public @NonNull LPSubjectReference asSubjectReference() { return this.ref; } - @Nonnull @Override - public Optional getCommandSource() { + public @NonNull Optional getCommandSource() { return handle().thenApply(LPSubject::getCommandSource).join(); } - @Nonnull @Override - public SubjectCollection getContainingCollection() { + public @NonNull SubjectCollection getContainingCollection() { return this.service.getCollection(this.ref.getCollectionIdentifier()).sponge(); } @@ -103,23 +99,22 @@ public final class SubjectProxy implements Subject, ProxiedSubject { } @Override - public boolean hasPermission(@Nonnull Set contexts, @Nonnull String permission) { + public boolean hasPermission(@NonNull Set contexts, @NonNull String permission) { return handle().thenApply(handle -> handle.getPermissionValue(CompatibilityUtil.convertContexts(contexts), permission).asBoolean()).join(); } @Override - public boolean hasPermission(@Nonnull String permission) { + public boolean hasPermission(@NonNull String permission) { return handle().thenApply(handle -> handle.getPermissionValue(ImmutableContextSet.empty(), permission).asBoolean()).join(); } - @Nonnull @Override - public Tristate getPermissionValue(@Nonnull Set contexts, @Nonnull String permission) { + public @NonNull Tristate getPermissionValue(@NonNull Set contexts, @NonNull String permission) { return handle().thenApply(handle -> CompatibilityUtil.convertTristate(handle.getPermissionValue(CompatibilityUtil.convertContexts(contexts), permission))).join(); } @Override - public boolean isChildOf(@Nonnull Subject parent) { + public boolean isChildOf(@NonNull Subject parent) { return handle().thenApply(handle -> handle.isChildOf( ImmutableContextSet.empty(), this.service.getReferenceFactory().obtain(parent) @@ -127,38 +122,34 @@ public final class SubjectProxy implements Subject, ProxiedSubject { } @Override - public boolean isChildOf(@Nonnull Set contexts, @Nonnull Subject parent) { + public boolean isChildOf(@NonNull Set contexts, @NonNull Subject parent) { return handle().thenApply(handle -> handle.isChildOf( CompatibilityUtil.convertContexts(contexts), this.service.getReferenceFactory().obtain(parent) )).join(); } - @Nonnull @Override - public List getParents() { + public @NonNull List getParents() { return (List) handle().thenApply(handle -> handle.getParents(ImmutableContextSet.empty()).stream() .map(s -> new SubjectProxy(this.service, s)) .collect(ImmutableCollectors.toList())).join(); } - @Nonnull @Override - public List getParents(@Nonnull Set contexts) { + public @NonNull List getParents(@NonNull Set contexts) { return (List) handle().thenApply(handle -> handle.getParents(CompatibilityUtil.convertContexts(contexts)).stream() .map(s -> new SubjectProxy(this.service, s)) .collect(ImmutableCollectors.toList())).join(); } - @Nonnull @Override - public Optional getOption(@Nonnull Set contexts, @Nonnull String key) { + public @NonNull Optional getOption(@NonNull Set contexts, @NonNull String key) { return handle().thenApply(handle -> handle.getOption(CompatibilityUtil.convertContexts(contexts), key)).join(); } - @Nonnull @Override - public Optional getOption(@Nonnull String key) { + public @NonNull Optional getOption(@NonNull String key) { return handle().thenApply(handle -> handle.getOption(ImmutableContextSet.empty(), key)).join(); } @@ -167,9 +158,8 @@ public final class SubjectProxy implements Subject, ProxiedSubject { return this.ref.getSubjectIdentifier(); } - @Nonnull @Override - public Set getActiveContexts() { + public @NonNull Set getActiveContexts() { return CompatibilityUtil.convertContexts(getContextsCache().getContextSet()); } diff --git a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/DescriptionBuilder.java b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/DescriptionBuilder.java index 51594bb2..1c46a5fa 100644 --- a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/DescriptionBuilder.java +++ b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/DescriptionBuilder.java @@ -32,6 +32,8 @@ import me.lucko.luckperms.sponge.service.model.LPPermissionService; import me.lucko.luckperms.sponge.service.model.LPSubject; import me.lucko.luckperms.sponge.service.model.LPSubjectCollection; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.service.permission.PermissionDescription; import org.spongepowered.api.service.permission.PermissionService; @@ -41,46 +43,39 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - public final class DescriptionBuilder implements PermissionDescription.Builder { - @Nonnull private final LPPermissionService service; - @Nonnull private final PluginContainer container; - @Nonnull private final Map roles = new HashMap<>(); - @Nullable private String id = null; - @Nullable private Text description = null; + private final @NonNull LPPermissionService service; + private final @NonNull PluginContainer container; + private final @NonNull Map roles = new HashMap<>(); + private @Nullable String id = null; + private @Nullable Text description = null; public DescriptionBuilder(LPPermissionService service, PluginContainer container) { this.service = Objects.requireNonNull(service, "service"); this.container = Objects.requireNonNull(container, "container"); } - @Nonnull @Override - public PermissionDescription.Builder id(@Nonnull String id) { + public PermissionDescription.@NonNull Builder id(@NonNull String id) { this.id = Objects.requireNonNull(id, "id"); return this; } - @Nonnull @Override - public PermissionDescription.Builder description(@Nullable Text description) { + public PermissionDescription.@NonNull Builder description(@Nullable Text description) { this.description = description; return this; } - @Nonnull @Override - public PermissionDescription.Builder assign(@Nonnull String role, boolean value) { + public PermissionDescription.@NonNull Builder assign(@NonNull String role, boolean value) { Objects.requireNonNull(role, "role"); this.roles.put(role, Tristate.fromBoolean(value)); return this; } - @Nonnull @Override - public PermissionDescription register() throws IllegalStateException { + public @NonNull PermissionDescription register() throws IllegalStateException { if (this.id == null) { throw new IllegalStateException("id cannot be null"); } diff --git a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/PermissionDescriptionProxy.java b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/PermissionDescriptionProxy.java index a1242511..e0997fd3 100644 --- a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/PermissionDescriptionProxy.java +++ b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/PermissionDescriptionProxy.java @@ -29,6 +29,7 @@ import me.lucko.luckperms.common.utils.ImmutableCollectors; import me.lucko.luckperms.sponge.service.model.LPPermissionDescription; import me.lucko.luckperms.sponge.service.model.LPPermissionService; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.service.permission.PermissionDescription; import org.spongepowered.api.service.permission.Subject; @@ -39,8 +40,6 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.CompletableFuture; -import javax.annotation.Nonnull; - public final class PermissionDescriptionProxy implements PermissionDescription { private final LPPermissionService service; private final LPPermissionDescription handle; @@ -50,27 +49,23 @@ public final class PermissionDescriptionProxy implements PermissionDescription { this.handle = handle; } - @Nonnull @Override - public String getId() { + public @NonNull String getId() { return this.handle.getId(); } - @Nonnull @Override - public Optional getDescription() { + public @NonNull Optional getDescription() { return this.handle.getDescription(); } - @Nonnull @Override - public Optional getOwner() { + public @NonNull Optional getOwner() { return this.handle.getOwner(); } - @Nonnull @Override - public Map getAssignedSubjects(@Nonnull String s) { + public @NonNull Map getAssignedSubjects(@NonNull String s) { return this.handle.getAssignedSubjects(s).entrySet().stream() .collect(ImmutableCollectors.toMap( e -> new SubjectProxy(this.service, e.getKey().toReference()), @@ -78,10 +73,9 @@ public final class PermissionDescriptionProxy implements PermissionDescription { )); } - @Nonnull - @SuppressWarnings("unchecked") @Override - public CompletableFuture> findAssignedSubjects(@Nonnull String s) { + @SuppressWarnings("unchecked") + public @NonNull CompletableFuture> findAssignedSubjects(@NonNull String s) { return (CompletableFuture) this.handle.findAssignedSubjects(s); } diff --git a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/PermissionServiceProxy.java b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/PermissionServiceProxy.java index a2526170..098e6306 100644 --- a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/PermissionServiceProxy.java +++ b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/PermissionServiceProxy.java @@ -32,6 +32,7 @@ import me.lucko.luckperms.sponge.service.model.LPPermissionDescription; import me.lucko.luckperms.sponge.service.model.LPPermissionService; import me.lucko.luckperms.sponge.service.model.LPSubjectCollection; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.Sponge; import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.service.context.ContextCalculator; @@ -49,8 +50,6 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.function.Predicate; -import javax.annotation.Nonnull; - public final class PermissionServiceProxy implements PermissionService { private final LPPermissionService handle; @@ -58,38 +57,33 @@ public final class PermissionServiceProxy implements PermissionService { this.handle = handle; } - @Nonnull @Override - public SubjectCollection getUserSubjects() { + public @NonNull SubjectCollection getUserSubjects() { return this.handle.getUserSubjects().sponge(); } - @Nonnull @Override - public SubjectCollection getGroupSubjects() { + public @NonNull SubjectCollection getGroupSubjects() { return this.handle.getGroupSubjects().sponge(); } - @Nonnull @Override - public Subject getDefaults() { + public @NonNull Subject getDefaults() { return this.handle.getRootDefaults().sponge(); } - @Nonnull @Override - public Predicate getIdentifierValidityPredicate() { + public @NonNull Predicate getIdentifierValidityPredicate() { return this.handle.getIdentifierValidityPredicate(); } @Override - public CompletableFuture loadCollection(@Nonnull String s) { + public CompletableFuture loadCollection(@NonNull String s) { return CompletableFuture.completedFuture(this.handle.getCollection(s).sponge()); } - @Nonnull @Override - public Optional getCollection(String s) { + public @NonNull Optional getCollection(String s) { return Optional.ofNullable(this.handle.getLoadedCollections().get(s.toLowerCase())).map(LPSubjectCollection::sponge); } @@ -98,9 +92,8 @@ public final class PermissionServiceProxy implements PermissionService { return CompletableFuture.completedFuture(this.handle.getLoadedCollections().containsKey(s.toLowerCase())); } - @Nonnull @Override - public Map getLoadedCollections() { + public @NonNull Map getLoadedCollections() { return this.handle.getLoadedCollections().entrySet().stream() .collect(ImmutableCollectors.toMap( Map.Entry::getKey, @@ -113,9 +106,8 @@ public final class PermissionServiceProxy implements PermissionService { return CompletableFuture.completedFuture(ImmutableSet.copyOf(this.handle.getLoadedCollections().keySet())); } - @Nonnull @Override - public SubjectReference newSubjectReference(@Nonnull String collectionIdentifier, @Nonnull String subjectIdentifier) { + public @NonNull SubjectReference newSubjectReference(@NonNull String collectionIdentifier, @NonNull String subjectIdentifier) { Objects.requireNonNull(collectionIdentifier, "collectionIdentifier"); Objects.requireNonNull(subjectIdentifier, "subjectIdentifier"); @@ -132,7 +124,7 @@ public final class PermissionServiceProxy implements PermissionService { } @Override - public PermissionDescription.Builder newDescriptionBuilder(@Nonnull Object o) { + public PermissionDescription.Builder newDescriptionBuilder(@NonNull Object o) { Optional container = Sponge.getGame().getPluginManager().fromInstance(o); if (!container.isPresent()) { throw new IllegalArgumentException("Couldn't find a plugin container for " + o.getClass().getSimpleName()); @@ -141,20 +133,18 @@ public final class PermissionServiceProxy implements PermissionService { return new DescriptionBuilder(this.handle, container.get()); } - @Nonnull @Override - public Optional getDescription(@Nonnull String s) { + public @NonNull Optional getDescription(@NonNull String s) { return this.handle.getDescription(s).map(LPPermissionDescription::sponge); } - @Nonnull @Override - public Collection getDescriptions() { + public @NonNull Collection getDescriptions() { return this.handle.getDescriptions().stream().map(LPPermissionDescription::sponge).collect(ImmutableCollectors.toSet()); } @Override - public void registerContextCalculator(@Nonnull ContextCalculator contextCalculator) { + public void registerContextCalculator(@NonNull ContextCalculator contextCalculator) { this.handle.registerContextCalculator(contextCalculator); } diff --git a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectCollectionProxy.java b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectCollectionProxy.java index 09015225..e8de0162 100644 --- a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectCollectionProxy.java +++ b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectCollectionProxy.java @@ -30,6 +30,7 @@ import me.lucko.luckperms.sponge.service.CompatibilityUtil; import me.lucko.luckperms.sponge.service.model.LPSubject; import me.lucko.luckperms.sponge.service.model.LPSubjectCollection; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.service.context.Context; import org.spongepowered.api.service.permission.Subject; import org.spongepowered.api.service.permission.SubjectCollection; @@ -43,8 +44,6 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.function.Predicate; -import javax.annotation.Nonnull; - @SuppressWarnings("unchecked") public final class SubjectCollectionProxy implements SubjectCollection { private final LPSubjectCollection handle; @@ -53,57 +52,48 @@ public final class SubjectCollectionProxy implements SubjectCollection { this.handle = handle; } - @Nonnull @Override - public String getIdentifier() { + public @NonNull String getIdentifier() { return this.handle.getIdentifier(); } - @Nonnull @Override - public Predicate getIdentifierValidityPredicate() { + public @NonNull Predicate getIdentifierValidityPredicate() { return this.handle.getIdentifierValidityPredicate(); } - @Nonnull @Override - public CompletableFuture loadSubject(@Nonnull String s) { + public @NonNull CompletableFuture loadSubject(@NonNull String s) { return this.handle.loadSubject(s).thenApply(LPSubject::sponge); } - @Nonnull @Override - public Optional getSubject(@Nonnull String s) { + public @NonNull Optional getSubject(@NonNull String s) { return this.handle.getSubject(s).map(LPSubject::sponge); } - @Nonnull @Override - public CompletableFuture hasSubject(@Nonnull String s) { + public @NonNull CompletableFuture hasSubject(@NonNull String s) { return this.handle.hasRegistered(s); } - @Nonnull @Override - public CompletableFuture> loadSubjects(@Nonnull Set set) { + public @NonNull CompletableFuture> loadSubjects(@NonNull Set set) { return this.handle.loadSubjects(set).thenApply(subs -> subs.stream().collect(ImmutableCollectors.toMap(LPSubject::getIdentifier, LPSubject::sponge))); } - @Nonnull @Override - public Collection getLoadedSubjects() { + public @NonNull Collection getLoadedSubjects() { return this.handle.getLoadedSubjects().stream().map(LPSubject::sponge).collect(ImmutableCollectors.toSet()); } - @Nonnull @Override - public CompletableFuture> getAllIdentifiers() { + public @NonNull CompletableFuture> getAllIdentifiers() { return (CompletableFuture) this.handle.getAllIdentifiers(); } - @Nonnull @Override - public SubjectReference newSubjectReference(@Nonnull String subjectIdentifier) { + public @NonNull SubjectReference newSubjectReference(@NonNull String subjectIdentifier) { Objects.requireNonNull(subjectIdentifier, "identifier"); if (!this.handle.getIdentifierValidityPredicate().test(subjectIdentifier)) { throw new IllegalArgumentException("Subject identifier '" + subjectIdentifier + "' does not pass the validity predicate"); @@ -112,21 +102,18 @@ public final class SubjectCollectionProxy implements SubjectCollection { return this.handle.getService().getReferenceFactory().obtain(getIdentifier(), subjectIdentifier); } - @Nonnull @Override - public CompletableFuture> getAllWithPermission(@Nonnull String s) { + public @NonNull CompletableFuture> getAllWithPermission(@NonNull String s) { return (CompletableFuture) this.handle.getAllWithPermission(s); } - @Nonnull @Override - public CompletableFuture> getAllWithPermission(@Nonnull Set set, @Nonnull String s) { + public @NonNull CompletableFuture> getAllWithPermission(@NonNull Set set, @NonNull String s) { return (CompletableFuture) this.handle.getAllWithPermission(CompatibilityUtil.convertContexts(set), s); } - @Nonnull @Override - public Map getLoadedWithPermission(@Nonnull String s) { + public @NonNull Map getLoadedWithPermission(@NonNull String s) { return this.handle.getLoadedWithPermission(s).entrySet().stream() .collect(ImmutableCollectors.toMap( sub -> sub.getKey().sponge(), @@ -134,9 +121,8 @@ public final class SubjectCollectionProxy implements SubjectCollection { )); } - @Nonnull @Override - public Map getLoadedWithPermission(@Nonnull Set set, @Nonnull String s) { + public @NonNull Map getLoadedWithPermission(@NonNull Set set, @NonNull String s) { return this.handle.getLoadedWithPermission(CompatibilityUtil.convertContexts(set), s).entrySet().stream() .collect(ImmutableCollectors.toMap( sub -> sub.getKey().sponge(), @@ -144,14 +130,13 @@ public final class SubjectCollectionProxy implements SubjectCollection { )); } - @Nonnull @Override - public Subject getDefaults() { + public @NonNull Subject getDefaults() { return this.handle.getDefaults().sponge(); } @Override - public void suggestUnload(@Nonnull String s) { + public void suggestUnload(@NonNull String s) { // unused by lp } diff --git a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectDataProxy.java b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectDataProxy.java index 6d0f94e7..ee77b330 100644 --- a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectDataProxy.java +++ b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectDataProxy.java @@ -32,6 +32,8 @@ import me.lucko.luckperms.sponge.service.model.LPSubject; import me.lucko.luckperms.sponge.service.model.LPSubjectData; import me.lucko.luckperms.sponge.service.model.LPSubjectReference; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.spongepowered.api.service.context.Context; import org.spongepowered.api.service.permission.SubjectData; import org.spongepowered.api.util.Tristate; @@ -41,9 +43,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - @SuppressWarnings("unchecked") public final class SubjectDataProxy implements SubjectData { private final LPPermissionService service; @@ -62,9 +61,8 @@ public final class SubjectDataProxy implements SubjectData { this.ref.resolveLp().thenApply(LPSubject::getTransientSubjectData); } - @Nonnull @Override - public Map, Map> getAllPermissions() { + public @NonNull Map, Map> getAllPermissions() { return (Map) handle().thenApply(handle -> handle.getAllPermissions().entrySet().stream() .collect(ImmutableCollectors.toMap( e -> CompatibilityUtil.convertContexts(e.getKey()), @@ -72,15 +70,13 @@ public final class SubjectDataProxy implements SubjectData { ))).join(); } - @Nonnull @Override - public Map getPermissions(@Nonnull Set contexts) { + public @NonNull Map getPermissions(@NonNull Set contexts) { return handle().thenApply(handle -> handle.getPermissions(CompatibilityUtil.convertContexts(contexts))).join(); } - @Nonnull @Override - public CompletableFuture setPermission(@Nonnull Set contexts, @Nonnull String permission, @Nonnull Tristate value) { + public @NonNull CompletableFuture setPermission(@NonNull Set contexts, @NonNull String permission, @NonNull Tristate value) { return handle().thenCompose(handle -> handle.setPermission( CompatibilityUtil.convertContexts(contexts), permission, @@ -88,21 +84,18 @@ public final class SubjectDataProxy implements SubjectData { )); } - @Nonnull @Override - public CompletableFuture clearPermissions() { + public @NonNull CompletableFuture clearPermissions() { return handle().thenCompose(LPSubjectData::clearPermissions); } - @Nonnull @Override - public CompletableFuture clearPermissions(@Nonnull Set contexts) { + public @NonNull CompletableFuture clearPermissions(@NonNull Set contexts) { return handle().thenCompose(handle -> handle.clearPermissions(CompatibilityUtil.convertContexts(contexts))); } - @Nonnull @Override - public Map, List> getAllParents() { + public @NonNull Map, List> getAllParents() { return (Map) handle().thenApply(handle -> handle.getAllParents().entrySet().stream() .collect(ImmutableCollectors.toMap( e -> CompatibilityUtil.convertContexts(e.getKey()), @@ -110,39 +103,33 @@ public final class SubjectDataProxy implements SubjectData { ))).join(); } - @Nonnull @Override - public List getParents(@Nonnull Set contexts) { + public @NonNull List getParents(@NonNull Set contexts) { return (List) handle().thenApply(handle -> handle.getParents(CompatibilityUtil.convertContexts(contexts))).join(); } - @Nonnull @Override - public CompletableFuture addParent(@Nonnull Set contexts, @Nonnull org.spongepowered.api.service.permission.SubjectReference ref) { + public @NonNull CompletableFuture addParent(@NonNull Set contexts, org.spongepowered.api.service.permission.@NonNull SubjectReference ref) { return handle().thenCompose(handle -> handle.addParent(CompatibilityUtil.convertContexts(contexts), this.service.getReferenceFactory().obtain(ref))); } - @Nonnull @Override - public CompletableFuture removeParent(@Nonnull Set contexts, @Nonnull org.spongepowered.api.service.permission.SubjectReference ref) { + public @NonNull CompletableFuture removeParent(@NonNull Set contexts, org.spongepowered.api.service.permission.@NonNull SubjectReference ref) { return handle().thenCompose(handle -> handle.removeParent(CompatibilityUtil.convertContexts(contexts), this.service.getReferenceFactory().obtain(ref))); } - @Nonnull @Override - public CompletableFuture clearParents() { + public @NonNull CompletableFuture clearParents() { return handle().thenCompose(LPSubjectData::clearParents); } - @Nonnull @Override - public CompletableFuture clearParents(@Nonnull Set contexts) { + public @NonNull CompletableFuture clearParents(@NonNull Set contexts) { return handle().thenCompose(handle -> handle.clearParents(CompatibilityUtil.convertContexts(contexts))); } - @Nonnull @Override - public Map, Map> getAllOptions() { + public @NonNull Map, Map> getAllOptions() { return (Map) handle().thenApply(handle -> handle.getAllOptions().entrySet().stream() .collect(ImmutableCollectors.toMap( e -> CompatibilityUtil.convertContexts(e.getKey()), @@ -150,15 +137,13 @@ public final class SubjectDataProxy implements SubjectData { ))).join(); } - @Nonnull @Override - public Map getOptions(@Nonnull Set contexts) { + public @NonNull Map getOptions(@NonNull Set contexts) { return handle().thenApply(handle -> handle.getOptions(CompatibilityUtil.convertContexts(contexts))).join(); } - @Nonnull @Override - public CompletableFuture setOption(@Nonnull Set contexts, @Nonnull String key, @Nullable String value) { + public @NonNull CompletableFuture setOption(@NonNull Set contexts, @NonNull String key, @Nullable String value) { if (value == null) { return handle().thenCompose(handle -> handle.unsetOption(CompatibilityUtil.convertContexts(contexts), key)); } else { @@ -166,15 +151,13 @@ public final class SubjectDataProxy implements SubjectData { } } - @Nonnull @Override - public CompletableFuture clearOptions() { + public @NonNull CompletableFuture clearOptions() { return handle().thenCompose(LPSubjectData::clearOptions); } - @Nonnull @Override - public CompletableFuture clearOptions(@Nonnull Set contexts) { + public @NonNull CompletableFuture clearOptions(@NonNull Set contexts) { return handle().thenCompose(handle -> handle.clearOptions(CompatibilityUtil.convertContexts(contexts))); } diff --git a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectProxy.java b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectProxy.java index f62a46ba..576d3a7d 100644 --- a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectProxy.java +++ b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectProxy.java @@ -34,6 +34,7 @@ import me.lucko.luckperms.sponge.service.model.LPSubject; import me.lucko.luckperms.sponge.service.model.LPSubjectReference; import me.lucko.luckperms.sponge.service.model.ProxiedSubject; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.service.context.Context; import org.spongepowered.api.service.permission.Subject; @@ -47,8 +48,6 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; -import javax.annotation.Nonnull; - @SuppressWarnings("unchecked") public final class SubjectProxy implements Subject, ProxiedSubject { private final LPPermissionService service; @@ -74,21 +73,18 @@ public final class SubjectProxy implements Subject, ProxiedSubject { return this.contextsSupplier; } - @Nonnull @Override - public LPSubjectReference asSubjectReference() { + public @NonNull LPSubjectReference asSubjectReference() { return this.ref; } - @Nonnull @Override - public Optional getCommandSource() { + public @NonNull Optional getCommandSource() { return handle().thenApply(LPSubject::getCommandSource).join(); } - @Nonnull @Override - public SubjectCollection getContainingCollection() { + public @NonNull SubjectCollection getContainingCollection() { return this.service.getCollection(this.ref.getCollectionIdentifier()).sponge(); } @@ -108,52 +104,47 @@ public final class SubjectProxy implements Subject, ProxiedSubject { } @Override - public boolean hasPermission(@Nonnull Set contexts, @Nonnull String permission) { + public boolean hasPermission(@NonNull Set contexts, @NonNull String permission) { return handle().thenApply(handle -> handle.getPermissionValue(CompatibilityUtil.convertContexts(contexts), permission).asBoolean()).join(); } @Override - public boolean hasPermission(@Nonnull String permission) { + public boolean hasPermission(@NonNull String permission) { return handle().thenApply(handle -> handle.getPermissionValue(ImmutableContextSet.empty(), permission).asBoolean()).join(); } - @Nonnull @Override - public Tristate getPermissionValue(@Nonnull Set contexts, @Nonnull String permission) { + public @NonNull Tristate getPermissionValue(@NonNull Set contexts, @NonNull String permission) { return handle().thenApply(handle -> CompatibilityUtil.convertTristate(handle.getPermissionValue(CompatibilityUtil.convertContexts(contexts), permission))).join(); } @Override - public boolean isChildOf(@Nonnull SubjectReference parent) { + public boolean isChildOf(@NonNull SubjectReference parent) { return handle().thenApply(handle -> handle.isChildOf(ImmutableContextSet.empty(), this.service.getReferenceFactory().obtain(parent))).join(); } @Override - public boolean isChildOf(@Nonnull Set contexts, @Nonnull SubjectReference parent) { + public boolean isChildOf(@NonNull Set contexts, @NonNull SubjectReference parent) { return handle().thenApply(handle -> handle.isChildOf(CompatibilityUtil.convertContexts(contexts), this.service.getReferenceFactory().obtain(parent))).join(); } - @Nonnull @Override - public List getParents() { + public @NonNull List getParents() { return (List) handle().thenApply(handle -> handle.getParents(ImmutableContextSet.empty())).join(); } - @Nonnull @Override - public List getParents(@Nonnull Set contexts) { + public @NonNull List getParents(@NonNull Set contexts) { return (List) handle().thenApply(handle -> handle.getParents(CompatibilityUtil.convertContexts(contexts))).join(); } - @Nonnull @Override - public Optional getOption(@Nonnull Set contexts, @Nonnull String key) { + public @NonNull Optional getOption(@NonNull Set contexts, @NonNull String key) { return handle().thenApply(handle -> handle.getOption(CompatibilityUtil.convertContexts(contexts), key)).join(); } - @Nonnull @Override - public Optional getOption(@Nonnull String key) { + public @NonNull Optional getOption(@NonNull String key) { return handle().thenApply(handle -> handle.getOption(ImmutableContextSet.empty(), key)).join(); } @@ -162,15 +153,13 @@ public final class SubjectProxy implements Subject, ProxiedSubject { return this.ref.getSubjectIdentifier(); } - @Nonnull @Override - public Optional getFriendlyIdentifier() { + public @NonNull Optional getFriendlyIdentifier() { return handle().thenApply(LPSubject::getFriendlyIdentifier).join(); } - @Nonnull @Override - public Set getActiveContexts() { + public @NonNull Set getActiveContexts() { return CompatibilityUtil.convertContexts(getContextsCache().getContextSet()); } diff --git a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingImmutableContextSet.java b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingImmutableContextSet.java index 1c2cfde3..00b284c5 100644 --- a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingImmutableContextSet.java +++ b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingImmutableContextSet.java @@ -27,14 +27,13 @@ package me.lucko.luckperms.sponge.service.context; import me.lucko.luckperms.api.context.ImmutableContextSet; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.service.context.Context; import java.util.Iterator; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; - /** * Implements a {@link Set} of {@link Context}s, delegating all calls to a {@link ImmutableContextSet}. */ @@ -50,9 +49,8 @@ public class DelegatingImmutableContextSet extends AbstractDelegatingContextSet return this.delegate; } - @Nonnull @Override - public Iterator iterator() { + public @NonNull Iterator iterator() { return new ContextSetIterator(); } diff --git a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingMutableContextSet.java b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingMutableContextSet.java index 56126ae7..cfff1d0b 100644 --- a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingMutableContextSet.java +++ b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingMutableContextSet.java @@ -27,14 +27,13 @@ package me.lucko.luckperms.sponge.service.context; import me.lucko.luckperms.api.context.MutableContextSet; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.service.context.Context; import java.util.Iterator; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; - /** * Implements a {@link Set} of {@link Context}s, delegating all calls to a {@link MutableContextSet}. */ @@ -50,9 +49,8 @@ public class DelegatingMutableContextSet extends AbstractDelegatingContextSet { return this.delegate; } - @Nonnull @Override - public Iterator iterator() { + public @NonNull Iterator iterator() { return new ContextSetIterator(); } diff --git a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/model/LPSubjectReference.java b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/model/LPSubjectReference.java index 7ea7ce67..cfc0904f 100644 --- a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/model/LPSubjectReference.java +++ b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/model/LPSubjectReference.java @@ -25,18 +25,17 @@ package me.lucko.luckperms.sponge.service.model; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.service.permission.SubjectReference; import java.util.concurrent.CompletableFuture; -import javax.annotation.Nonnull; - /** * LuckPerms model for the Sponge {@link SubjectReference} */ public interface LPSubjectReference extends SubjectReference { - @Nonnull + @NonNull CompletableFuture resolveLp(); } diff --git a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/model/ProxiedSubject.java b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/model/ProxiedSubject.java index ae8d50b9..09e99693 100644 --- a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/model/ProxiedSubject.java +++ b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/model/ProxiedSubject.java @@ -27,16 +27,15 @@ package me.lucko.luckperms.sponge.service.model; import me.lucko.luckperms.api.context.ImmutableContextSet; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.service.permission.Subject; -import javax.annotation.Nonnull; - /** * Marks that an object is a proxied representation of a {@link Subject}. */ public interface ProxiedSubject { - @Nonnull + @NonNull LPSubjectReference asSubjectReference(); ImmutableContextSet getActiveContextSet(); diff --git a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/reference/CachedSubjectReference.java b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/reference/CachedSubjectReference.java index e7b4c3f4..eb134dc1 100644 --- a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/reference/CachedSubjectReference.java +++ b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/reference/CachedSubjectReference.java @@ -29,6 +29,7 @@ import me.lucko.luckperms.sponge.service.model.LPPermissionService; import me.lucko.luckperms.sponge.service.model.LPSubject; import me.lucko.luckperms.sponge.service.model.LPSubjectReference; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.service.permission.Subject; import java.lang.ref.WeakReference; @@ -36,8 +37,6 @@ import java.util.Objects; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; - /** * Represents a reference to a given Subject. * @@ -59,14 +58,12 @@ final class CachedSubjectReference implements LPSubjectReference { /** * The identifier of the collection which holds the subject */ - @Nonnull - private final String collectionIdentifier; + private final @NonNull String collectionIdentifier; /** * The identifier of the subject */ - @Nonnull - private final String subjectIdentifier; + private final @NonNull String subjectIdentifier; // cache private long lastLookup = 0L; @@ -78,15 +75,13 @@ final class CachedSubjectReference implements LPSubjectReference { this.subjectIdentifier = Objects.requireNonNull(subjectIdentifier); } - @Nonnull @Override - public String getCollectionIdentifier() { + public @NonNull String getCollectionIdentifier() { return this.collectionIdentifier; } - @Nonnull @Override - public String getSubjectIdentifier() { + public @NonNull String getSubjectIdentifier() { return this.subjectIdentifier; } @@ -134,9 +129,8 @@ final class CachedSubjectReference implements LPSubjectReference { return s; } - @Nonnull @Override - public CompletableFuture resolveLp() { + public @NonNull CompletableFuture resolveLp() { // check if there is a cached value before loading LPSubject s = tryCache(); if (s != null) { @@ -147,9 +141,8 @@ final class CachedSubjectReference implements LPSubjectReference { return CompletableFuture.supplyAsync(this::resolveDirectly); } - @Nonnull @Override - public CompletableFuture resolve() { + public @NonNull CompletableFuture resolve() { // check if there is a cached value before loading LPSubject s = tryCache(); if (s != null) { diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeCommandExecutor.java b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeCommandExecutor.java index 1d118402..5b82f8eb 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeCommandExecutor.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeCommandExecutor.java @@ -30,6 +30,8 @@ import com.google.common.base.Splitter; import me.lucko.luckperms.common.command.CommandManager; import me.lucko.luckperms.common.sender.Sender; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.spongepowered.api.command.CommandCallable; import org.spongepowered.api.command.CommandResult; import org.spongepowered.api.command.CommandSource; @@ -43,9 +45,6 @@ import java.util.List; import java.util.ListIterator; import java.util.Optional; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - public class SpongeCommandExecutor extends CommandManager implements CommandCallable { private static final Splitter TAB_COMPLETE_ARGUMENT_SPLITTER = Splitter.on(COMMAND_SEPARATOR_PATTERN); private static final Splitter ARGUMENT_SPLITTER = Splitter.on(COMMAND_SEPARATOR_PATTERN).omitEmptyStrings(); @@ -57,9 +56,8 @@ public class SpongeCommandExecutor extends CommandManager implements CommandCall this.plugin = plugin; } - @Nonnull @Override - public CommandResult process(@Nonnull CommandSource source, @Nonnull String s) { + public @NonNull CommandResult process(@NonNull CommandSource source, @NonNull String s) { Sender lpSender = this.plugin.getSenderFactory().wrap(source); List arguments = processSelectors(source, CommandManager.stripQuotes(ARGUMENT_SPLITTER.splitToList(s))); @@ -67,9 +65,8 @@ public class SpongeCommandExecutor extends CommandManager implements CommandCall return CommandResult.success(); } - @Nonnull @Override - public List getSuggestions(@Nonnull CommandSource source, @Nonnull String s, @Nullable Location location) { + public @NonNull List getSuggestions(@NonNull CommandSource source, @NonNull String s, @Nullable Location location) { Sender lpSender = this.plugin.getSenderFactory().wrap(source); List arguments = processSelectors(source, CommandManager.stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(s))); @@ -77,25 +74,22 @@ public class SpongeCommandExecutor extends CommandManager implements CommandCall } @Override - public boolean testPermission(@Nonnull CommandSource source) { + public boolean testPermission(@NonNull CommandSource source) { return true; // we run permission checks internally } - @Nonnull @Override - public Optional getShortDescription(@Nonnull CommandSource source) { + public @NonNull Optional getShortDescription(@NonNull CommandSource source) { return Optional.of(Text.of("Manage permissions")); } - @Nonnull @Override - public Optional getHelp(@Nonnull CommandSource source) { + public @NonNull Optional getHelp(@NonNull CommandSource source) { return Optional.of(Text.of("Run /luckperms to view usage.")); } - @Nonnull @Override - public Text getUsage(@Nonnull CommandSource source) { + public @NonNull Text getUsage(@NonNull CommandSource source) { return Text.of("/luckperms"); } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeMainCommand.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeMainCommand.java index 1a512c0f..85e7bec6 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeMainCommand.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeMainCommand.java @@ -46,6 +46,8 @@ import me.lucko.luckperms.sponge.service.model.LPSubject; import me.lucko.luckperms.sponge.service.model.LPSubjectCollection; import me.lucko.luckperms.sponge.service.model.LPSubjectData; +import org.checkerframework.checker.nullness.qual.NonNull; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -53,8 +55,6 @@ import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; -import javax.annotation.Nonnull; - public class SpongeMainCommand extends Command { private final LPSpongePlugin plugin; @@ -227,9 +227,8 @@ public class SpongeMainCommand extends Command { return this.subCommands.values().stream().flatMap(List::stream).collect(ImmutableCollectors.toList()); } - @Nonnull @Override - public Optional>> getChildren() { + public @NonNull Optional>> getChildren() { return Optional.of(getSubCommands()); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/contexts/SpongeContextManager.java b/sponge/src/main/java/me/lucko/luckperms/sponge/contexts/SpongeContextManager.java index 806488f1..f1f69e31 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/contexts/SpongeContextManager.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/contexts/SpongeContextManager.java @@ -55,7 +55,7 @@ public class SpongeContextManager extends ContextManager { throw new NullPointerException("subject"); } - return subjectCaches.get(subject); + return this.subjectCaches.get(subject); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/contexts/SpongeProxiedContextCalculator.java b/sponge/src/main/java/me/lucko/luckperms/sponge/contexts/SpongeProxiedContextCalculator.java index c4181ad4..73daf291 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/contexts/SpongeProxiedContextCalculator.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/contexts/SpongeProxiedContextCalculator.java @@ -29,14 +29,13 @@ import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.contexts.ProxiedContextCalculator; import me.lucko.luckperms.sponge.service.context.DelegatingMutableContextSet; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.service.context.Context; import org.spongepowered.api.service.context.ContextCalculator; import org.spongepowered.api.service.permission.Subject; import java.util.Set; -import javax.annotation.Nonnull; - public class SpongeProxiedContextCalculator implements ProxiedContextCalculator { private final ContextCalculator delegate; @@ -44,9 +43,8 @@ public class SpongeProxiedContextCalculator implements ProxiedContextCalculator< this.delegate = delegate; } - @Nonnull @Override - public MutableContextSet giveApplicableContext(@Nonnull Subject subject, @Nonnull MutableContextSet accumulator) { + public @NonNull MutableContextSet giveApplicableContext(@NonNull Subject subject, @NonNull MutableContextSet accumulator) { Set contexts = new DelegatingMutableContextSet(accumulator); this.delegate.accumulateContexts(subject, contexts); return accumulator; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/contexts/WorldCalculator.java b/sponge/src/main/java/me/lucko/luckperms/sponge/contexts/WorldCalculator.java index 6c6e9623..d2e41c54 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/contexts/WorldCalculator.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/contexts/WorldCalculator.java @@ -31,12 +31,11 @@ import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.service.permission.Subject; -import javax.annotation.Nonnull; - public class WorldCalculator implements ContextCalculator { private final LuckPermsPlugin plugin; @@ -44,9 +43,8 @@ public class WorldCalculator implements ContextCalculator { this.plugin = plugin; } - @Nonnull @Override - public MutableContextSet giveApplicableContext(@Nonnull Subject subject, @Nonnull MutableContextSet accumulator) { + public @NonNull MutableContextSet giveApplicableContext(@NonNull Subject subject, @NonNull MutableContextSet accumulator) { CommandSource source = subject.getCommandSource().orElse(null); if (source == null || !(source instanceof Player)) { return accumulator; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/messaging/PluginMessageMessenger.java b/sponge/src/main/java/me/lucko/luckperms/sponge/messaging/PluginMessageMessenger.java index d1d15d6e..2567b399 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/messaging/PluginMessageMessenger.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/messaging/PluginMessageMessenger.java @@ -32,6 +32,7 @@ import me.lucko.luckperms.api.messenger.Messenger; import me.lucko.luckperms.api.messenger.message.OutgoingMessage; import me.lucko.luckperms.sponge.LPSpongePlugin; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.Platform; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.network.ChannelBinding; @@ -42,8 +43,6 @@ import org.spongepowered.api.network.RemoteConnection; import java.util.Collection; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; - /** * An implementation of {@link Messenger} using the plugin messaging channels. */ @@ -73,7 +72,7 @@ public class PluginMessageMessenger implements Messenger, RawDataListener { } @Override - public void sendOutgoingMessage(@Nonnull OutgoingMessage outgoingMessage) { + public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) { this.plugin.getBootstrap().getSpongeScheduler().createTaskBuilder().interval(10, TimeUnit.SECONDS).execute(task -> { if (!this.plugin.getBootstrap().getGame().isServerAvailable()) { return; @@ -91,7 +90,7 @@ public class PluginMessageMessenger implements Messenger, RawDataListener { } @Override - public void handlePayload(@Nonnull ChannelBuf buf, @Nonnull RemoteConnection connection, @Nonnull Platform.Type type) { + public void handlePayload(@NonNull ChannelBuf buf, @NonNull RemoteConnection connection, Platform.@NonNull Type type) { String msg = buf.readUTF(); this.consumer.consumeIncomingMessageAsString(msg); } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/messaging/SpongeMessagingFactory.java b/sponge/src/main/java/me/lucko/luckperms/sponge/messaging/SpongeMessagingFactory.java index 514d6fbd..12681a3b 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/messaging/SpongeMessagingFactory.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/messaging/SpongeMessagingFactory.java @@ -33,7 +33,7 @@ import me.lucko.luckperms.common.messaging.LuckPermsMessagingService; import me.lucko.luckperms.common.messaging.MessagingFactory; import me.lucko.luckperms.sponge.LPSpongePlugin; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; public class SpongeMessagingFactory extends MessagingFactory { public SpongeMessagingFactory(LPSpongePlugin plugin) { @@ -55,15 +55,13 @@ public class SpongeMessagingFactory extends MessagingFactory { private class PluginMessageMessengerProvider implements MessengerProvider { - @Nonnull @Override - public String getName() { + public @NonNull String getName() { return "PluginMessage"; } - @Nonnull @Override - public Messenger obtain(@Nonnull IncomingMessageConsumer incomingMessageConsumer) { + public @NonNull Messenger obtain(@NonNull IncomingMessageConsumer incomingMessageConsumer) { PluginMessageMessenger messenger = new PluginMessageMessenger(getPlugin(), incomingMessageConsumer); messenger.init(); return messenger; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/event/LPSubjectDataUpdateEvent.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/event/LPSubjectDataUpdateEvent.java index 3734c9b4..e7fc9b0c 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/event/LPSubjectDataUpdateEvent.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/event/LPSubjectDataUpdateEvent.java @@ -28,6 +28,7 @@ package me.lucko.luckperms.sponge.service.event; import me.lucko.luckperms.sponge.LPSpongePlugin; import me.lucko.luckperms.sponge.service.model.LPSubjectData; +import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.event.cause.Cause; import org.spongepowered.api.event.cause.EventContext; import org.spongepowered.api.event.cause.EventContextKeys; @@ -35,8 +36,6 @@ import org.spongepowered.api.event.impl.AbstractEvent; import org.spongepowered.api.event.permission.SubjectDataUpdateEvent; import org.spongepowered.api.service.permission.SubjectData; -import javax.annotation.Nonnull; - public class LPSubjectDataUpdateEvent extends AbstractEvent implements SubjectDataUpdateEvent { private final LPSpongePlugin plugin; private final LPSubjectData subjectData; @@ -55,9 +54,8 @@ public class LPSubjectDataUpdateEvent extends AbstractEvent implements SubjectDa return this.subjectData; } - @Nonnull @Override - public Cause getCause() { + public @NonNull Cause getCause() { EventContext eventContext = EventContext.builder() .add(EventContextKeys.PLUGIN, this.plugin.getBootstrap().getPluginContainer()) .build(); diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/misc/SimplePermissionDescription.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/misc/SimplePermissionDescription.java index c38bbad3..9350dd1f 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/misc/SimplePermissionDescription.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/misc/SimplePermissionDescription.java @@ -32,6 +32,7 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectCollection; import me.lucko.luckperms.sponge.service.model.LPSubjectReference; import me.lucko.luckperms.sponge.service.proxy.ProxyFactory; +import org.checkerframework.checker.nullness.qual.Nullable; import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.service.permission.PermissionDescription; import org.spongepowered.api.text.Text; @@ -41,14 +42,12 @@ import java.util.Objects; import java.util.Optional; import java.util.concurrent.CompletableFuture; -import javax.annotation.Nullable; - public final class SimplePermissionDescription implements LPPermissionDescription { private final LPPermissionService service; private final String id; - @Nullable private final Text description; - @Nullable private final PluginContainer owner; + private final @Nullable Text description; + private final @Nullable PluginContainer owner; private PermissionDescription spongeProxy = null; diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/VelocityClassLoader.java b/velocity/src/main/java/me/lucko/luckperms/velocity/VelocityClassLoader.java index 9bc164bd..3ef4b6a9 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/VelocityClassLoader.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/VelocityClassLoader.java @@ -38,6 +38,6 @@ public class VelocityClassLoader implements PluginClassLoader { @Override public void loadJar(Path file) { - this.bootstrap.getProxy().getPluginManager().addToClasspath(bootstrap, file); + this.bootstrap.getProxy().getPluginManager().addToClasspath(this.bootstrap, file); } } diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/contexts/BackendServerCalculator.java b/velocity/src/main/java/me/lucko/luckperms/velocity/contexts/BackendServerCalculator.java index ff1b1984..ac523eac 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/contexts/BackendServerCalculator.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/contexts/BackendServerCalculator.java @@ -33,7 +33,7 @@ import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; public class BackendServerCalculator implements ContextCalculator { @@ -47,9 +47,8 @@ public class BackendServerCalculator implements ContextCalculator { this.plugin = plugin; } - @Nonnull @Override - public MutableContextSet giveApplicableContext(@Nonnull Player subject, @Nonnull MutableContextSet accumulator) { + public @NonNull MutableContextSet giveApplicableContext(@NonNull Player subject, @NonNull MutableContextSet accumulator) { String server = getServer(subject); while (server != null && !accumulator.has(Contexts.WORLD_KEY, server)) { accumulator.add(Contexts.WORLD_KEY, server); diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/contexts/VelocityContextManager.java b/velocity/src/main/java/me/lucko/luckperms/velocity/contexts/VelocityContextManager.java index f88df831..22616895 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/contexts/VelocityContextManager.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/contexts/VelocityContextManager.java @@ -54,7 +54,7 @@ public class VelocityContextManager extends ContextManager { throw new NullPointerException("subject"); } - return subjectCaches.get(subject); + return this.subjectCaches.get(subject); } @Override diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/messaging/PluginMessageMessenger.java b/velocity/src/main/java/me/lucko/luckperms/velocity/messaging/PluginMessageMessenger.java index 4e2f16ed..b2cdc093 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/messaging/PluginMessageMessenger.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/messaging/PluginMessageMessenger.java @@ -41,9 +41,9 @@ import me.lucko.luckperms.api.messenger.Messenger; import me.lucko.luckperms.api.messenger.message.OutgoingMessage; import me.lucko.luckperms.velocity.LPVelocityPlugin; -import java.util.Optional; +import org.checkerframework.checker.nullness.qual.NonNull; -import javax.annotation.Nonnull; +import java.util.Optional; /** * An implementation of {@link Messenger} using the plugin messaging channels. @@ -81,7 +81,7 @@ public class PluginMessageMessenger implements Messenger, MessageHandler { } @Override - public void sendOutgoingMessage(@Nonnull OutgoingMessage outgoingMessage) { + public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF(outgoingMessage.asEncodedString()); diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/messaging/VelocityMessagingFactory.java b/velocity/src/main/java/me/lucko/luckperms/velocity/messaging/VelocityMessagingFactory.java index 7f5ae5b0..cabc06db 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/messaging/VelocityMessagingFactory.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/messaging/VelocityMessagingFactory.java @@ -33,7 +33,7 @@ import me.lucko.luckperms.common.messaging.LuckPermsMessagingService; import me.lucko.luckperms.common.messaging.MessagingFactory; import me.lucko.luckperms.velocity.LPVelocityPlugin; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; public class VelocityMessagingFactory extends MessagingFactory { public VelocityMessagingFactory(LPVelocityPlugin plugin) { @@ -55,15 +55,13 @@ public class VelocityMessagingFactory extends MessagingFactory private class PluginMessageMessengerProvider implements MessengerProvider { - @Nonnull @Override - public String getName() { + public @NonNull String getName() { return "PluginMessage"; } - @Nonnull @Override - public Messenger obtain(@Nonnull IncomingMessageConsumer incomingMessageConsumer) { + public @NonNull Messenger obtain(@NonNull IncomingMessageConsumer incomingMessageConsumer) { PluginMessageMessenger messenger = new PluginMessageMessenger(getPlugin(), incomingMessageConsumer); messenger.init(); return messenger;