getGroups();
/**
@@ -66,7 +71,8 @@ public interface Track {
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
- String getNext(Group current) throws ObjectLacksException;
+ @Nullable
+ String getNext(@Nonnull Group current) throws ObjectLacksException;
/**
* Gets the previous group on the track, before the one provided
@@ -77,7 +83,8 @@ public interface Track {
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
- String getPrevious(Group current) throws ObjectLacksException;
+ @Nullable
+ String getPrevious(@Nonnull Group current) throws ObjectLacksException;
/**
* Appends a group to the end of this track
@@ -87,7 +94,7 @@ public interface Track {
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
- void appendGroup(Group group) throws ObjectAlreadyHasException;
+ void appendGroup(@Nonnull Group group) throws ObjectAlreadyHasException;
/**
* Inserts a group at a certain position on this track
@@ -99,7 +106,7 @@ public interface Track {
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
- void insertGroup(Group group, int position) throws ObjectAlreadyHasException, IndexOutOfBoundsException;
+ void insertGroup(@Nonnull Group group, int position) throws ObjectAlreadyHasException, IndexOutOfBoundsException;
/**
* Removes a group from this track
@@ -109,7 +116,7 @@ public interface Track {
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
- void removeGroup(Group group) throws ObjectLacksException;
+ void removeGroup(@Nonnull Group group) throws ObjectLacksException;
/**
* Removes a group from this track
@@ -118,7 +125,7 @@ public interface Track {
* @throws ObjectLacksException if the group is not on this track
* @throws NullPointerException if the group is null
*/
- void removeGroup(String group) throws ObjectLacksException;
+ void removeGroup(@Nonnull String group) throws ObjectLacksException;
/**
* Checks if a group features on this track
@@ -128,7 +135,7 @@ public interface Track {
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
- boolean containsGroup(Group group);
+ boolean containsGroup(@Nonnull Group group);
/**
* Checks if a group features on this track
@@ -137,7 +144,7 @@ public interface Track {
* @return true if the group is on this track
* @throws NullPointerException if the group is null
*/
- boolean containsGroup(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 5fa100b22..587b1c5ef 100644
--- a/api/src/main/java/me/lucko/luckperms/api/Tristate.java
+++ b/api/src/main/java/me/lucko/luckperms/api/Tristate.java
@@ -25,6 +25,8 @@
package me.lucko.luckperms.api;
+import javax.annotation.Nonnull;
+
/**
* Represents a permission setting.
*
@@ -54,6 +56,7 @@ public enum Tristate {
* @param b the boolean
* @return {@link #TRUE} or {@link #FALSE}, depending on the value of the boolean.
*/
+ @Nonnull
public static Tristate fromBoolean(boolean b) {
return b ? 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 c61b66cea..d87ba0c20 100644
--- a/api/src/main/java/me/lucko/luckperms/api/User.java
+++ b/api/src/main/java/me/lucko/luckperms/api/User.java
@@ -34,6 +34,9 @@ import java.util.List;
import java.util.Optional;
import java.util.UUID;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
/**
* A player holding permission data
*/
@@ -44,6 +47,7 @@ public interface User extends PermissionHolder {
*
* @return the users Mojang assigned unique id
*/
+ @Nonnull
UUID getUuid();
/**
@@ -51,16 +55,18 @@ public interface User extends PermissionHolder {
*
* @return the users username
*/
+ @Nullable
String getName();
/**
- * Gets the users current primary group.
+ * Gets the users current primary group.
*
* The result of this method depends on which method is configured for primary group calculation. It may not
* be the same as any value set through {@link #setPrimaryGroup(String)}.
*
* @return the users primary group
*/
+ @Nonnull
String getPrimaryGroup();
/**
@@ -71,7 +77,7 @@ public interface User extends PermissionHolder {
* @throws IllegalStateException if the user is not a member of that group
* @throws NullPointerException if the group is null
*/
- void setPrimaryGroup(String group) throws ObjectAlreadyHasException;
+ void setPrimaryGroup(@Nonnull String group) throws ObjectAlreadyHasException;
/**
* Refresh and re-assign the users permissions.
@@ -87,6 +93,7 @@ public interface User extends PermissionHolder {
* @return the users cached data.
* @since 3.2
*/
+ @Nonnull
UserData getCachedData();
/**
@@ -97,7 +104,7 @@ public interface User extends PermissionHolder {
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
- boolean isInGroup(Group group);
+ boolean isInGroup(@Nonnull Group group);
/**
* Check to see if the user is a direct member of a group in a specific context
@@ -108,7 +115,7 @@ public interface User extends PermissionHolder {
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @since 3.2
*/
- boolean isInGroup(Group group, ContextSet contextSet);
+ boolean isInGroup(@Nonnull Group group, @Nonnull ContextSet contextSet);
/**
* Gets the user's {@link UserData} cache, if they have one setup.
@@ -118,6 +125,7 @@ public interface User extends PermissionHolder {
* @deprecated in version 3.2, as this cache is now always loaded
*/
@Deprecated
+ @Nonnull
Optional getUserDataCache();
/**
@@ -140,7 +148,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link #isInGroup(Group, ContextSet)}
*/
@Deprecated
- boolean isInGroup(Group group, String server);
+ boolean isInGroup(@Nonnull Group group, @Nonnull String server);
/**
* Check to see if a user is a member of a group on a specific server and world
@@ -154,7 +162,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link #isInGroup(Group, ContextSet)}
*/
@Deprecated
- boolean isInGroup(Group group, String server, String world);
+ boolean isInGroup(@Nonnull Group group, @Nonnull String server, @Nonnull String world);
/**
* Add a user to a group
@@ -166,7 +174,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
- void addGroup(Group group) throws ObjectAlreadyHasException;
+ void addGroup(@Nonnull Group group) throws ObjectAlreadyHasException;
/**
* Add a user to a group on a specific server
@@ -180,7 +188,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
- void addGroup(Group group, String server) throws ObjectAlreadyHasException;
+ void addGroup(@Nonnull Group group, @Nonnull String server) throws ObjectAlreadyHasException;
/**
* Add a user to a group on a specific server and world
@@ -195,7 +203,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
- void addGroup(Group group, String server, String world) throws ObjectAlreadyHasException;
+ void addGroup(@Nonnull Group group, @Nonnull String server, @Nonnull String world) throws ObjectAlreadyHasException;
/**
* Add a user to a group temporarily on a specific server
@@ -209,7 +217,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
- void addGroup(Group group, long expireAt) throws ObjectAlreadyHasException;
+ void addGroup(@Nonnull Group group, long expireAt) throws ObjectAlreadyHasException;
/**
* Add a user to a group temporarily on a specific server
@@ -224,7 +232,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
- void addGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException;
+ void addGroup(@Nonnull Group group, @Nonnull String server, long expireAt) throws ObjectAlreadyHasException;
/**
* Add a user to a group temporarily on a specific server and world
@@ -240,7 +248,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
- void addGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException;
+ void addGroup(@Nonnull Group group, @Nonnull String server, @Nonnull String world, long expireAt) throws ObjectAlreadyHasException;
/**
* Remove the user from a group
@@ -252,7 +260,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
- void removeGroup(Group group) throws ObjectLacksException;
+ void removeGroup(@Nonnull Group group) throws ObjectLacksException;
/**
* Remove the user from a group
@@ -265,7 +273,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
- void removeGroup(Group group, boolean temporary) throws ObjectLacksException;
+ void removeGroup(@Nonnull Group group, boolean temporary) throws ObjectLacksException;
/**
* Remove the user from a group on a specific server
@@ -279,7 +287,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
- void removeGroup(Group group, String server) throws ObjectLacksException;
+ void removeGroup(@Nonnull Group group, @Nonnull String server) throws ObjectLacksException;
/**
* Remove the user from a group on a specific server and world
@@ -294,7 +302,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
- void removeGroup(Group group, String server, String world) throws ObjectLacksException;
+ void removeGroup(@Nonnull Group group, @Nonnull String server, @Nonnull String world) throws ObjectLacksException;
/**
* Remove the user from a group on a specific server
@@ -309,7 +317,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
- void removeGroup(Group group, String server, boolean temporary) throws ObjectLacksException;
+ void removeGroup(@Nonnull Group group, @Nonnull String server, boolean temporary) throws ObjectLacksException;
/**
* Remove the user from a group on a specific server and world
@@ -325,7 +333,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
- void removeGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException;
+ void removeGroup(@Nonnull Group group, @Nonnull String server, @Nonnull String world, boolean temporary) throws ObjectLacksException;
/**
* Get a {@link List} of all of the groups the user is a member of, on all servers
@@ -334,6 +342,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of just querying a users permissions
*/
@Deprecated
+ @Nonnull
List getGroupNames();
/**
@@ -347,7 +356,8 @@ public interface User extends PermissionHolder {
* @deprecated in favour of just querying a users permissions
*/
@Deprecated
- List getLocalGroups(String server, String world);
+ @Nonnull
+ List getLocalGroups(@Nonnull String server, @Nonnull String world);
/**
* Get a {@link List} of the groups the user is a member of on a specific server
@@ -359,6 +369,7 @@ public interface User extends PermissionHolder {
* @deprecated in favour of just querying a users permissions
*/
@Deprecated
- List getLocalGroups(String server);
+ @Nonnull
+ List getLocalGroups(@Nonnull String server);
}
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 97f8c450e..d792c517f 100644
--- a/api/src/main/java/me/lucko/luckperms/api/UuidCache.java
+++ b/api/src/main/java/me/lucko/luckperms/api/UuidCache.java
@@ -27,6 +27,8 @@ package me.lucko.luckperms.api;
import java.util.UUID;
+import javax.annotation.Nonnull;
+
/**
* A UUID cache for online users, between external Mojang UUIDs, and internal LuckPerms UUIDs.
*
@@ -48,7 +50,8 @@ public interface UuidCache {
* @param external the UUID assigned by the server, through Player#getUniqueId or ProxiedPlayer#getUniqueId
* @return the corresponding internal UUID
*/
- UUID getUUID(UUID external);
+ @Nonnull
+ UUID getUUID(@Nonnull UUID external);
/**
* Gets a users external, server assigned or Mojang assigned unique id, from the internal one used within LuckPerms.
@@ -56,6 +59,7 @@ public interface UuidCache {
* @param internal the UUID used within LuckPerms, through User#getUuid
* @return the corresponding external UUID
*/
- UUID getExternalUUID(UUID internal);
+ @Nonnull
+ UUID getExternalUUID(@Nonnull UUID internal);
}
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 071fc33ed..baf2f3faf 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
@@ -30,6 +30,8 @@ import com.google.common.base.Preconditions;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
+import javax.annotation.Nonnull;
+
/**
* Represents the context for a meta lookup, consisting of a standard {@link Contexts} element, plus options to define how
* the meta stack should be constructed.
@@ -46,7 +48,7 @@ public final class MetaContexts {
* @param suffixStackDefinition the suffix stack definition to be used
* @return the new instance
*/
- public static MetaContexts of(Contexts contexts, MetaStackDefinition prefixStackDefinition, MetaStackDefinition suffixStackDefinition) {
+ public static MetaContexts of(@Nonnull Contexts contexts, @Nonnull MetaStackDefinition prefixStackDefinition, @Nonnull MetaStackDefinition suffixStackDefinition) {
return new MetaContexts(contexts, prefixStackDefinition, suffixStackDefinition);
}
@@ -61,25 +63,29 @@ public final class MetaContexts {
* @param prefixStackDefinition the prefix stack definition to be used
* @param suffixStackDefinition the suffix stack definition to be used
*/
- public MetaContexts(Contexts contexts, MetaStackDefinition prefixStackDefinition, MetaStackDefinition suffixStackDefinition) {
+ public MetaContexts(@Nonnull Contexts contexts, @Nonnull MetaStackDefinition prefixStackDefinition, @Nonnull MetaStackDefinition suffixStackDefinition) {
this.contexts = Preconditions.checkNotNull(contexts, "contexts");
this.prefixStackDefinition = Preconditions.checkNotNull(prefixStackDefinition, "prefixStackDefinition");
this.suffixStackDefinition = Preconditions.checkNotNull(suffixStackDefinition, "suffixStackDefinition");
}
+ @Nonnull
public Contexts getContexts() {
return this.contexts;
}
+ @Nonnull
public MetaStackDefinition getPrefixStackDefinition() {
return this.prefixStackDefinition;
}
+ @Nonnull
public MetaStackDefinition getSuffixStackDefinition() {
return this.suffixStackDefinition;
}
@Override
+ @Nonnull
public String toString() {
return "MetaContexts(" +
"contexts=" + this.getContexts() + ", " +
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 d31469573..3918e5ef3 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
@@ -32,6 +32,9 @@ import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
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
*
@@ -51,6 +54,7 @@ public interface MetaData {
* @return an immutable multimap of meta
* @since 3.3
*/
+ @Nonnull
ListMultimap getMetaMultimap();
/**
@@ -61,6 +65,7 @@ public interface MetaData {
*
* @return an immutable map of meta
*/
+ @Nonnull
Map getMeta();
/**
@@ -69,6 +74,7 @@ public interface MetaData {
*
* @return a sorted map of prefixes
*/
+ @Nonnull
SortedMap getPrefixes();
/**
@@ -77,6 +83,7 @@ public interface MetaData {
*
* @return a sorted map of suffixes
*/
+ @Nonnull
SortedMap getSuffixes();
/**
@@ -84,6 +91,7 @@ public interface MetaData {
*
* @return a prefix string, or null
*/
+ @Nullable
String getPrefix();
/**
@@ -91,6 +99,7 @@ public interface MetaData {
*
* @return a suffix string, or null
*/
+ @Nullable
String getSuffix();
/**
@@ -99,6 +108,7 @@ public interface MetaData {
* @return the definition used for the prefix stack
* @since 3.2
*/
+ @Nonnull
MetaStackDefinition getPrefixStackDefinition();
/**
@@ -107,6 +117,7 @@ public interface MetaData {
* @return the definition used for the suffix stack
* @since 3.2
*/
+ @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 c481dd13d..6ea53e600 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
@@ -29,6 +29,8 @@ import me.lucko.luckperms.api.Tristate;
import java.util.Map;
+import javax.annotation.Nonnull;
+
/**
* Holds cached Permission lookup data for a specific set of contexts
*
@@ -43,7 +45,8 @@ public interface PermissionData {
* @return a tristate result
* @throws NullPointerException if permission is null
*/
- Tristate getPermissionValue(String permission);
+ @Nonnull
+ Tristate getPermissionValue(@Nonnull String permission);
/**
* Invalidates the underlying permission calculator cache.
@@ -57,6 +60,7 @@ public interface PermissionData {
*
* @return an immutable set of permissions
*/
+ @Nonnull
Map getImmutableBacking();
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/caching/UserData.java b/api/src/main/java/me/lucko/luckperms/api/caching/UserData.java
index 0e679b308..f8bd7f376 100644
--- a/api/src/main/java/me/lucko/luckperms/api/caching/UserData.java
+++ b/api/src/main/java/me/lucko/luckperms/api/caching/UserData.java
@@ -29,6 +29,8 @@ import me.lucko.luckperms.api.Contexts;
import java.util.Set;
+import javax.annotation.Nonnull;
+
/**
* Holds cached permission and meta lookup data for a {@link me.lucko.luckperms.api.User}.
*
@@ -52,7 +54,8 @@ public interface UserData {
* @return a permission data instance
* @throws NullPointerException if contexts is null
*/
- PermissionData getPermissionData(Contexts contexts);
+ @Nonnull
+ PermissionData getPermissionData(@Nonnull Contexts contexts);
/**
* Gets MetaData from the cache, given a specified context.
@@ -64,7 +67,8 @@ public interface UserData {
* @throws NullPointerException if contexts is null
* @since 3.2
*/
- MetaData getMetaData(MetaContexts contexts);
+ @Nonnull
+ MetaData getMetaData(@Nonnull MetaContexts contexts);
/**
* Gets MetaData from the cache, given a specified context.
@@ -75,7 +79,8 @@ public interface UserData {
* @return a meta data instance
* @throws NullPointerException if contexts is null
*/
- MetaData getMetaData(Contexts contexts);
+ @Nonnull
+ MetaData getMetaData(@Nonnull Contexts contexts);
/**
* Calculates permission data, bypassing the cache.
@@ -84,7 +89,8 @@ public interface UserData {
* @return a permission data instance
* @throws NullPointerException if contexts is null
*/
- PermissionData calculatePermissions(Contexts contexts);
+ @Nonnull
+ PermissionData calculatePermissions(@Nonnull Contexts contexts);
/**
* Calculates meta data, bypassing the cache.
@@ -94,7 +100,8 @@ public interface UserData {
* @throws NullPointerException if contexts is null
* @since 3.2
*/
- MetaData calculateMeta(MetaContexts contexts);
+ @Nonnull
+ MetaData calculateMeta(@Nonnull MetaContexts contexts);
/**
* Calculates meta data, bypassing the cache.
@@ -103,7 +110,8 @@ public interface UserData {
* @return a meta data instance
* @throws NullPointerException if contexts is null
*/
- MetaData calculateMeta(Contexts contexts);
+ @Nonnull
+ MetaData calculateMeta(@Nonnull Contexts contexts);
/**
* Calculates permission data and stores it in the cache.
@@ -114,7 +122,7 @@ public interface UserData {
* @param contexts the contexts to recalculate in.
* @throws NullPointerException if contexts is null
*/
- void recalculatePermissions(Contexts contexts);
+ void recalculatePermissions(@Nonnull Contexts contexts);
/**
* Calculates meta data and stores it in the cache.
@@ -126,7 +134,7 @@ public interface UserData {
* @throws NullPointerException if contexts is null
* @since 3.2
*/
- void recalculateMeta(MetaContexts contexts);
+ void recalculateMeta(@Nonnull MetaContexts contexts);
/**
* Calculates meta data and stores it in the cache.
@@ -137,7 +145,7 @@ public interface UserData {
* @param contexts the contexts to recalculate in.
* @throws NullPointerException if contexts is null
*/
- void recalculateMeta(Contexts contexts);
+ void recalculateMeta(@Nonnull Contexts contexts);
/**
* Calls {@link #recalculatePermissions(Contexts)} for all current loaded contexts
@@ -155,7 +163,7 @@ public interface UserData {
* @param contexts a set of contexts
* @throws NullPointerException if contexts is null
*/
- void preCalculate(Set contexts);
+ void preCalculate(@Nonnull Set contexts);
/**
* Ensures that PermissionData and MetaData is cached for a context.
@@ -165,7 +173,7 @@ public interface UserData {
* @param contexts the contexts to pre-calculate for
* @throws NullPointerException if contexts is null
*/
- void preCalculate(Contexts contexts);
+ void preCalculate(@Nonnull Contexts contexts);
/**
* Invalidates all of the underlying Permission calculators.
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 38f74ce10..c3c1ceef9 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,6 +25,8 @@
package me.lucko.luckperms.api.context;
+import javax.annotation.Nonnull;
+
/**
* Calculates whether contexts are applicable to {@link T}
*
@@ -41,6 +43,7 @@ public interface ContextCalculator {
* @return the map
* @since 2.13
*/
- MutableContextSet giveApplicableContext(T subject, MutableContextSet accumulator);
+ @Nonnull
+ MutableContextSet giveApplicableContext(@Nonnull T subject, @Nonnull MutableContextSet accumulator);
}
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 4a832c051..1b8250648 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
@@ -25,12 +25,15 @@
package me.lucko.luckperms.api.context;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Multimap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import javax.annotation.Nonnull;
+
/**
* Holder of contexts.
*
@@ -48,7 +51,8 @@ public interface ContextSet {
* @return a new ImmutableContextSet containing one KV pair
* @throws NullPointerException if key or value is null
*/
- static ImmutableContextSet singleton(String key, String value) {
+ @Nonnull
+ static ImmutableContextSet singleton(@Nonnull String key, @Nonnull String value) {
return ImmutableContextSet.singleton(key, value);
}
@@ -63,7 +67,8 @@ public interface ContextSet {
* @throws NullPointerException if any of the keys or values are null
* @since 3.1
*/
- static ImmutableContextSet of(String key1, String value1, String key2, String value2) {
+ @Nonnull
+ static ImmutableContextSet of(@Nonnull String key1, @Nonnull String value1, @Nonnull String key2, @Nonnull String value2) {
return ImmutableContextSet.of(key1, value1, key2, value2);
}
@@ -74,7 +79,8 @@ public interface ContextSet {
* @return a new ImmutableContextSet representing the pairs from the map
* @throws NullPointerException if the map is null
*/
- static ImmutableContextSet fromMap(Map map) {
+ @Nonnull
+ static ImmutableContextSet fromMap(@Nonnull Map map) {
return ImmutableContextSet.fromMap(map);
}
@@ -85,7 +91,8 @@ public interface ContextSet {
* @return a new ImmutableContextSet representing the pairs in the iterable
* @throws NullPointerException if the iterable is null
*/
- static ImmutableContextSet fromEntries(Iterable extends Map.Entry> iterable) {
+ @Nonnull
+ static ImmutableContextSet fromEntries(@Nonnull Iterable extends Map.Entry> iterable) {
return ImmutableContextSet.fromEntries(iterable);
}
@@ -97,7 +104,8 @@ public interface ContextSet {
* @throws NullPointerException if the multimap is null
* @since 2.16
*/
- static ImmutableContextSet fromMultimap(Multimap multimap) {
+ @Nonnull
+ static ImmutableContextSet fromMultimap(@Nonnull Multimap multimap) {
return ImmutableContextSet.fromMultimap(multimap);
}
@@ -109,7 +117,8 @@ public interface ContextSet {
* @return a new ImmutableContextSet with the same content and the one provided
* @throws NullPointerException if contextSet is null
*/
- static ImmutableContextSet fromSet(ContextSet contextSet) {
+ @Nonnull
+ static ImmutableContextSet fromSet(@Nonnull ContextSet contextSet) {
return ImmutableContextSet.fromSet(contextSet);
}
@@ -118,6 +127,7 @@ public interface ContextSet {
*
* @return a new ImmutableContextSet
*/
+ @Nonnull
static ImmutableContextSet empty() {
return ImmutableContextSet.empty();
}
@@ -134,6 +144,7 @@ public interface ContextSet {
*
* @return an immutable ContextSet
*/
+ @Nonnull
ImmutableContextSet makeImmutable();
/**
@@ -142,6 +153,7 @@ public interface ContextSet {
* @return a mutable ContextSet
* @since 2.16
*/
+ @Nonnull
MutableContextSet mutableCopy();
/**
@@ -149,6 +161,7 @@ public interface ContextSet {
*
* @return an immutable set
*/
+ @Nonnull
Set> toSet();
/**
@@ -159,6 +172,7 @@ public interface ContextSet {
*
* @return an immutable map
*/
+ @Nonnull
Map toMap();
/**
@@ -167,6 +181,7 @@ public interface ContextSet {
* @return a multimap
* @since 2.16
*/
+ @Nonnull
Multimap toMultimap();
/**
@@ -176,7 +191,7 @@ public interface ContextSet {
* @return true if the set contains a value for the key
* @throws NullPointerException if the key is null
*/
- boolean containsKey(String key);
+ boolean containsKey(@Nonnull String key);
/**
* Gets a set of all of the values mapped to the given key
@@ -185,7 +200,8 @@ public interface ContextSet {
* @return a set of values
* @throws NullPointerException if the key is null
*/
- Set getValues(String key);
+ @Nonnull
+ Set getValues(@Nonnull String key);
/**
* Returns any value from this set matching the key, if present.
@@ -194,7 +210,8 @@ public interface ContextSet {
* @return an optional containing any match
* @since 3.1
*/
- default Optional getAnyValue(String key) {
+ @Nonnull
+ default Optional getAnyValue(@Nonnull String key) {
return getValues(key).stream().findAny();
}
@@ -206,7 +223,7 @@ public interface ContextSet {
* @return true if the set contains the KV pair
* @throws NullPointerException if the key or value is null
*/
- boolean has(String key, String value);
+ boolean has(@Nonnull String key, @Nonnull String value);
/**
* Same as {@link #has(String, String)}, except ignores the case of the value.
@@ -216,7 +233,7 @@ public interface ContextSet {
* @return true if the set contains the KV pair
* @throws NullPointerException if the key or value is null
*/
- boolean hasIgnoreCase(String key, String value);
+ boolean hasIgnoreCase(@Nonnull String key, @Nonnull String value);
/**
* Checks to see if all entries in this context set are also included in another set.
@@ -225,7 +242,8 @@ public interface ContextSet {
* @return true if all entries in this set are also in the other set
* @since 3.1
*/
- default boolean isSatisfiedBy(ContextSet other) {
+ default boolean isSatisfiedBy(@Nonnull ContextSet other) {
+ Preconditions.checkNotNull(other, "other");
if (this.isEmpty()) {
// this is empty, so is therefore always satisfied.
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 a86aaad1f..2ce13b72b 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
@@ -25,6 +25,7 @@
package me.lucko.luckperms.api.context;
+import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap;
@@ -35,6 +36,8 @@ import java.util.Collection;
import java.util.Map;
import java.util.Set;
+import javax.annotation.Nonnull;
+
/**
* An immutable implementation of {@link ContextSet}.
*
@@ -51,14 +54,10 @@ public final class ImmutableContextSet implements ContextSet {
* @return a new ImmutableContextSet containing one KV pair
* @throws NullPointerException if key or value is null
*/
- public static ImmutableContextSet singleton(String key, String value) {
- if (key == null) {
- throw new NullPointerException("key");
- }
- if (value == null) {
- throw new NullPointerException("value");
- }
-
+ @Nonnull
+ public static ImmutableContextSet singleton(@Nonnull String key, @Nonnull String value) {
+ Preconditions.checkNotNull(key, "key");
+ Preconditions.checkNotNull(value, "value");
return new ImmutableContextSet(ImmutableSetMultimap.of(key.toLowerCase(), value));
}
@@ -73,20 +72,12 @@ public final class ImmutableContextSet implements ContextSet {
* @throws NullPointerException if any of the keys or values are null
* @since 3.1
*/
- public static ImmutableContextSet of(String key1, String value1, String key2, String value2) {
- if (key1 == null) {
- throw new NullPointerException("key1");
- }
- if (value1 == null) {
- throw new NullPointerException("value1");
- }
- if (key2 == null) {
- throw new NullPointerException("key2");
- }
- if (value2 == null) {
- throw new NullPointerException("value2");
- }
-
+ @Nonnull
+ public static ImmutableContextSet of(@Nonnull String key1, @Nonnull String value1, @Nonnull String key2, @Nonnull String value2) {
+ Preconditions.checkNotNull(key1, "key1");
+ Preconditions.checkNotNull(value1, "value1");
+ Preconditions.checkNotNull(key2, "key2");
+ Preconditions.checkNotNull(value2, "value2");
return new ImmutableContextSet(ImmutableSetMultimap.of(key1.toLowerCase(), value1, key2.toLowerCase(), value2));
}
@@ -97,10 +88,9 @@ public final class ImmutableContextSet implements ContextSet {
* @return a new ImmutableContextSet representing the pairs from the map
* @throws NullPointerException if the map is null
*/
- public static ImmutableContextSet fromMap(Map map) {
- if (map == null) {
- throw new NullPointerException("map");
- }
+ @Nonnull
+ public static ImmutableContextSet fromMap(@Nonnull Map map) {
+ Preconditions.checkNotNull(map, "map");
ImmutableSetMultimap.Builder b = ImmutableSetMultimap.builder();
for (Map.Entry e : map.entrySet()) {
@@ -117,11 +107,9 @@ public final class ImmutableContextSet implements ContextSet {
* @return a new ImmutableContextSet representing the pairs in the iterable
* @throws NullPointerException if the iterable is null
*/
- public static ImmutableContextSet fromEntries(Iterable extends Map.Entry> iterable) {
- if (iterable == null) {
- throw new NullPointerException("iterable");
- }
-
+ @Nonnull
+ public static ImmutableContextSet fromEntries(@Nonnull Iterable extends Map.Entry> iterable) {
+ Preconditions.checkNotNull(iterable, "iterable");
return MutableContextSet.fromEntries(iterable).makeImmutable();
}
@@ -132,11 +120,9 @@ public final class ImmutableContextSet implements ContextSet {
* @return a new ImmutableContextSet representing the pairs in the multimap
* @throws NullPointerException if the multimap is null
*/
- public static ImmutableContextSet fromMultimap(Multimap multimap) {
- if (multimap == null) {
- throw new NullPointerException("multimap");
- }
-
+ @Nonnull
+ public static ImmutableContextSet fromMultimap(@Nonnull Multimap multimap) {
+ Preconditions.checkNotNull(multimap, "multimap");
return MutableContextSet.fromMultimap(multimap).makeImmutable();
}
@@ -148,8 +134,9 @@ public final class ImmutableContextSet implements ContextSet {
* @return a new ImmutableContextSet with the same content and the one provided
* @throws NullPointerException if contextSet is null
*/
- public static ImmutableContextSet fromSet(ContextSet contextSet) {
- return contextSet.makeImmutable();
+ @Nonnull
+ public static ImmutableContextSet fromSet(@Nonnull ContextSet contextSet) {
+ return Preconditions.checkNotNull(contextSet, "contextSet").makeImmutable();
}
/**
@@ -157,6 +144,7 @@ public final class ImmutableContextSet implements ContextSet {
*
* @return a new ContextSet
*/
+ @Nonnull
public static ImmutableContextSet empty() {
return EMPTY;
}
@@ -174,21 +162,25 @@ public final class ImmutableContextSet implements ContextSet {
@Override
@Deprecated // This set is already immutable!
+ @Nonnull
public ImmutableContextSet makeImmutable() {
return this;
}
@Override
+ @Nonnull
public MutableContextSet mutableCopy() {
return MutableContextSet.fromSet(this);
}
@Override
+ @Nonnull
public Set> toSet() {
return ImmutableSet.copyOf(map.entries());
}
@Override
+ @Nonnull
public Map toMap() {
ImmutableMap.Builder m = ImmutableMap.builder();
for (Map.Entry e : map.entries()) {
@@ -199,49 +191,35 @@ public final class ImmutableContextSet implements ContextSet {
}
@Override
+ @Nonnull
public Multimap toMultimap() {
return map;
}
@Override
- public boolean containsKey(String key) {
- if (key == null) {
- throw new NullPointerException("key");
- }
-
+ public boolean containsKey(@Nonnull String key) {
+ Preconditions.checkNotNull(key, "key");
return map.containsKey(key);
}
@Override
- public Set getValues(String key) {
- if (key == null) {
- throw new NullPointerException("key");
- }
-
+ public Set getValues(@Nonnull String key) {
+ Preconditions.checkNotNull(key, "key");
Collection c = map.get(key);
return c != null && !c.isEmpty() ? ImmutableSet.copyOf(c) : ImmutableSet.of();
}
@Override
- public boolean has(String key, String value) {
- if (key == null) {
- throw new NullPointerException("key");
- }
- if (value == null) {
- throw new NullPointerException("value");
- }
-
+ public boolean has(@Nonnull String key, @Nonnull String value) {
+ Preconditions.checkNotNull(key, "key");
+ Preconditions.checkNotNull(value, "value");
return map.containsEntry(key, value);
}
@Override
- public boolean hasIgnoreCase(String key, String value) {
- if (key == null) {
- throw new NullPointerException("key");
- }
- if (value == null) {
- throw new NullPointerException("value");
- }
+ public boolean hasIgnoreCase(@Nonnull String key, @Nonnull String value) {
+ Preconditions.checkNotNull(key, "key");
+ Preconditions.checkNotNull(value, "value");
Collection c = map.get(key);
if (c == null || c.isEmpty()) {
@@ -274,7 +252,7 @@ public final class ImmutableContextSet implements ContextSet {
final Multimap thisContexts = this.toMultimap();
final Multimap otherContexts = other.toMultimap();
- return thisContexts == null ? otherContexts == null : thisContexts.equals(otherContexts);
+ return thisContexts.equals(otherContexts);
}
@Override
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 4f9e7044e..544f56bfb 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
@@ -25,6 +25,7 @@
package me.lucko.luckperms.api.context;
+import com.google.common.base.Preconditions;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -37,6 +38,8 @@ import java.util.Collection;
import java.util.Map;
import java.util.Set;
+import javax.annotation.Nonnull;
+
/**
* A mutable implementation of {@link ContextSet}.
*
@@ -52,14 +55,10 @@ public final class MutableContextSet implements ContextSet {
* @return a new MutableContextSet containing one KV pair
* @throws NullPointerException if key or value is null
*/
- public static MutableContextSet singleton(String key, String value) {
- if (key == null) {
- throw new NullPointerException("key");
- }
- if (value == null) {
- throw new NullPointerException("value");
- }
-
+ @Nonnull
+ public static MutableContextSet singleton(@Nonnull String key, @Nonnull String value) {
+ Preconditions.checkNotNull(key, "key");
+ Preconditions.checkNotNull(value, "value");
MutableContextSet set = new MutableContextSet();
set.add(key, value);
return set;
@@ -76,20 +75,12 @@ public final class MutableContextSet implements ContextSet {
* @throws NullPointerException if any of the keys or values are null
* @since 3.1
*/
- public static MutableContextSet of(String key1, String value1, String key2, String value2) {
- if (key1 == null) {
- throw new NullPointerException("key1");
- }
- if (value1 == null) {
- throw new NullPointerException("value1");
- }
- if (key2 == null) {
- throw new NullPointerException("key2");
- }
- if (value2 == null) {
- throw new NullPointerException("value2");
- }
-
+ @Nonnull
+ public static MutableContextSet of(@Nonnull String key1, @Nonnull String value1, @Nonnull String key2, @Nonnull String value2) {
+ Preconditions.checkNotNull(key1, "key1");
+ Preconditions.checkNotNull(value1, "value1");
+ Preconditions.checkNotNull(key2, "key2");
+ Preconditions.checkNotNull(value2, "value2");
MutableContextSet ret = singleton(key1, value1);
ret.add(key2, value2);
return ret;
@@ -102,11 +93,9 @@ public final class MutableContextSet implements ContextSet {
* @return a new MutableContextSet representing the pairs from the map
* @throws NullPointerException if the map is null
*/
- public static MutableContextSet fromMap(Map map) {
- if (map == null) {
- throw new NullPointerException("map");
- }
-
+ @Nonnull
+ public static MutableContextSet fromMap(@Nonnull Map map) {
+ Preconditions.checkNotNull(map, "map");
MutableContextSet set = new MutableContextSet();
set.addAll(map);
return set;
@@ -119,11 +108,9 @@ public final class MutableContextSet implements ContextSet {
* @return a new MutableContextSet representing the pairs in the iterable
* @throws NullPointerException if the iterable is null
*/
- public static MutableContextSet fromEntries(Iterable extends Map.Entry> iterable) {
- if (iterable == null) {
- throw new NullPointerException("iterable");
- }
-
+ @Nonnull
+ public static MutableContextSet fromEntries(@Nonnull Iterable extends Map.Entry> iterable) {
+ Preconditions.checkNotNull(iterable, "iterable");
MutableContextSet set = new MutableContextSet();
set.addAll(iterable);
return set;
@@ -136,11 +123,9 @@ public final class MutableContextSet implements ContextSet {
* @return a new MutableContextSet representing the pairs in the multimap
* @throws NullPointerException if the multimap is null
*/
- public static MutableContextSet fromMultimap(Multimap multimap) {
- if (multimap == null) {
- throw new NullPointerException("multimap");
- }
-
+ @Nonnull
+ public static MutableContextSet fromMultimap(@Nonnull Multimap multimap) {
+ Preconditions.checkNotNull(multimap, "multimap");
return fromEntries(multimap.entries());
}
@@ -152,11 +137,9 @@ public final class MutableContextSet implements ContextSet {
* @return a new MutableContextSet with the same content and the one provided
* @throws NullPointerException if contextSet is null
*/
- public static MutableContextSet fromSet(ContextSet contextSet) {
- if (contextSet == null) {
- throw new NullPointerException("contextSet");
- }
-
+ @Nonnull
+ public static MutableContextSet fromSet(@Nonnull ContextSet contextSet) {
+ Preconditions.checkNotNull(contextSet, "contextSet");
MutableContextSet set = new MutableContextSet();
set.addAll(contextSet.toSet());
return set;
@@ -167,6 +150,7 @@ public final class MutableContextSet implements ContextSet {
*
* @return a new MutableContextSet
*/
+ @Nonnull
public static MutableContextSet create() {
return new MutableContextSet();
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/data/DatastoreConfiguration.java b/api/src/main/java/me/lucko/luckperms/api/data/DatastoreConfiguration.java
index 7a86bb787..72a1c6206 100644
--- a/api/src/main/java/me/lucko/luckperms/api/data/DatastoreConfiguration.java
+++ b/api/src/main/java/me/lucko/luckperms/api/data/DatastoreConfiguration.java
@@ -25,18 +25,24 @@
package me.lucko.luckperms.api.data;
+import javax.annotation.Nullable;
+
/**
* Represents the data section of the main LuckPerms configuration.
* All methods could return null.
*/
public interface DatastoreConfiguration {
+ @Nullable
String getAddress();
+ @Nullable
String getDatabase();
+ @Nullable
String getUsername();
+ @Nullable
String getPassword();
}
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 201aeb97e..4df77003a 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
@@ -27,6 +27,8 @@ package me.lucko.luckperms.api.event;
import java.util.concurrent.atomic.AtomicBoolean;
+import javax.annotation.Nonnull;
+
/**
* Represents an event that can be cancelled
*/
@@ -37,6 +39,7 @@ public interface Cancellable {
*
* @return the cancellation
*/
+ @Nonnull
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 8cbc9b9bc..5345113f4 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
@@ -28,6 +28,8 @@ package me.lucko.luckperms.api.event;
import java.util.Set;
import java.util.function.Consumer;
+import javax.annotation.Nonnull;
+
/**
* The LuckPerms event bus. Used for subscribing (or registering listeners) to events.
*
@@ -43,7 +45,8 @@ public interface EventBus {
* @param the event class
* @return an event handler instance representing this subscription
*/
- EventHandler subscribe(Class eventClass, Consumer handler);
+ @Nonnull
+ EventHandler subscribe(@Nonnull Class eventClass, @Nonnull Consumer handler);
/**
* Gets a set of all registered handlers for a given event
@@ -52,6 +55,7 @@ public interface EventBus {
* @param the event class
* @return an immutable set of event handlers
*/
- Set> getHandlers(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 216eec1bb..f20857be9 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
@@ -27,6 +27,8 @@ package me.lucko.luckperms.api.event;
import java.util.function.Consumer;
+import javax.annotation.Nonnull;
+
/**
* Represents a handler for a LuckPerms event
*
@@ -39,6 +41,7 @@ public interface EventHandler {
*
* @return the event class
*/
+ @Nonnull
Class getEventClass();
/**
@@ -60,6 +63,7 @@ public interface EventHandler {
*
* @return the event consumer
*/
+ @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 a1a598464..56050c5e8 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,6 +27,8 @@ package me.lucko.luckperms.api.event;
import me.lucko.luckperms.api.LuckPermsApi;
+import javax.annotation.Nonnull;
+
/**
* The base event interface
*
@@ -39,6 +41,7 @@ public interface LuckPermsEvent {
*
* @return the api instance
*/
+ @Nonnull
LuckPermsApi getApi();
}
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 3bcaac1ae..01a8c86fe 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
@@ -29,6 +29,8 @@ import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.cause.CreationCause;
+import javax.annotation.Nonnull;
+
/**
* Called when a group is created
*/
@@ -39,6 +41,7 @@ public interface GroupCreateEvent extends LuckPermsEvent {
*
* @return the new group
*/
+ @Nonnull
Group getGroup();
/**
@@ -46,6 +49,7 @@ public interface GroupCreateEvent extends LuckPermsEvent {
*
* @return the cause of the creation
*/
+ @Nonnull
CreationCause getCause();
}
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 175d16108..48fe48576 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
@@ -31,6 +31,8 @@ import me.lucko.luckperms.api.event.cause.DeletionCause;
import java.util.Set;
+import javax.annotation.Nonnull;
+
/**
* Called when a group is deleted
*/
@@ -41,6 +43,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent {
*
* @return the name of the deleted group
*/
+ @Nonnull
String getGroupName();
/**
@@ -48,6 +51,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent {
*
* @return a copy of the groups existing data
*/
+ @Nonnull
Set getExistingData();
/**
@@ -55,6 +59,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent {
*
* @return the cause of the deletion
*/
+ @Nonnull
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 9df112a9e..eb414f6e4 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
@@ -28,6 +28,8 @@ package me.lucko.luckperms.api.event.group;
import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.event.LuckPermsEvent;
+import javax.annotation.Nonnull;
+
/**
* Called when a group is loaded into memory from the storage.
*
@@ -40,6 +42,7 @@ public interface GroupLoadEvent extends LuckPermsEvent {
*
* @return the group that was loaded
*/
+ @Nonnull
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 96e95d8c2..8d676d4ad 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
@@ -29,6 +29,8 @@ import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.api.event.Cancellable;
import me.lucko.luckperms.api.event.LuckPermsEvent;
+import javax.annotation.Nonnull;
+
/**
* Called when a log entry is about to be sent to notifiable players on the platform
*/
@@ -39,6 +41,7 @@ public interface LogBroadcastEvent extends LuckPermsEvent, Cancellable {
*
* @return the log entry to be broadcasted
*/
+ @Nonnull
LogEntry getEntry();
}
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 546dcec92..15c2a990e 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
@@ -29,6 +29,8 @@ import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.api.event.Cancellable;
import me.lucko.luckperms.api.event.LuckPermsEvent;
+import javax.annotation.Nonnull;
+
/**
* Called when a log is about to be published to the storage file/table
*/
@@ -39,6 +41,7 @@ public interface LogPublishEvent extends LuckPermsEvent, Cancellable {
*
* @return the log entry to be published
*/
+ @Nonnull
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 d0467f14e..5944c5f93 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
@@ -27,6 +27,8 @@ package me.lucko.luckperms.api.event.node;
import me.lucko.luckperms.api.Node;
+import javax.annotation.Nonnull;
+
/**
* Called when a node is added to a holder
*/
@@ -37,6 +39,7 @@ public interface NodeAddEvent extends NodeMutateEvent {
*
* @return the node that was added
*/
+ @Nonnull
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 7927bb215..293147456 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
@@ -31,6 +31,8 @@ import me.lucko.luckperms.api.event.LuckPermsEvent;
import java.util.Set;
+import javax.annotation.Nonnull;
+
/**
* Called when a node is added to/removed from a user/group
*/
@@ -41,6 +43,7 @@ public interface NodeMutateEvent extends LuckPermsEvent {
*
* @return the event target
*/
+ @Nonnull
PermissionHolder getTarget();
/**
@@ -48,6 +51,7 @@ public interface NodeMutateEvent extends LuckPermsEvent {
*
* @return the data before the change
*/
+ @Nonnull
Set getDataBefore();
/**
@@ -55,6 +59,7 @@ public interface NodeMutateEvent extends LuckPermsEvent {
*
* @return the data after the change
*/
+ @Nonnull
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 053d6b7ae..8e2becbfa 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
@@ -27,6 +27,8 @@ package me.lucko.luckperms.api.event.node;
import me.lucko.luckperms.api.Node;
+import javax.annotation.Nonnull;
+
/**
* Called when a node is removed from a holder
*/
@@ -37,6 +39,7 @@ public interface NodeRemoveEvent extends NodeMutateEvent {
*
* @return the node that was removed
*/
+ @Nonnull
Node getNode();
}
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 7a209dda5..fec70ac0b 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
@@ -30,6 +30,8 @@ import me.lucko.luckperms.api.event.LuckPermsEvent;
import java.util.UUID;
+import javax.annotation.Nonnull;
+
/**
* Called before a network sync task runs
*/
@@ -40,6 +42,7 @@ public interface PreNetworkSyncEvent extends LuckPermsEvent, Cancellable {
*
* @return the id of the sync request
*/
+ @Nonnull
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 f7ee4cc9e..816b7ac20 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
@@ -29,6 +29,8 @@ import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.cause.CreationCause;
+import javax.annotation.Nonnull;
+
/**
* Called when a track is created
*/
@@ -39,6 +41,7 @@ public interface TrackCreateEvent extends LuckPermsEvent {
*
* @return the new track
*/
+ @Nonnull
Track getTrack();
/**
@@ -46,6 +49,7 @@ public interface TrackCreateEvent extends LuckPermsEvent {
*
* @return the cause of the creation
*/
+ @Nonnull
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 ae6cd97ec..3d753d59f 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
@@ -30,6 +30,8 @@ import me.lucko.luckperms.api.event.cause.DeletionCause;
import java.util.List;
+import javax.annotation.Nonnull;
+
/**
* Called when a track is deleted
*/
@@ -40,6 +42,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent {
*
* @return the name of the deleted track
*/
+ @Nonnull
String getTrackName();
/**
@@ -47,6 +50,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent {
*
* @return a copy of the tracks existing data
*/
+ @Nonnull
List getExistingData();
/**
@@ -54,6 +58,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent {
*
* @return the cause of the deletion
*/
+ @Nonnull
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 92f5255ed..b53271bd7 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
@@ -28,6 +28,8 @@ package me.lucko.luckperms.api.event.track;
import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.event.LuckPermsEvent;
+import javax.annotation.Nonnull;
+
/**
* Called when a track is loaded into memory from the storage.
*
@@ -40,6 +42,7 @@ public interface TrackLoadEvent extends LuckPermsEvent {
*
* @return the track that was loaded
*/
+ @Nonnull
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 35e8eda9a..76a3294f5 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
@@ -25,6 +25,8 @@
package me.lucko.luckperms.api.event.track.mutate;
+import javax.annotation.Nonnull;
+
/**
* Called when a group is added to a track
*/
@@ -35,6 +37,7 @@ public interface TrackAddGroupEvent extends TrackMutateEvent {
*
* @return the group that was added
*/
+ @Nonnull
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 999386fb4..d9fad7491 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
@@ -30,6 +30,8 @@ import me.lucko.luckperms.api.event.LuckPermsEvent;
import java.util.List;
+import javax.annotation.Nonnull;
+
/**
* Called when a track is changed
*/
@@ -40,6 +42,7 @@ public interface TrackMutateEvent extends LuckPermsEvent {
*
* @return the track that was mutated
*/
+ @Nonnull
Track getTrack();
/**
@@ -47,6 +50,7 @@ public interface TrackMutateEvent extends LuckPermsEvent {
*
* @return the data before the change
*/
+ @Nonnull
List getDataBefore();
/**
@@ -54,6 +58,7 @@ public interface TrackMutateEvent extends LuckPermsEvent {
*
* @return the data after the change
*/
+ @Nonnull
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 3bec4cfd0..f582cbd8f 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
@@ -25,6 +25,8 @@
package me.lucko.luckperms.api.event.track.mutate;
+import javax.annotation.Nonnull;
+
/**
* Called when a group is removed from a track
*/
@@ -35,6 +37,7 @@ public interface TrackRemoveGroupEvent extends TrackMutateEvent {
*
* @return the group that was removed
*/
+ @Nonnull
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 87d22d34b..d0e311040 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
@@ -29,6 +29,8 @@ import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.caching.UserData;
import me.lucko.luckperms.api.event.LuckPermsEvent;
+import javax.annotation.Nonnull;
+
/**
* Called when a users {@link me.lucko.luckperms.api.caching.UserData} is loaded.
*/
@@ -39,6 +41,7 @@ public interface UserCacheLoadEvent extends LuckPermsEvent {
*
* @return the user
*/
+ @Nonnull
User getUser();
/**
@@ -46,6 +49,7 @@ public interface UserCacheLoadEvent extends LuckPermsEvent {
*
* @return the loaded data
*/
+ @Nonnull
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 0a594c132..354fd6d89 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
@@ -29,6 +29,8 @@ import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.caching.UserData;
import me.lucko.luckperms.api.event.LuckPermsEvent;
+import javax.annotation.Nonnull;
+
/**
* Called when a users cached data is refreshed
*/
@@ -39,6 +41,7 @@ public interface UserDataRecalculateEvent extends LuckPermsEvent {
*
* @return the user
*/
+ @Nonnull
User getUser();
/**
@@ -46,6 +49,7 @@ public interface UserDataRecalculateEvent extends LuckPermsEvent {
*
* @return the data
*/
+ @Nonnull
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 de195a2c4..0807e9d25 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
@@ -29,6 +29,8 @@ import me.lucko.luckperms.api.event.LuckPermsEvent;
import java.util.UUID;
+import javax.annotation.Nonnull;
+
/**
* Called when the user logs into the network for the first time.
*
@@ -47,6 +49,7 @@ public interface UserFirstLoginEvent extends LuckPermsEvent {
*
* @return the uuid of the user
*/
+ @Nonnull
UUID getUuid();
/**
@@ -54,6 +57,7 @@ public interface UserFirstLoginEvent extends LuckPermsEvent {
*
* @return the username of the user
*/
+ @Nonnull
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 f64ad0af4..847fc7138 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
@@ -28,6 +28,8 @@ package me.lucko.luckperms.api.event.user;
import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.event.LuckPermsEvent;
+import javax.annotation.Nonnull;
+
/**
* Called when a user is loaded into memory from the storage.
*/
@@ -38,6 +40,7 @@ public interface UserLoadEvent extends LuckPermsEvent {
*
* @return the user that was loaded
*/
+ @Nonnull
User getUser();
}
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 e60083192..690f08db8 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,6 +31,8 @@ import me.lucko.luckperms.api.event.LuckPermsEvent;
import java.util.Optional;
+import javax.annotation.Nonnull;
+
/**
* Called when a user interacts with a track through a promotion or demotion
*/
@@ -41,6 +43,7 @@ public interface UserTrackEvent extends LuckPermsEvent {
*
* @return the track involved in the event
*/
+ @Nonnull
Track getTrack();
/**
@@ -48,6 +51,7 @@ public interface UserTrackEvent extends LuckPermsEvent {
*
* @return the user involved in the event
*/
+ @Nonnull
User getUser();
/**
@@ -55,6 +59,7 @@ public interface UserTrackEvent extends LuckPermsEvent {
*
* @return the action performed
*/
+ @Nonnull
TrackAction getAction();
/**
@@ -64,6 +69,7 @@ public interface UserTrackEvent extends LuckPermsEvent {
*
* @return the group the user was promoted/demoted from
*/
+ @Nonnull
Optional getGroupFrom();
/**
@@ -71,6 +77,7 @@ public interface UserTrackEvent extends LuckPermsEvent {
*
* @return the group the user was promoted/demoted to
*/
+ @Nonnull
Optional getGroupTo();
}
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 a60b8244d..5baea00f1 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
@@ -27,6 +27,8 @@ package me.lucko.luckperms.api.metastacking;
import java.util.List;
+import javax.annotation.Nonnull;
+
/**
* Represents a meta stack model, consisting of a chain of elements, separated by spacers.
*
@@ -45,6 +47,7 @@ public interface MetaStackDefinition {
*
* @return the elements in this stack
*/
+ @Nonnull
List getElements();
/**
@@ -52,6 +55,7 @@ public interface MetaStackDefinition {
*
* @return the start spacer
*/
+ @Nonnull
String getStartSpacer();
/**
@@ -59,6 +63,7 @@ public interface MetaStackDefinition {
*
* @return the middle spacer
*/
+ @Nonnull
String getMiddleSpacer();
/**
@@ -66,6 +71,7 @@ public interface MetaStackDefinition {
*
* @return the end spacer
*/
+ @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 a54e919ed..048b4a611 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
@@ -31,6 +31,9 @@ import me.lucko.luckperms.api.Node;
import java.util.Map;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
/**
* Represents an element within a {@link MetaStackDefinition}.
*
@@ -48,6 +51,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(LocalizedNode node, ChatMetaType type, Map.Entry current);
+ boolean shouldAccumulate(@Nonnull LocalizedNode node, @Nonnull ChatMetaType type, @Nullable Map.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 253689722..0eccae0d3 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
@@ -28,6 +28,8 @@ package me.lucko.luckperms.api.metastacking;
import java.util.List;
import java.util.Optional;
+import javax.annotation.Nonnull;
+
/**
* Factory to create meta stack elements and definitions.
*
@@ -41,7 +43,8 @@ public interface MetaStackFactory {
* @param definition the definition
* @return the parsed element, if present
*/
- Optional fromString(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.
@@ -51,7 +54,8 @@ public interface MetaStackFactory {
* @param definitions the definition strings
* @return a list of parsed elements
*/
- List fromStrings(List definitions);
+ @Nonnull
+ List fromStrings(@Nonnull List definitions);
/**
* Creates a new {@link MetaStackDefinition} with the given properties.
@@ -62,6 +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
*/
- MetaStackDefinition createDefinition(List