Add jsr305 annotations to the API

This commit is contained in:
Luck 2017-06-24 17:25:13 +01:00
parent 26ce8b8ab7
commit 2ffbeeef8e
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
59 changed files with 690 additions and 347 deletions

View File

@ -100,6 +100,12 @@
<version>19.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -29,6 +29,8 @@ import me.lucko.luckperms.api.LuckPermsApi;
import java.util.Optional;
import javax.annotation.Nonnull;
/**
* Singleton for the {@link LuckPermsApi}.
*
@ -44,6 +46,7 @@ public final class LuckPerms {
* @return an api instance
* @throws IllegalStateException if the api is not loaded
*/
@Nonnull
public static LuckPermsApi getApi() {
if (api == null) {
throw new IllegalStateException("API is not loaded.");
@ -59,6 +62,7 @@ public final class LuckPerms {
*
* @return an optional api instance
*/
@Nonnull
public static Optional<LuckPermsApi> getApiSafe() {
return Optional.ofNullable(api);
}

View File

@ -25,8 +25,12 @@
package me.lucko.luckperms.api;
import com.google.common.base.Preconditions;
import java.util.Map;
import javax.annotation.Nonnull;
/**
* Represents a type of chat meta
*
@ -40,17 +44,17 @@ public enum ChatMetaType {
PREFIX {
@Override
public boolean matches(Node node) {
return node.isPrefix();
return Preconditions.checkNotNull(node, "node").isPrefix();
}
@Override
public boolean shouldIgnore(Node node) {
return !node.isPrefix();
return !Preconditions.checkNotNull(node, "node").isPrefix();
}
@Override
public Map.Entry<Integer, String> getEntry(Node node) {
return node.getPrefix();
return Preconditions.checkNotNull(node, "node").getPrefix();
}
},
@ -60,17 +64,17 @@ public enum ChatMetaType {
SUFFIX {
@Override
public boolean matches(Node node) {
return node.isSuffix();
return Preconditions.checkNotNull(node, "node").isSuffix();
}
@Override
public boolean shouldIgnore(Node node) {
return !node.isSuffix();
return !Preconditions.checkNotNull(node, "node").isSuffix();
}
@Override
public Map.Entry<Integer, String> getEntry(Node node) {
return node.getSuffix();
return Preconditions.checkNotNull(node, "node").getSuffix();
}
};
@ -80,7 +84,7 @@ public enum ChatMetaType {
* @param node the node to test
* @return true if the node has the same type
*/
public abstract boolean matches(Node node);
public abstract boolean matches(@Nonnull Node node);
/**
* Returns if the passed node should be ignored when searching for meta of this type
@ -88,7 +92,7 @@ public enum ChatMetaType {
* @param node the node to test
* @return true if the node does not share the same type
*/
public abstract boolean shouldIgnore(Node node);
public abstract boolean shouldIgnore(@Nonnull Node node);
/**
* Maps the corresponding entry from the given node
@ -97,6 +101,7 @@ public enum ChatMetaType {
* @return the entry
* @throws IllegalStateException if the node does not share the same type
*/
public abstract Map.Entry<Integer, String> getEntry(Node node);
@Nonnull
public abstract Map.Entry<Integer, String> getEntry(@Nonnull Node node);
}

View File

@ -27,6 +27,8 @@ package me.lucko.luckperms.api;
import me.lucko.luckperms.api.context.ContextSet;
import javax.annotation.Nonnull;
/**
* Context and options for a permission lookup.
*
@ -44,11 +46,12 @@ public class Contexts {
*
* @return a context that will not apply any filters
*/
@Nonnull
public static Contexts allowAll() {
return ALLOW_ALL;
}
public static Contexts of(ContextSet context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) {
public static Contexts of(@Nonnull ContextSet context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) {
return new Contexts(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, op);
}
@ -90,7 +93,7 @@ public class Contexts {
*/
private final boolean applyGlobalWorldGroups;
public Contexts(ContextSet context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) {
public Contexts(@Nonnull ContextSet context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) {
if (context == null) {
throw new NullPointerException("context");
}
@ -110,6 +113,7 @@ public class Contexts {
* @return an immutable set of context key value pairs
* @since 2.13
*/
@Nonnull
public ContextSet getContexts() {
return this.context;
}
@ -169,6 +173,7 @@ public class Contexts {
}
@Override
@Nonnull
public String toString() {
return "Contexts(" +
"context=" + this.getContexts() + ", " +

View File

@ -32,6 +32,8 @@ import me.lucko.luckperms.exceptions.ObjectLacksException;
import java.util.List;
import java.util.OptionalInt;
import javax.annotation.Nonnull;
/**
* A group which holds permission data.
*/
@ -42,6 +44,7 @@ public interface Group extends PermissionHolder {
*
* @return the name of the group
*/
@Nonnull
String getName();
/**
@ -52,7 +55,7 @@ public interface Group extends PermissionHolder {
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
boolean inheritsGroup(Group group);
boolean inheritsGroup(@Nonnull Group group);
/**
* Check to see if a group inherits another group directly
@ -64,7 +67,7 @@ public interface Group extends PermissionHolder {
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @since 3.2
*/
boolean inheritsGroup(Group group, ContextSet contextSet);
boolean inheritsGroup(@Nonnull Group group, @Nonnull ContextSet contextSet);
/**
* Gets the weight of this group, if present.
@ -72,6 +75,7 @@ public interface Group extends PermissionHolder {
* @return the group weight
* @since 2.17
*/
@Nonnull
OptionalInt getWeight();
/**
@ -86,7 +90,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link #inheritsGroup(Group, ContextSet)}
*/
@Deprecated
boolean inheritsGroup(Group group, String server);
boolean inheritsGroup(@Nonnull Group group, @Nonnull String server);
/**
* Check to see if the group inherits a group on a specific server and world
@ -101,7 +105,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link #inheritsGroup(Group, ContextSet)}
*/
@Deprecated
boolean inheritsGroup(Group group, String server, String world);
boolean inheritsGroup(@Nonnull Group group, @Nonnull String server, @Nonnull String world);
/**
* Make this group inherit another group
@ -113,7 +117,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
void setInheritGroup(Group group) throws ObjectAlreadyHasException;
void setInheritGroup(@Nonnull Group group) throws ObjectAlreadyHasException;
/**
* Make this group inherit another group on a specific server
@ -127,7 +131,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
void setInheritGroup(Group group, String server) throws ObjectAlreadyHasException;
void setInheritGroup(@Nonnull Group group, @Nonnull String server) throws ObjectAlreadyHasException;
/**
* Make this group inherit another group on a specific server and world
@ -142,7 +146,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
void setInheritGroup(Group group, String server, String world) throws ObjectAlreadyHasException;
void setInheritGroup(@Nonnull Group group, @Nonnull String server, @Nonnull String world) throws ObjectAlreadyHasException;
/**
* Make this group inherit another group temporarily
@ -156,7 +160,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
void setInheritGroup(Group group, long expireAt) throws ObjectAlreadyHasException;
void setInheritGroup(@Nonnull Group group, long expireAt) throws ObjectAlreadyHasException;
/**
* Make this group inherit another group on a specific server temporarily
@ -171,7 +175,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
void setInheritGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException;
void setInheritGroup(@Nonnull Group group, @Nonnull String server, long expireAt) throws ObjectAlreadyHasException;
/**
* Make this group inherit another group on a specific server and world temporarily
@ -187,7 +191,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
void setInheritGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException;
void setInheritGroup(@Nonnull Group group, @Nonnull String server, @Nonnull String world, long expireAt) throws ObjectAlreadyHasException;
/**
* Remove a previously set inheritance rule
@ -199,7 +203,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
void unsetInheritGroup(Group group) throws ObjectLacksException;
void unsetInheritGroup(@Nonnull Group group) throws ObjectLacksException;
/**
* Remove a previously set inheritance rule
@ -212,7 +216,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
void unsetInheritGroup(Group group, boolean temporary) throws ObjectLacksException;
void unsetInheritGroup(@Nonnull Group group, boolean temporary) throws ObjectLacksException;
/**
* Remove a previously set inheritance rule on a specific server
@ -226,7 +230,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
void unsetInheritGroup(Group group, String server) throws ObjectLacksException;
void unsetInheritGroup(@Nonnull Group group, @Nonnull String server) throws ObjectLacksException;
/**
* Remove a previously set inheritance rule on a specific server and world
@ -241,7 +245,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
void unsetInheritGroup(Group group, String server, String world) throws ObjectLacksException;
void unsetInheritGroup(@Nonnull Group group, @Nonnull String server, @Nonnull String world) throws ObjectLacksException;
/**
* Remove a previously set inheritance rule on a specific server
@ -256,7 +260,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
void unsetInheritGroup(Group group, String server, boolean temporary) throws ObjectLacksException;
void unsetInheritGroup(@Nonnull Group group, @Nonnull String server, boolean temporary) throws ObjectLacksException;
/**
* Remove a previously set inheritance rule on a specific server and world
@ -272,7 +276,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of {@link NodeFactory#makeGroupNode(Group)}
*/
@Deprecated
void unsetInheritGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException;
void unsetInheritGroup(@Nonnull Group group, @Nonnull String server, @Nonnull String world, boolean temporary) throws ObjectLacksException;
/**
* Get a {@link List} of all of the groups the group inherits, on all servers
@ -281,6 +285,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of just querying a users permissions
*/
@Deprecated
@Nonnull
List<String> getGroupNames();
/**
@ -293,7 +298,8 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of just querying a users permissions
*/
@Deprecated
List<String> getLocalGroups(String server);
@Nonnull
List<String> getLocalGroups(@Nonnull String server);
/**
@ -307,6 +313,7 @@ public interface Group extends PermissionHolder {
* @deprecated in favour of just querying a users permissions
*/
@Deprecated
List<String> getLocalGroups(String server, String world);
@Nonnull
List<String> getLocalGroups(@Nonnull String server, @Nonnull String world);
}

View File

@ -30,6 +30,8 @@ import com.google.common.collect.Multimap;
import java.util.Optional;
import java.util.OptionalLong;
import javax.annotation.Nonnull;
/**
* A relationship between a Holder and a permission
*
@ -43,6 +45,7 @@ public interface HeldPermission<T> {
*
* @return the holder
*/
@Nonnull
T getHolder();
/**
@ -50,6 +53,7 @@ public interface HeldPermission<T> {
*
* @return the permission
*/
@Nonnull
String getPermission();
/**
@ -64,6 +68,7 @@ public interface HeldPermission<T> {
*
* @return the server
*/
@Nonnull
Optional<String> getServer();
/**
@ -71,6 +76,7 @@ public interface HeldPermission<T> {
*
* @return the world
*/
@Nonnull
Optional<String> getWorld();
/**
@ -85,6 +91,7 @@ public interface HeldPermission<T> {
*
* @return the context
*/
@Nonnull
Multimap<String, String> getContext();
/**
@ -92,6 +99,7 @@ public interface HeldPermission<T> {
*
* @return a Node copy of this permission
*/
@Nonnull
Node asNode();
}

View File

@ -29,6 +29,8 @@ import me.lucko.luckperms.api.data.DatastoreConfiguration;
import java.util.Map;
import javax.annotation.Nonnull;
/**
* Read-only access to the LuckPerms configuration settings
*/
@ -38,6 +40,7 @@ public interface LPConfiguration {
* Returns the name of this server
* @return the name of this server
*/
@Nonnull
String getServer();
/**
@ -130,6 +133,7 @@ public interface LPConfiguration {
* @return the name of the server used within Vault operations
* @since 2.7
*/
@Nonnull
String getVaultServer();
/**
@ -143,12 +147,14 @@ public interface LPConfiguration {
* Returns the values set for data storage in the configuration
* @return the values set for data storage in the configuration
*/
@Nonnull
DatastoreConfiguration getDatastoreConfig();
/**
* Returns the storage method string from the configuration
* @return the storage method string from the configuration
*/
@Nonnull
String getStorageMethod();
/**
@ -164,6 +170,7 @@ public interface LPConfiguration {
* method. For example: key = user, value = json
* @since 2.7
*/
@Nonnull
Map<String, String> getSplitStorageOptions();
}

View File

@ -25,6 +25,8 @@
package me.lucko.luckperms.api;
import javax.annotation.Nonnull;
/**
* A node with a traceable origin
*
@ -37,6 +39,7 @@ public interface LocalizedNode extends Node {
*
* @return the node this instance is representing
*/
@Nonnull
Node getNode();
/**
@ -45,6 +48,7 @@ public interface LocalizedNode extends Node {
* @return where the node was inherited from. Will not return null.
* @see PermissionHolder#getObjectName()
*/
@Nonnull
String getLocation();
}

View File

@ -29,6 +29,8 @@ import java.util.SortedMap;
import java.util.SortedSet;
import java.util.UUID;
import javax.annotation.Nonnull;
/**
* Represents the internal LuckPerms log.
*
@ -40,11 +42,13 @@ public interface Log {
/**
* @return a {@link SortedSet} of all of the {@link LogEntry} objects in this {@link Log}
*/
@Nonnull
SortedSet<LogEntry> getContent();
/**
* @return all content in this log
*/
@Nonnull
SortedSet<LogEntry> getRecent();
/**
@ -55,6 +59,7 @@ public interface Log {
* @throws IllegalArgumentException if the pageNo is less than 1
* @throws IllegalStateException if the log doesn't contain enough entries to populate the page. See {@link #getRecentMaxPages()}}
*/
@Nonnull
SortedMap<Integer, LogEntry> getRecent(int pageNo);
/**
@ -67,7 +72,8 @@ public interface Log {
* @param actor the uuid of the actor to filter by
* @return all content in this log where is actor = uuid
*/
SortedSet<LogEntry> getRecent(UUID actor);
@Nonnull
SortedSet<LogEntry> getRecent(@Nonnull UUID actor);
/**
* Gets the recent content for the uuid, separated into pages
@ -78,20 +84,22 @@ public interface Log {
* @throws IllegalArgumentException if the pageNo is less than 1
* @throws IllegalStateException if the log doesn't contain enough entries to populate the page. See {@link #getRecentMaxPages(UUID)}}
*/
SortedMap<Integer, LogEntry> getRecent(int pageNo, UUID actor);
@Nonnull
SortedMap<Integer, LogEntry> getRecent(int pageNo, @Nonnull UUID actor);
/**
* @param actor the actor to filter by
* @return the max page number allowed in the {@link #getRecent(int, UUID)} method
*/
int getRecentMaxPages(UUID actor);
int getRecentMaxPages(@Nonnull UUID actor);
/**
* @param uuid the uuid to filter by
* @return all content in this log where the user = uuid
*/
SortedSet<LogEntry> getUserHistory(UUID uuid);
@Nonnull
SortedSet<LogEntry> getUserHistory(@Nonnull UUID uuid);
/**
* Gets the user history content, separated by pages
@ -102,20 +110,22 @@ public interface Log {
* @throws IllegalArgumentException if the pageNo is less than 1
* @throws IllegalStateException if the log doesn't contain enough entries to populate the page. See {@link #getUserHistoryMaxPages(UUID)}}
*/
SortedMap<Integer, LogEntry> getUserHistory(int pageNo, UUID uuid);
@Nonnull
SortedMap<Integer, LogEntry> getUserHistory(int pageNo, @Nonnull UUID uuid);
/**
* @param uuid the uuid to filter by
* @return the max page number allowed in the {@link #getUserHistory(int, UUID)} method
*/
int getUserHistoryMaxPages(UUID uuid);
int getUserHistoryMaxPages(@Nonnull UUID uuid);
/**
* @param name the name to filter by
* @return all content in this log where the group = name
*/
SortedSet<LogEntry> getGroupHistory(String name);
@Nonnull
SortedSet<LogEntry> getGroupHistory(@Nonnull String name);
/**
* Gets the group history content, separated by pages
@ -126,20 +136,22 @@ public interface Log {
* @throws IllegalArgumentException if the pageNo is less than 1
* @throws IllegalStateException if the log doesn't contain enough entries to populate the page. See {@link #getGroupHistoryMaxPages(String)}}
*/
SortedMap<Integer, LogEntry> getGroupHistory(int pageNo, String name);
@Nonnull
SortedMap<Integer, LogEntry> getGroupHistory(int pageNo, @Nonnull String name);
/**
* @param name the name to filter by
* @return the max page number allowed in the {@link #getGroupHistory(int, String)} method
*/
int getGroupHistoryMaxPages(String name);
int getGroupHistoryMaxPages(@Nonnull String name);
/**
* @param name the name to filter by
* @return all content in this log where the track = name
*/
SortedSet<LogEntry> getTrackHistory(String name);
@Nonnull
SortedSet<LogEntry> getTrackHistory(@Nonnull String name);
/**
* Gets the track history content, separated by pages
@ -148,7 +160,8 @@ public interface Log {
* @param name the name of the acted track to filter by
* @return the page content
*/
SortedMap<Integer, LogEntry> getTrackHistory(int pageNo, String name);
@Nonnull
SortedMap<Integer, LogEntry> getTrackHistory(int pageNo, @Nonnull String name);
/**
* @param name the name to filter by
@ -156,14 +169,15 @@ public interface Log {
* @throws IllegalArgumentException if the pageNo is less than 1
* @throws IllegalStateException if the log doesn't contain enough entries to populate the page. See {@link #getTrackHistoryMaxPages(String)}}
*/
int getTrackHistoryMaxPages(String name);
int getTrackHistoryMaxPages(@Nonnull String name);
/**
* @param query the query to filter by
* @return all content in this log where the content matches query
*/
SortedSet<LogEntry> getSearch(String query);
@Nonnull
SortedSet<LogEntry> getSearch(@Nonnull String query);
/**
* Gets the search content, separated by pages
@ -174,11 +188,12 @@ public interface Log {
* @throws IllegalArgumentException if the pageNo is less than 1
* @throws IllegalStateException if the log doesn't contain enough entries to populate the page. See {@link #getSearchMaxPages(String)}}
*/
SortedMap<Integer, LogEntry> getSearch(int pageNo, String query);
@Nonnull
SortedMap<Integer, LogEntry> getSearch(int pageNo, @Nonnull String query);
/**
* @param query the query to filter by
* @return the max page number allowed in the {@link #getSearch(int, String)} method
*/
int getSearchMaxPages(String query);
int getSearchMaxPages(@Nonnull String query);
}

View File

@ -27,6 +27,9 @@ package me.lucko.luckperms.api;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* A single entry in the log
*
@ -35,6 +38,7 @@ import java.util.UUID;
public class LogEntry implements Comparable<LogEntry> {
private static final String FORMAT = "&8(&e%s&8) [&a%s&8] (&b%s&8) &7--> &f%s";
@Nonnull
public static LogEntryBuilder builder() {
return new LogEntryBuilder();
}
@ -47,7 +51,7 @@ public class LogEntry implements Comparable<LogEntry> {
private String actedName;
private String action;
public LogEntry(long timestamp, UUID actor, String actorName, char type, UUID acted, String actedName, String action) {
public LogEntry(long timestamp, @Nonnull UUID actor, @Nonnull String actorName, char type, @Nullable UUID acted, @Nonnull String actedName, @Nonnull String action) {
if (actor == null) {
throw new NullPointerException("actor");
}
@ -85,12 +89,13 @@ public class LogEntry implements Comparable<LogEntry> {
return equals(o) ? 0 : (Long.compare(timestamp, o.getTimestamp()) == 0 ? 1 : Long.compare(timestamp, o.getTimestamp()));
}
public boolean matchesSearch(String query) {
public boolean matchesSearch(@Nonnull String query) {
query = query.toLowerCase();
return actorName.toLowerCase().contains(query) || actedName.toLowerCase().contains(query)
|| action.toLowerCase().contains(query);
}
@Nonnull
public String getFormatted() {
return String.format(FORMAT,
String.valueOf(actorName).equals("null") ? actor.toString() : actorName,
@ -108,19 +113,21 @@ public class LogEntry implements Comparable<LogEntry> {
this.timestamp = timestamp;
}
@Nonnull
public UUID getActor() {
return actor;
}
void setActor(UUID actor) {
void setActor(@Nonnull UUID actor) {
this.actor = actor;
}
@Nonnull
public String getActorName() {
return actorName;
}
void setActorName(String actorName) {
void setActorName(@Nonnull String actorName) {
this.actorName = actorName;
}
@ -132,27 +139,30 @@ public class LogEntry implements Comparable<LogEntry> {
this.type = type;
}
@Nullable
public UUID getActed() {
return acted;
}
void setActed(UUID acted) {
void setActed(@Nullable UUID acted) {
this.acted = acted;
}
@Nonnull
public String getActedName() {
return actedName;
}
void setActedName(String actedName) {
void setActedName(@Nonnull String actedName) {
this.actedName = actedName;
}
@Nonnull
public String getAction() {
return action;
}
void setAction(String action) {
void setAction(@Nonnull String action) {
this.action = action;
}

View File

@ -25,6 +25,8 @@
package me.lucko.luckperms.api;
import javax.annotation.Nonnull;
/**
* Represents the logger instance being used by LuckPerms on the platform.
*
@ -33,10 +35,10 @@ package me.lucko.luckperms.api;
*/
public interface Logger {
void info(String s);
void info(@Nonnull String s);
void warn(String s);
void warn(@Nonnull String s);
void severe(String s);
void severe(@Nonnull String s);
}

View File

@ -34,6 +34,9 @@ import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* The root API interface for LuckPerms
*/
@ -57,6 +60,7 @@ public interface LuckPermsApi {
*
* @return the version of the plugin running on the platform
*/
@Nonnull
String getVersion();
/**
@ -65,6 +69,7 @@ public interface LuckPermsApi {
* @return the platform LuckPerms is running on
* @since 2.7
*/
@Nonnull
PlatformType getPlatformType();
/**
@ -73,6 +78,7 @@ public interface LuckPermsApi {
* @return the event bus
* @since 3.0
*/
@Nonnull
EventBus getEventBus();
/**
@ -80,6 +86,7 @@ public interface LuckPermsApi {
*
* @return a configuration instance
*/
@Nonnull
LPConfiguration getConfiguration();
/**
@ -88,6 +95,7 @@ public interface LuckPermsApi {
* @return a storage instance
* @since 2.14
*/
@Nonnull
Storage getStorage();
/**
@ -95,6 +103,7 @@ public interface LuckPermsApi {
*
* @return an optional that may contain a messaging service instance.
*/
@Nonnull
Optional<MessagingService> getMessagingService();
/**
@ -102,6 +111,7 @@ public interface LuckPermsApi {
*
* @return the logger instance
*/
@Nonnull
Logger getLogger();
/**
@ -109,6 +119,7 @@ public interface LuckPermsApi {
*
* @return a uuid cache instance
*/
@Nonnull
UuidCache getUuidCache();
/**
@ -118,7 +129,8 @@ 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
*/
User getUser(UUID uuid);
@Nullable
User getUser(@Nonnull UUID uuid);
/**
* Gets a wrapped user object from the user storage.
@ -129,7 +141,8 @@ public interface LuckPermsApi {
* @return an optional {@link User} object
* @throws NullPointerException if the uuid is null
*/
Optional<User> getUserSafe(UUID uuid);
@Nonnull
Optional<User> getUserSafe(@Nonnull UUID uuid);
/**
* Gets a wrapped user object from the user storage
@ -138,7 +151,8 @@ 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
*/
User getUser(String name);
@Nullable
User getUser(@Nonnull String name);
/**
* Gets a wrapped user object from the user storage.
@ -149,13 +163,15 @@ public interface LuckPermsApi {
* @return an optional {@link User} object
* @throws NullPointerException if the name is null
*/
Optional<User> getUserSafe(String name);
@Nonnull
Optional<User> getUserSafe(@Nonnull String name);
/**
* Gets a set of all loaded users.
*
* @return a {@link Set} of {@link User} objects
*/
@Nonnull
Set<User> getUsers();
/**
@ -165,7 +181,7 @@ public interface LuckPermsApi {
* @return true if the user is loaded
* @throws NullPointerException if the uuid is null
*/
boolean isUserLoaded(UUID uuid);
boolean isUserLoaded(@Nonnull UUID uuid);
/**
* Unload a user from the internal storage, if they're not currently online.
@ -174,7 +190,7 @@ public interface LuckPermsApi {
* @throws NullPointerException if the user is null
* @since 2.6
*/
void cleanupUser(User user);
void cleanupUser(@Nonnull User user);
/**
* Gets a wrapped group object from the group storage
@ -183,7 +199,8 @@ 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
*/
Group getGroup(String name);
@Nullable
Group getGroup(@Nonnull String name);
/**
* Gets a wrapped group object from the group storage.
@ -194,13 +211,15 @@ public interface LuckPermsApi {
* @return an optional {@link Group} object
* @throws NullPointerException if the name is null
*/
Optional<Group> getGroupSafe(String name);
@Nonnull
Optional<Group> getGroupSafe(@Nonnull String name);
/**
* Gets a set of all loaded groups.
*
* @return a {@link Set} of {@link Group} objects
*/
@Nonnull
Set<Group> getGroups();
/**
@ -210,7 +229,7 @@ public interface LuckPermsApi {
* @return true if the group is loaded
* @throws NullPointerException if the name is null
*/
boolean isGroupLoaded(String name);
boolean isGroupLoaded(@Nonnull String name);
/**
* Gets a wrapped track object from the track storage
@ -219,7 +238,8 @@ public interface LuckPermsApi {
* @return a {@link Track} object, if one matching the name exists, or null if not
* @throws NullPointerException if the name is null
*/
Track getTrack(String name);
@Nullable
Track getTrack(@Nonnull String name);
/**
* Gets a wrapped track object from the track storage.
@ -230,13 +250,15 @@ public interface LuckPermsApi {
* @return an optional {@link Track} object
* @throws NullPointerException if the name is null
*/
Optional<Track> getTrackSafe(String name);
@Nonnull
Optional<Track> getTrackSafe(@Nonnull String name);
/**
* Gets a set of all loaded tracks.
*
* @return a {@link Set} of {@link Track} objects
*/
@Nonnull
Set<Track> getTracks();
/**
@ -246,13 +268,14 @@ public interface LuckPermsApi {
* @return true if the track is loaded
* @throws NullPointerException if the name is null
*/
boolean isTrackLoaded(String name);
boolean isTrackLoaded(@Nonnull String name);
/**
* Gets the node factory instance for the platform
*
* @return the node factory
*/
@Nonnull
NodeFactory getNodeFactory();
/**
@ -261,6 +284,7 @@ public interface LuckPermsApi {
* @return the meta stack factory
* @since 3.2
*/
@Nonnull
MetaStackFactory getMetaStackFactory();
/**
@ -272,7 +296,8 @@ public interface LuckPermsApi {
* @throws NullPointerException if the permission is null
* @since 2.6
*/
Node.Builder buildNode(String permission) throws IllegalArgumentException;
@Nonnull
Node.Builder buildNode(@Nonnull String permission) throws IllegalArgumentException;
/**
* Register a custom context calculator to the server
@ -280,7 +305,7 @@ public interface LuckPermsApi {
* @param contextCalculator 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.
*/
void registerContextCalculator(ContextCalculator<?> contextCalculator);
void registerContextCalculator(@Nonnull ContextCalculator<?> contextCalculator);
/**
* Gets a calculated context instance for the user using the rules of the platform.
@ -290,7 +315,8 @@ 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.
*/
Optional<Contexts> getContextForUser(User user);
@Nonnull
Optional<Contexts> getContextForUser(@Nonnull User user);
/**
* Gets set of contexts applicable to a player using the platforms {@link ContextCalculator}s.
@ -299,6 +325,7 @@ public interface LuckPermsApi {
* @return a set of contexts.
* @since 2.17
*/
ContextSet getContextForPlayer(Object player);
@Nonnull
ContextSet getContextForPlayer(@Nonnull Object player);
}

View File

@ -33,6 +33,9 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* An immutable permission node
*
@ -47,6 +50,7 @@ public interface Node extends Map.Entry<String, Boolean> {
*
* @return the actual permission node
*/
@Nonnull
String getPermission();
/**
@ -55,6 +59,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return the permission's value
*/
@Override
@Nonnull
Boolean getValue();
/**
@ -62,6 +67,7 @@ public interface Node extends Map.Entry<String, Boolean> {
*
* @return the value of this node as a Tristate
*/
@Nonnull
default Tristate getTristate() {
return Tristate.fromBoolean(getValue());
}
@ -88,6 +94,7 @@ public interface Node extends Map.Entry<String, Boolean> {
*
* @return an {@link Optional} containing the server, if one is defined
*/
@Nonnull
Optional<String> getServer();
/**
@ -95,6 +102,7 @@ public interface Node extends Map.Entry<String, Boolean> {
*
* @return an {@link Optional} containing the world, if one is defined
*/
@Nonnull
Optional<String> getWorld();
/**
@ -139,7 +147,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return true if the node should apply, otherwise false
* @since 3.1
*/
boolean shouldApply(boolean includeGlobal, boolean includeGlobalWorld, String server, String world, ContextSet context, boolean applyRegex);
boolean shouldApply(boolean includeGlobal, boolean includeGlobalWorld, @Nullable String server, @Nullable String world, @Nullable ContextSet context, boolean applyRegex);
/**
* If this node should apply on a specific server
@ -149,7 +157,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @param applyRegex if regex should be applied
* @return true if the node should apply
*/
boolean shouldApplyOnServer(String server, boolean includeGlobal, boolean applyRegex);
boolean shouldApplyOnServer(@Nullable String server, boolean includeGlobal, boolean applyRegex);
/**
* If this node should apply on a specific world
@ -159,7 +167,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @param applyRegex if regex should be applied
* @return true if the node should apply
*/
boolean shouldApplyOnWorld(String world, boolean includeGlobal, boolean applyRegex);
boolean shouldApplyOnWorld(@Nullable String world, boolean includeGlobal, boolean applyRegex);
/**
* If this node should apply in the given context
@ -169,7 +177,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return true if the node should apply
* @since 2.13
*/
boolean shouldApplyWithContext(ContextSet context, boolean worldAndServer);
boolean shouldApplyWithContext(@Nonnull ContextSet context, boolean worldAndServer);
/**
* If this node should apply in the given context
@ -178,7 +186,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return true if the node should apply
* @since 2.13
*/
boolean shouldApplyWithContext(ContextSet context);
boolean shouldApplyWithContext(@Nonnull ContextSet context);
/**
* Similar to {@link #shouldApplyOnServer(String, boolean, boolean)}, except this method accepts a List
@ -187,7 +195,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @param includeGlobal if global permissions should apply
* @return true if the node should apply
*/
boolean shouldApplyOnAnyServers(List<String> servers, boolean includeGlobal);
boolean shouldApplyOnAnyServers(@Nonnull List<String> servers, boolean includeGlobal);
/**
* Similar to {@link #shouldApplyOnWorld(String, boolean, boolean)}, except this method accepts a List
@ -196,7 +204,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @param includeGlobal if global permissions should apply
* @return true if the node should apply
*/
boolean shouldApplyOnAnyWorlds(List<String> worlds, boolean includeGlobal);
boolean shouldApplyOnAnyWorlds(@Nonnull List<String> worlds, boolean includeGlobal);
/**
* Resolves a list of wildcards that match this node
@ -204,13 +212,15 @@ public interface Node extends Map.Entry<String, Boolean> {
* @param possibleNodes a list of possible permission nodes
* @return a list of permissions that match this wildcard
*/
List<String> resolveWildcard(List<String> possibleNodes);
@Nonnull
List<String> resolveWildcard(@Nonnull List<String> possibleNodes);
/**
* Resolves any shorthand parts of this node and returns the full list
*
* @return a list of full nodes
*/
@Nonnull
List<String> resolveShorthand();
/**
@ -235,7 +245,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return the time in Unix time when this node will expire
* @throws IllegalStateException if the node is not temporary
*/
long getExpiryUnixTime();
long getExpiryUnixTime() throws IllegalStateException;
/**
* Returns the date when this node will expire
@ -243,7 +253,8 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return the {@link Date} when this node will expire
* @throws IllegalStateException if the node is not temporary
*/
Date getExpiry();
@Nonnull
Date getExpiry() throws IllegalStateException;
/**
* Return the number of seconds until this permission will expire
@ -251,7 +262,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return the number of seconds until this permission will expire
* @throws IllegalStateException if the node is not temporary
*/
long getSecondsTilExpiry();
long getSecondsTilExpiry() throws IllegalStateException;
/**
* Return true if the node has expired.
@ -267,6 +278,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return the extra contexts required for this node to apply
* @since 2.13
*/
@Nonnull
ContextSet getContexts();
/**
@ -275,6 +287,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return the full contexts required for this node to apply
* @since 3.1
*/
@Nonnull
ContextSet getFullContexts();
/**
@ -284,6 +297,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @deprecated because this serialized form is no longer used by the implementation.
*/
@Deprecated
@Nonnull
String toSerializedNode();
/**
@ -299,7 +313,8 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return the name of the group
* @throws IllegalStateException if this is not a group node. See {@link #isGroupNode()}
*/
String getGroupName();
@Nonnull
String getGroupName() throws IllegalStateException;
/**
* Returns if this node is a wildcard node
@ -314,7 +329,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return the wildcard level
* @throws IllegalStateException if this is not a wildcard
*/
int getWildcardLevel();
int getWildcardLevel() throws IllegalStateException;
/**
* Returns if this node is a meta node
@ -329,7 +344,8 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return the meta value
* @throws IllegalStateException if this node is not a meta node
*/
Map.Entry<String, String> getMeta();
@Nonnull
Map.Entry<String, String> getMeta() throws IllegalStateException;
/**
* Returns if this node is a prefix node
@ -344,7 +360,8 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return the prefix value
* @throws IllegalStateException if this node is a not a prefix node
*/
Map.Entry<Integer, String> getPrefix();
@Nonnull
Map.Entry<Integer, String> getPrefix() throws IllegalStateException;
/**
* Returns if this node is a suffix node
@ -359,7 +376,8 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return the suffix value
* @throws IllegalStateException if this node is a not a suffix node
*/
Map.Entry<Integer, String> getSuffix();
@Nonnull
Map.Entry<Integer, String> getSuffix() throws IllegalStateException;
/**
* Checks if this Node is equal to another node
@ -368,6 +386,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return true if this node is equal to the other provided
* @see #equalsIgnoringValue(Node) for a less strict implementation of this method
*/
@Override
boolean equals(Object obj);
/**
@ -376,7 +395,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @param other the other node
* @return true if the two nodes are almost equal
*/
boolean equalsIgnoringValue(Node other);
boolean equalsIgnoringValue(@Nonnull Node other);
/**
* Similar to {@link Node#equals(Object)}, except doesn't take note of the expiry time or value
@ -384,7 +403,7 @@ public interface Node extends Map.Entry<String, Boolean> {
* @param other the other node
* @return true if the two nodes are almost equal
*/
boolean almostEquals(Node other);
boolean almostEquals(@Nonnull Node other);
/**
* Similar to {@link Node#equals(Object)}, except doesn't take note of the value or if the node is temporary
@ -393,38 +412,51 @@ public interface Node extends Map.Entry<String, Boolean> {
* @return true if the two nodes are almost equal
* @since 2.8
*/
boolean equalsIgnoringValueOrTemp(Node other);
boolean equalsIgnoringValueOrTemp(@Nonnull Node other);
/**
* Builds a Node instance
*/
interface Builder {
@Nonnull
Builder setNegated(boolean negated);
@Nonnull
Builder setValue(boolean value);
/**
* Warning: this value does not persist, and disappears when the holder is re-loaded.
* It is therefore only useful for transient nodes.
*/
@Nonnull
Builder setOverride(boolean override);
@Nonnull
Builder setExpiry(long expireAt);
Builder setWorld(String world);
@Nonnull
Builder setWorld(@Nonnull String world);
Builder setServer(String server) throws IllegalArgumentException;
@Nonnull
Builder setServer(@Nonnull String server) throws IllegalArgumentException;
Builder withExtraContext(String key, String value);
@Nonnull
Builder withExtraContext(@Nonnull String key, @Nonnull String value);
Builder withExtraContext(Map<String, String> map);
@Nonnull
Builder withExtraContext(@Nonnull Map<String, String> map);
Builder withExtraContext(Set<Map.Entry<String, String>> context);
@Nonnull
Builder withExtraContext(@Nonnull Set<Map.Entry<String, String>> context);
Builder withExtraContext(Map.Entry<String, String> entry);
@Nonnull
Builder withExtraContext(@Nonnull Map.Entry<String, String> entry);
Builder withExtraContext(ContextSet set);
@Nonnull
Builder withExtraContext(@Nonnull ContextSet set);
@Nonnull
Node build();
}

View File

@ -25,6 +25,8 @@
package me.lucko.luckperms.api;
import javax.annotation.Nonnull;
/**
* Builds {@link Node} instances
*
@ -43,7 +45,8 @@ public interface NodeFactory {
* @see Node#toSerializedNode()
*/
@Deprecated
Node fromSerialisedNode(String serialisedPermission, boolean value);
@Nonnull
Node fromSerialisedNode(@Nonnull String serialisedPermission, boolean value);
/**
@ -53,7 +56,8 @@ public interface NodeFactory {
* @return a node builder instance
* @throws NullPointerException if the permission is null
*/
Node.Builder newBuilder(String permission);
@Nonnull
Node.Builder newBuilder(@Nonnull String permission);
/**
* Creates a node builder instance from an existing node
@ -62,7 +66,8 @@ public interface NodeFactory {
* @return a node builder instance
* @throws NullPointerException if the other node is null
*/
Node.Builder newBuilderFromExisting(Node other);
@Nonnull
Node.Builder newBuilderFromExisting(@Nonnull Node other);
/**
* Creates a node builder from a serialised node string
@ -75,7 +80,8 @@ public interface NodeFactory {
* @see Node#toSerializedNode()
*/
@Deprecated
Node.Builder newBuilderFromSerialisedNode(String serialisedPermission, boolean value);
@Nonnull
Node.Builder newBuilderFromSerialisedNode(@Nonnull String serialisedPermission, boolean value);
/**
@ -87,7 +93,8 @@ public interface NodeFactory {
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @since 3.1
*/
Node.Builder makeGroupNode(Group group);
@Nonnull
Node.Builder makeGroupNode(@Nonnull Group group);
/**
* Creates a node builder from a key value pair
@ -97,7 +104,8 @@ public interface NodeFactory {
* @return a node builder instance
* @throws NullPointerException if the key or value is null
*/
Node.Builder makeMetaNode(String key, String value);
@Nonnull
Node.Builder makeMetaNode(@Nonnull String key, @Nonnull String value);
/**
* Creates a node builder for the given chat meta type
@ -108,7 +116,8 @@ public interface NodeFactory {
* @throws NullPointerException if the type or value is null
* @since 3.2
*/
Node.Builder makeChatMetaNode(ChatMetaType type, int priority, String value);
@Nonnull
Node.Builder makeChatMetaNode(@Nonnull ChatMetaType type, int priority, @Nonnull String value);
/**
* Creates a node builder from a prefix string and priority
@ -118,7 +127,8 @@ public interface NodeFactory {
* @return a node builder instance
* @throws NullPointerException if the prefix is null
*/
Node.Builder makePrefixNode(int priority, String prefix);
@Nonnull
Node.Builder makePrefixNode(int priority, @Nonnull String prefix);
/**
* Creates a node builder from a prefix string and priority
@ -128,6 +138,7 @@ public interface NodeFactory {
* @return a node builder instance
* @throws NullPointerException if the suffix is null
*/
Node.Builder makeSuffixNode(int priority, String suffix);
@Nonnull
Node.Builder makeSuffixNode(int priority, @Nonnull String suffix);
}

View File

@ -34,6 +34,9 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* An object capable of holding permissions
*
@ -49,6 +52,7 @@ public interface PermissionHolder {
*
* @return the identifier for this object. Either a uuid string or name.
*/
@Nonnull
String getObjectName();
/**
@ -60,6 +64,7 @@ public interface PermissionHolder {
* @return a friendly identifier for this holder
* @since 3.2
*/
@Nonnull
String getFriendlyName();
/**
@ -68,6 +73,7 @@ public interface PermissionHolder {
* @return an immutable set of permissions in priority order
* @since 2.6
*/
@Nonnull
SortedSet<? extends Node> getPermissions();
/**
@ -78,6 +84,7 @@ public interface PermissionHolder {
* @return a set of nodes
* @since 2.6
*/
@Nonnull
Set<? extends Node> getEnduringPermissions();
/**
@ -88,6 +95,7 @@ public interface PermissionHolder {
* @return a set of nodes
* @since 2.6
*/
@Nonnull
Set<? extends Node> getTransientPermissions();
/**
@ -96,6 +104,7 @@ public interface PermissionHolder {
* @return a set of permanent nodes
* @since 2.6
*/
@Nonnull
Set<Node> getPermanentPermissionNodes();
/**
@ -104,6 +113,7 @@ public interface PermissionHolder {
* @return a set of temporary nodes
* @since 2.6
*/
@Nonnull
Set<Node> getTemporaryPermissionNodes();
/**
@ -119,7 +129,8 @@ public interface PermissionHolder {
* @throws NullPointerException if the context is null
* @since 2.11
*/
SortedSet<LocalizedNode> getAllNodes(Contexts contexts);
@Nonnull
SortedSet<LocalizedNode> getAllNodes(@Nonnull Contexts contexts);
/**
* Gets a mutable set of the nodes that this object has and inherits, filtered by context.
@ -132,7 +143,8 @@ public interface PermissionHolder {
* @throws NullPointerException if the context is null
* @since 2.11
*/
Set<LocalizedNode> getAllNodesFiltered(Contexts contexts);
@Nonnull
Set<LocalizedNode> getAllNodesFiltered(@Nonnull Contexts contexts);
/**
* Converts the output of {@link #getAllNodesFiltered(Contexts)}, and expands shorthand permissions.
@ -141,7 +153,8 @@ public interface PermissionHolder {
* @param lowerCase if the keys should be made lowercase whilst being exported
* @return a mutable map of permissions
*/
Map<String, Boolean> exportNodes(Contexts contexts, boolean lowerCase);
@Nonnull
Map<String, Boolean> exportNodes(@Nonnull Contexts contexts, boolean lowerCase);
/**
* Removes temporary permissions that have expired
@ -156,7 +169,8 @@ public interface PermissionHolder {
* @throws NullPointerException if the node is null
* @since 2.6
*/
Tristate hasPermission(Node node);
@Nonnull
Tristate hasPermission(@Nonnull Node node);
/**
* Checks to see if the object has a certain permission
@ -166,7 +180,8 @@ public interface PermissionHolder {
* @throws NullPointerException if the node is null
* @since 2.6
*/
Tristate hasTransientPermission(Node node);
@Nonnull
Tristate hasTransientPermission(@Nonnull Node node);
/**
* Checks to see if the object inherits a certain permission
@ -176,7 +191,8 @@ public interface PermissionHolder {
* @throws NullPointerException if the node is null
* @since 2.6
*/
Tristate inheritsPermission(Node node);
@Nonnull
Tristate inheritsPermission(@Nonnull Node node);
/**
* Sets a permission for the object
@ -186,7 +202,7 @@ public interface PermissionHolder {
* @throws NullPointerException if the node is null
* @since 2.6
*/
void setPermission(Node node) throws ObjectAlreadyHasException;
void setPermission(@Nonnull Node node) throws ObjectAlreadyHasException;
/**
* Sets a permission for the object
@ -196,7 +212,8 @@ public interface PermissionHolder {
* @return the result of the operation
* @since 3.1
*/
DataMutateResult setPermissionUnchecked(Node node);
@Nonnull
DataMutateResult setPermissionUnchecked(@Nonnull Node node);
/**
* Sets a transient permission for the object
@ -215,7 +232,7 @@ public interface PermissionHolder {
* @throws NullPointerException if the node is null
* @since 2.6
*/
void setTransientPermission(Node node) throws ObjectAlreadyHasException;
void setTransientPermission(@Nonnull Node node) throws ObjectAlreadyHasException;
/**
* Sets a transient permission for the object
@ -234,7 +251,8 @@ public interface PermissionHolder {
* @return the result of the operation
* @since 3.1
*/
DataMutateResult setTransientPermissionUnchecked(Node node);
@Nonnull
DataMutateResult setTransientPermissionUnchecked(@Nonnull Node node);
/**
* Unsets a permission for the object
@ -244,7 +262,7 @@ public interface PermissionHolder {
* @throws NullPointerException if the node is null
* @since 2.6
*/
void unsetPermission(Node node) throws ObjectLacksException;
void unsetPermission(@Nonnull Node node) throws ObjectLacksException;
/**
* Unsets a permission for the object
@ -254,7 +272,8 @@ public interface PermissionHolder {
* @return the result of the operation
* @since 3.1
*/
DataMutateResult unsetPermissionUnchecked(Node node);
@Nonnull
DataMutateResult unsetPermissionUnchecked(@Nonnull Node node);
/**
* Unsets a transient permission for the object
@ -264,7 +283,7 @@ public interface PermissionHolder {
* @throws NullPointerException if the node is null
* @since 2.6
*/
void unsetTransientPermission(Node node) throws ObjectLacksException;
void unsetTransientPermission(@Nonnull Node node) throws ObjectLacksException;
/**
* Unsets a transient permission for the object
@ -274,7 +293,8 @@ public interface PermissionHolder {
* @return the result of the operation
* @since 3.1
*/
DataMutateResult unsetTransientPermissionUnchecked(Node node);
@Nonnull
DataMutateResult unsetTransientPermissionUnchecked(@Nonnull Node node);
/**
* Clears any nodes from the holder which pass the predicate
@ -282,7 +302,7 @@ public interface PermissionHolder {
* @param test the predicate to test for nodes which should be removed
* @since 3.2
*/
void clearMatching(Predicate<Node> test);
void clearMatching(@Nonnull Predicate<Node> test);
/**
* Clears any transient nodes from the holder which pass the predicate
@ -290,7 +310,7 @@ public interface PermissionHolder {
* @param test the predicate to test for nodes which should be removed
* @since 3.2
*/
void clearMatchingTransient(Predicate<Node> test);
void clearMatchingTransient(@Nonnull Predicate<Node> test);
/**
* Clears all nodes held by the object
@ -305,7 +325,7 @@ public interface PermissionHolder {
* @param contextSet the contexts to filter by
* @since 3.2
*/
void clearNodes(ContextSet contextSet);
void clearNodes(@Nonnull ContextSet contextSet);
/**
* Clears all parent groups
@ -320,7 +340,7 @@ public interface PermissionHolder {
* @param contextSet the contexts to filter by
* @since 3.2
*/
void clearParents(ContextSet contextSet);
void clearParents(@Nonnull ContextSet contextSet);
/**
* Clears all meta held by the object
@ -335,7 +355,7 @@ public interface PermissionHolder {
* @param contextSet the contexts to filter by
* @since 3.2
*/
void clearMeta(ContextSet contextSet);
void clearMeta(@Nonnull ContextSet contextSet);
/**
* Clears all transient permissions the holder has.
@ -353,7 +373,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #hasPermission(Node)}
*/
@Deprecated
boolean hasPermission(String node, boolean b);
boolean hasPermission(@Nonnull String node, boolean b);
/**
* Checks to see the the object has a permission on a certain server
@ -367,7 +387,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #hasPermission(Node)}
*/
@Deprecated
boolean hasPermission(String node, boolean b, String server);
boolean hasPermission(@Nonnull String node, boolean b, @Nonnull String server);
/**
* Checks to see the the object has a permission on a certain server and world
@ -382,7 +402,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #hasPermission(Node)}
*/
@Deprecated
boolean hasPermission(String node, boolean b, String server, String world);
boolean hasPermission(@Nonnull String node, boolean b, @Nonnull String server, @Nonnull String world);
/**
* Checks to see the the object has a permission
@ -396,7 +416,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #hasPermission(Node)}
*/
@Deprecated
boolean hasPermission(String node, boolean b, boolean temporary);
boolean hasPermission(@Nonnull String node, boolean b, boolean temporary);
/**
* Checks to see the the object has a permission on a certain server
@ -411,7 +431,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #hasPermission(Node)}
*/
@Deprecated
boolean hasPermission(String node, boolean b, String server, boolean temporary);
boolean hasPermission(@Nonnull String node, boolean b, @Nonnull String server, boolean temporary);
/**
* Checks to see the the object has a permission on a certain server and world
@ -427,7 +447,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #hasPermission(Node)}
*/
@Deprecated
boolean hasPermission(String node, boolean b, String server, String world, boolean temporary);
boolean hasPermission(@Nonnull String node, boolean b, @Nonnull String server, @Nonnull String world, boolean temporary);
/**
* Checks to see if the object inherits a certain permission
@ -440,7 +460,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #hasPermission(Node)}
*/
@Deprecated
boolean inheritsPermission(String node, boolean b);
boolean inheritsPermission(@Nonnull String node, boolean b);
/**
* Checks to see the the object inherits a permission on a certain server
@ -454,7 +474,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #hasPermission(Node)}
*/
@Deprecated
boolean inheritsPermission(String node, boolean b, String server);
boolean inheritsPermission(@Nonnull String node, boolean b, @Nonnull String server);
/**
* Checks to see the the object inherits a permission on a certain server and world
@ -469,7 +489,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #hasPermission(Node)}
*/
@Deprecated
boolean inheritsPermission(String node, boolean b, String server, String world);
boolean inheritsPermission(@Nonnull String node, boolean b, @Nonnull String server, @Nonnull String world);
/**
* Checks to see if the object inherits a permission
@ -483,7 +503,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #hasPermission(Node)}
*/
@Deprecated
boolean inheritsPermission(String node, boolean b, boolean temporary);
boolean inheritsPermission(@Nonnull String node, boolean b, boolean temporary);
/**
* Checks to see if the object inherits a permission on a certain server
@ -498,7 +518,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #hasPermission(Node)}
*/
@Deprecated
boolean inheritsPermission(String node, boolean b, String server, boolean temporary);
boolean inheritsPermission(@Nonnull String node, boolean b, @Nonnull String server, boolean temporary);
/**
* Checks to see if the object inherits a permission on a certain server and world
@ -514,7 +534,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #hasPermission(Node)}
*/
@Deprecated
boolean inheritsPermission(String node, boolean b, String server, String world, boolean temporary);
boolean inheritsPermission(@Nonnull String node, boolean b, @Nonnull String server, @Nonnull String world, boolean temporary);
/**
* Sets a permission for the object
@ -527,7 +547,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #setPermission(Node)}
*/
@Deprecated
void setPermission(String node, boolean value) throws ObjectAlreadyHasException;
void setPermission(@Nonnull String node, boolean value) throws ObjectAlreadyHasException;
/**
* Sets a permission for the object on a specific server
@ -541,7 +561,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #setPermission(Node)}
*/
@Deprecated
void setPermission(String node, boolean value, String server) throws ObjectAlreadyHasException;
void setPermission(@Nonnull String node, boolean value, @Nonnull String server) throws ObjectAlreadyHasException;
/**
* Sets a permission for the object on a specific server and world
@ -556,7 +576,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #setPermission(Node)}
*/
@Deprecated
void setPermission(String node, boolean value, String server, String world) throws ObjectAlreadyHasException;
void setPermission(@Nonnull String node, boolean value, @Nonnull String server, @Nonnull String world) throws ObjectAlreadyHasException;
/**
* Sets a temporary permission for the object
@ -570,7 +590,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #setPermission(Node)}
*/
@Deprecated
void setPermission(String node, boolean value, long expireAt) throws ObjectAlreadyHasException;
void setPermission(@Nonnull String node, boolean value, long expireAt) throws ObjectAlreadyHasException;
/**
* Sets a temporary permission for the object on a specific server
@ -585,7 +605,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #setPermission(Node)}
*/
@Deprecated
void setPermission(String node, boolean value, String server, long expireAt) throws ObjectAlreadyHasException;
void setPermission(@Nonnull String node, boolean value, @Nonnull String server, long expireAt) throws ObjectAlreadyHasException;
/**
* Sets a temporary permission for the object on a specific server and world
@ -601,7 +621,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #setPermission(Node)}
*/
@Deprecated
void setPermission(String node, boolean value, String server, String world, long expireAt) throws ObjectAlreadyHasException;
void setPermission(String node, boolean value, @Nonnull String server, @Nonnull String world, long expireAt) throws ObjectAlreadyHasException;
/**
* Unsets a permission for the object
@ -614,7 +634,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #unsetPermission(Node)}
*/
@Deprecated
void unsetPermission(String node, boolean temporary) throws ObjectLacksException;
void unsetPermission(@Nonnull String node, boolean temporary) throws ObjectLacksException;
/**
* Unsets a permission for the object
@ -626,7 +646,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #unsetPermission(Node)}
*/
@Deprecated
void unsetPermission(String node) throws ObjectLacksException;
void unsetPermission(@Nonnull String node) throws ObjectLacksException;
/**
* Unsets a permission for the object on a specific server
@ -639,7 +659,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #unsetPermission(Node)}
*/
@Deprecated
void unsetPermission(String node, String server) throws ObjectLacksException;
void unsetPermission(@Nonnull String node, @Nonnull String server) throws ObjectLacksException;
/**
* Unsets a permission for the object on a specific server and world
@ -653,7 +673,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #unsetPermission(Node)}
*/
@Deprecated
void unsetPermission(String node, String server, String world) throws ObjectLacksException;
void unsetPermission(@Nonnull String node, @Nonnull String server, @Nonnull String world) throws ObjectLacksException;
/**
* Unsets a permission for the object on a specific server
@ -667,7 +687,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #unsetPermission(Node)}
*/
@Deprecated
void unsetPermission(String node, String server, boolean temporary) throws ObjectLacksException;
void unsetPermission(@Nonnull String node, @Nonnull String server, boolean temporary) throws ObjectLacksException;
/**
* Unsets a permission for the object on a specific server and world
@ -682,7 +702,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #unsetPermission(Node)}
*/
@Deprecated
void unsetPermission(String node, String server, String world, boolean temporary) throws ObjectLacksException;
void unsetPermission(@Nonnull String node, @Nonnull String server, @Nonnull String world, boolean temporary) throws ObjectLacksException;
/**
* Clears all nodes held by the object on a specific server
@ -692,7 +712,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #clearNodes(ContextSet)}
*/
@Deprecated
void clearNodes(String server);
void clearNodes(@Nullable String server);
/**
* Clears all nodes held by the object on a specific server and world
@ -703,7 +723,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #clearNodes(ContextSet)}
*/
@Deprecated
void clearNodes(String server, String world);
void clearNodes(@Nullable String server, @Nullable String world);
/**
* Clears all parents on a specific server
@ -713,7 +733,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #clearParents(ContextSet)}
*/
@Deprecated
void clearParents(String server);
void clearParents(@Nullable String server);
/**
* Clears all parents on a specific server and world
@ -724,7 +744,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #clearParents(ContextSet)}
*/
@Deprecated
void clearParents(String server, String world);
void clearParents(@Nullable String server, @Nullable String world);
/**
* Clears all meta held by the object on a specific server
@ -734,7 +754,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #clearMeta(ContextSet)}
*/
@Deprecated
void clearMeta(String server);
void clearMeta(@Nullable String server);
/**
* Clears all meta held by the object on a specific server and world
@ -745,7 +765,7 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #clearMeta(ContextSet)}
*/
@Deprecated
void clearMeta(String server, String world);
void clearMeta(@Nullable String server, @Nullable String world);
/**
* Clears all meta for a given key.
@ -757,6 +777,6 @@ public interface PermissionHolder {
* @deprecated in favour of {@link #clearMatching(Predicate)}
*/
@Deprecated
void clearMetaKeys(String key, String server, String world, boolean temporary);
void clearMetaKeys(@Nonnull String key, @Nullable String server, @Nullable String world, boolean temporary);
}

View File

@ -25,6 +25,8 @@
package me.lucko.luckperms.api;
import javax.annotation.Nonnull;
/**
* The platforms which LuckPerms can run on
*
@ -42,6 +44,7 @@ public enum PlatformType {
this.friendlyName = friendlyName;
}
@Nonnull
public String getFriendlyName() {
return friendlyName;
}

View File

@ -32,6 +32,9 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* A means of loading and saving data to/from the Storage provider.
*
@ -52,6 +55,7 @@ public interface Storage {
*
* @return the name of the implementation
*/
@Nonnull
String getName();
/**
@ -66,6 +70,7 @@ public interface Storage {
*
* @return an executor instance
*/
@Nonnull
Executor getSyncExecutor();
/**
@ -74,6 +79,7 @@ public interface Storage {
*
* @return an executor instance
*/
@Nonnull
Executor getAsyncExecutor();
/**
@ -83,13 +89,15 @@ public interface Storage {
* @return true if the operation completed successfully.
* @throws NullPointerException if entry is null
*/
CompletableFuture<Boolean> logAction(LogEntry entry);
@Nonnull
CompletableFuture<Boolean> logAction(@Nonnull LogEntry entry);
/**
* Loads and returns the entire log from storage
*
* @return a log instance, could be null if loading failed
*/
@Nonnull
CompletableFuture<Log> getLog();
/**
@ -100,7 +108,8 @@ public interface Storage {
* @return if the operation completed successfully
* @throws NullPointerException if uuid is null
*/
CompletableFuture<Boolean> loadUser(UUID uuid, String username);
@Nonnull
CompletableFuture<Boolean> loadUser(@Nonnull UUID uuid, @Nullable String username);
/**
* Loads a user's data from the main storage into the plugins local storage.
@ -109,7 +118,8 @@ public interface Storage {
* @return if the operation completed successfully
* @throws NullPointerException if uuid is null
*/
default CompletableFuture<Boolean> loadUser(UUID uuid) {
@Nonnull
default CompletableFuture<Boolean> loadUser(@Nonnull UUID uuid) {
return loadUser(uuid, null);
}
@ -121,13 +131,15 @@ public interface Storage {
* @throws NullPointerException if user is null
* @throws IllegalStateException if the user instance was not obtained from LuckPerms.
*/
CompletableFuture<Boolean> saveUser(User user);
@Nonnull
CompletableFuture<Boolean> saveUser(@Nonnull User user);
/**
* Removes users from the main storage who are "default". This is called every time the plugin loads.
*
* @return true if the operation completed successfully
*/
@Nonnull
CompletableFuture<Boolean> cleanupUsers();
/**
@ -136,6 +148,7 @@ public interface Storage {
*
* @return a set of uuids, or null if the operation failed.
*/
@Nonnull
CompletableFuture<Set<UUID>> getUniqueUsers();
/**
@ -146,7 +159,8 @@ public interface Storage {
* @throws NullPointerException if the permission is null
* @since 2.17
*/
CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(String permission);
@Nonnull
CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@Nonnull String permission);
/**
* Creates and loads a group into the plugins local storage
@ -156,7 +170,8 @@ public interface Storage {
* @throws NullPointerException if name is null
* @throws IllegalArgumentException if the name is invalid
*/
CompletableFuture<Boolean> createAndLoadGroup(String name);
@Nonnull
CompletableFuture<Boolean> createAndLoadGroup(@Nonnull String name);
/**
* Loads a group into the plugins local storage.
@ -166,13 +181,15 @@ public interface Storage {
* @throws NullPointerException if name is null
* @throws IllegalArgumentException if the name is invalid
*/
CompletableFuture<Boolean> loadGroup(String name);
@Nonnull
CompletableFuture<Boolean> loadGroup(@Nonnull String name);
/**
* Loads all groups from the storage into memory
*
* @return true if the operation completed successfully.
*/
@Nonnull
CompletableFuture<Boolean> loadAllGroups();
/**
@ -183,7 +200,8 @@ public interface Storage {
* @throws NullPointerException if group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
CompletableFuture<Boolean> saveGroup(Group group);
@Nonnull
CompletableFuture<Boolean> saveGroup(@Nonnull Group group);
/**
* Permanently deletes a group from storage.
@ -193,7 +211,8 @@ public interface Storage {
* @throws NullPointerException if group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
CompletableFuture<Boolean> deleteGroup(Group group);
@Nonnull
CompletableFuture<Boolean> deleteGroup(@Nonnull Group group);
/**
* Searches for a list of groups with a given permission.
@ -203,7 +222,8 @@ public interface Storage {
* @throws NullPointerException if the permission is null
* @since 2.17
*/
CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(String permission);
@Nonnull
CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@Nonnull String permission);
/**
* Creates and loads a track into the plugins local storage
@ -213,7 +233,8 @@ public interface Storage {
* @throws NullPointerException if name is null
* @throws IllegalArgumentException if the name is invalid
*/
CompletableFuture<Boolean> createAndLoadTrack(String name);
@Nonnull
CompletableFuture<Boolean> createAndLoadTrack(@Nonnull String name);
/**
* Loads a track into the plugins local storage.
@ -223,13 +244,15 @@ public interface Storage {
* @throws NullPointerException if name is null
* @throws IllegalArgumentException if the name is invalid
*/
CompletableFuture<Boolean> loadTrack(String name);
@Nonnull
CompletableFuture<Boolean> loadTrack(@Nonnull String name);
/**
* Loads all tracks from the storage into memory
*
* @return true if the operation completed successfully.
*/
@Nonnull
CompletableFuture<Boolean> loadAllTracks();
/**
@ -240,7 +263,8 @@ public interface Storage {
* @throws NullPointerException if track is null
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
*/
CompletableFuture<Boolean> saveTrack(Track track);
@Nonnull
CompletableFuture<Boolean> saveTrack(@Nonnull Track track);
/**
* Permanently deletes a track from storage
@ -250,7 +274,8 @@ public interface Storage {
* @throws NullPointerException if track is null
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
*/
CompletableFuture<Boolean> deleteTrack(Track track);
@Nonnull
CompletableFuture<Boolean> deleteTrack(@Nonnull Track track);
/**
* Saves UUID caching data to the global cache
@ -261,7 +286,8 @@ public interface Storage {
* @throws NullPointerException if either parameters are null
* @throws IllegalArgumentException if the username is invalid
*/
CompletableFuture<Boolean> saveUUIDData(String username, UUID uuid);
@Nonnull
CompletableFuture<Boolean> saveUUIDData(@Nonnull String username, @Nonnull UUID uuid);
/**
* Gets a UUID from a username
@ -271,7 +297,8 @@ public interface Storage {
* @throws NullPointerException if either parameters are null
* @throws IllegalArgumentException if the username is invalid
*/
CompletableFuture<UUID> getUUID(String username);
@Nonnull
CompletableFuture<UUID> getUUID(@Nonnull String username);
/**
* Gets a username from a UUID
@ -281,6 +308,7 @@ public interface Storage {
* @throws NullPointerException if either parameters are null
* @since 2.17
*/
CompletableFuture<String> getName(UUID uuid);
@Nonnull
CompletableFuture<String> getName(@Nonnull UUID uuid);
}

View File

@ -30,6 +30,9 @@ import me.lucko.luckperms.exceptions.ObjectLacksException;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* An ordered collection of groups for easy promotions and demotions
*/
@ -39,6 +42,7 @@ public interface Track {
* Gets the name of this track
* @return the name of this track
*/
@Nonnull
String getName();
/**
@ -48,6 +52,7 @@ public interface Track {
*
* @return an ordered {@link List} of the groups on this track
*/
@Nonnull
List<String> 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

View File

@ -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;
}

View File

@ -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.
*
* <p>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)}.</p>
*
* @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<UserData> 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<String> getGroupNames();
/**
@ -347,7 +356,8 @@ public interface User extends PermissionHolder {
* @deprecated in favour of just querying a users permissions
*/
@Deprecated
List<String> getLocalGroups(String server, String world);
@Nonnull
List<String> 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<String> getLocalGroups(String server);
@Nonnull
List<String> getLocalGroups(@Nonnull String server);
}

View File

@ -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);
}

View File

@ -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() + ", " +

View File

@ -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<String, String> getMetaMultimap();
/**
@ -61,6 +65,7 @@ public interface MetaData {
*
* @return an immutable map of meta
*/
@Nonnull
Map<String, String> getMeta();
/**
@ -69,6 +74,7 @@ public interface MetaData {
*
* @return a sorted map of prefixes
*/
@Nonnull
SortedMap<Integer, String> getPrefixes();
/**
@ -77,6 +83,7 @@ public interface MetaData {
*
* @return a sorted map of suffixes
*/
@Nonnull
SortedMap<Integer, String> 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();
}

View File

@ -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<String, Boolean> getImmutableBacking();
}

View File

@ -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> contexts);
void preCalculate(@Nonnull Set<Contexts> 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.

View File

@ -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<T> {
* @return the map
* @since 2.13
*/
MutableContextSet giveApplicableContext(T subject, MutableContextSet accumulator);
@Nonnull
MutableContextSet giveApplicableContext(@Nonnull T subject, @Nonnull MutableContextSet accumulator);
}

View File

@ -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<String, String> map) {
@Nonnull
static ImmutableContextSet fromMap(@Nonnull Map<String, String> 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<String, String>> iterable) {
@Nonnull
static ImmutableContextSet fromEntries(@Nonnull Iterable<? extends Map.Entry<String, String>> 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<String, String> multimap) {
@Nonnull
static ImmutableContextSet fromMultimap(@Nonnull Multimap<String, String> 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<Map.Entry<String, String>> toSet();
/**
@ -159,6 +172,7 @@ public interface ContextSet {
*
* @return an immutable map
*/
@Nonnull
Map<String, String> toMap();
/**
@ -167,6 +181,7 @@ public interface ContextSet {
* @return a multimap
* @since 2.16
*/
@Nonnull
Multimap<String, String> 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<String> getValues(String key);
@Nonnull
Set<String> 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<String> getAnyValue(String key) {
@Nonnull
default Optional<String> 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;

View File

@ -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<String, String> map) {
if (map == null) {
throw new NullPointerException("map");
}
@Nonnull
public static ImmutableContextSet fromMap(@Nonnull Map<String, String> map) {
Preconditions.checkNotNull(map, "map");
ImmutableSetMultimap.Builder<String, String> b = ImmutableSetMultimap.builder();
for (Map.Entry<String, String> 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<String, String>> iterable) {
if (iterable == null) {
throw new NullPointerException("iterable");
}
@Nonnull
public static ImmutableContextSet fromEntries(@Nonnull Iterable<? extends Map.Entry<String, String>> 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<String, String> multimap) {
if (multimap == null) {
throw new NullPointerException("multimap");
}
@Nonnull
public static ImmutableContextSet fromMultimap(@Nonnull Multimap<String, String> 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<Map.Entry<String, String>> toSet() {
return ImmutableSet.copyOf(map.entries());
}
@Override
@Nonnull
public Map<String, String> toMap() {
ImmutableMap.Builder<String, String> m = ImmutableMap.builder();
for (Map.Entry<String, String> e : map.entries()) {
@ -199,49 +191,35 @@ public final class ImmutableContextSet implements ContextSet {
}
@Override
@Nonnull
public Multimap<String, String> 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<String> getValues(String key) {
if (key == null) {
throw new NullPointerException("key");
}
public Set<String> getValues(@Nonnull String key) {
Preconditions.checkNotNull(key, "key");
Collection<String> 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<String> c = map.get(key);
if (c == null || c.isEmpty()) {
@ -274,7 +252,7 @@ public final class ImmutableContextSet implements ContextSet {
final Multimap<String, String> thisContexts = this.toMultimap();
final Multimap<String, String> otherContexts = other.toMultimap();
return thisContexts == null ? otherContexts == null : thisContexts.equals(otherContexts);
return thisContexts.equals(otherContexts);
}
@Override

View File

@ -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<String, String> map) {
if (map == null) {
throw new NullPointerException("map");
}
@Nonnull
public static MutableContextSet fromMap(@Nonnull Map<String, String> 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<String, String>> iterable) {
if (iterable == null) {
throw new NullPointerException("iterable");
}
@Nonnull
public static MutableContextSet fromEntries(@Nonnull Iterable<? extends Map.Entry<String, String>> 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<String, String> multimap) {
if (multimap == null) {
throw new NullPointerException("multimap");
}
@Nonnull
public static MutableContextSet fromMultimap(@Nonnull Multimap<String, String> 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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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 <T> the event class
* @return an event handler instance representing this subscription
*/
<T extends LuckPermsEvent> EventHandler<T> subscribe(Class<T> eventClass, Consumer<T> handler);
@Nonnull
<T extends LuckPermsEvent> EventHandler<T> subscribe(@Nonnull Class<T> eventClass, @Nonnull Consumer<T> handler);
/**
* Gets a set of all registered handlers for a given event
@ -52,6 +55,7 @@ public interface EventBus {
* @param <T> the event class
* @return an immutable set of event handlers
*/
<T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(Class<T> eventClass);
@Nonnull
<T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(@Nonnull Class<T> eventClass);
}

View File

@ -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<T extends LuckPermsEvent> {
*
* @return the event class
*/
@Nonnull
Class<T> getEventClass();
/**
@ -60,6 +63,7 @@ public interface EventHandler<T extends LuckPermsEvent> {
*
* @return the event consumer
*/
@Nonnull
Consumer<T> getConsumer();
/**

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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<Node> getExistingData();
/**
@ -55,6 +59,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent {
*
* @return the cause of the deletion
*/
@Nonnull
DeletionCause getCause();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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<Node> getDataBefore();
/**
@ -55,6 +59,7 @@ public interface NodeMutateEvent extends LuckPermsEvent {
*
* @return the data after the change
*/
@Nonnull
Set<Node> getDataAfter();
/**

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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<String> getExistingData();
/**
@ -54,6 +58,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent {
*
* @return the cause of the deletion
*/
@Nonnull
DeletionCause getCause();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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<String> getDataBefore();
/**
@ -54,6 +58,7 @@ public interface TrackMutateEvent extends LuckPermsEvent {
*
* @return the data after the change
*/
@Nonnull
List<String> getDataAfter();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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<String> getGroupFrom();
/**
@ -71,6 +77,7 @@ public interface UserTrackEvent extends LuckPermsEvent {
*
* @return the group the user was promoted/demoted to
*/
@Nonnull
Optional<String> getGroupTo();
}

View File

@ -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<MetaStackElement> 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();
}

View File

@ -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<Integer, String> current);
boolean shouldAccumulate(@Nonnull LocalizedNode node, @Nonnull ChatMetaType type, @Nullable Map.Entry<Integer, String> current);
}

View File

@ -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<MetaStackElement> fromString(String definition);
@Nonnull
Optional<MetaStackElement> 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<MetaStackElement> fromStrings(List<String> definitions);
@Nonnull
List<MetaStackElement> fromStrings(@Nonnull List<String> 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<MetaStackElement> elements, String startSpacer, String middleSpacer, String endSpacer);
@Nonnull
MetaStackDefinition createDefinition(@Nonnull List<MetaStackElement> elements, @Nonnull String startSpacer, @Nonnull String middleSpacer, @Nonnull String endSpacer);
}

View File

@ -217,18 +217,18 @@ public class ApiProvider implements LuckPermsApi {
@SuppressWarnings("unchecked")
@Override
public void registerContextCalculator(ContextCalculator<?> contextCalculator) {
public void registerContextCalculator(@NonNull ContextCalculator<?> contextCalculator) {
plugin.getContextManager().registerCalculator(contextCalculator);
}
@Override
public Optional<Contexts> getContextForUser(User user) {
public Optional<Contexts> getContextForUser(@NonNull User user) {
return Optional.ofNullable(plugin.getContextForUser(UserDelegate.cast(user)));
}
@SuppressWarnings("unchecked")
@Override
public ContextSet getContextForPlayer(Object player) {
public ContextSet getContextForPlayer(@NonNull Object player) {
return plugin.getContextManager().getApplicableContext(player);
}
}

View File

@ -26,6 +26,7 @@
package me.lucko.luckperms.common.utils;
import lombok.AllArgsConstructor;
import lombok.NonNull;
import me.lucko.luckperms.api.Logger;
import me.lucko.luckperms.common.commands.sender.Sender;
@ -36,17 +37,17 @@ public class SenderLogger implements Logger {
private final Sender console;
@Override
public void info(String s) {
public void info(@NonNull String s) {
Message.LOG_INFO.send(console, s);
}
@Override
public void warn(String s) {
public void warn(@NonNull String s) {
Message.LOG_WARN.send(console, s);
}
@Override
public void severe(String s) {
public void severe(@NonNull String s) {
Message.LOG_ERROR.send(console, s);
}
}