API changes for 2.17 - closes #123

This commit is contained in:
Luck 2017-01-16 20:01:41 +00:00
parent c0da9d49d9
commit aea44fc8bc
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
59 changed files with 898 additions and 325 deletions

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.16-SNAPSHOT</version> <version>2.17-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -27,13 +27,16 @@ import me.lucko.luckperms.api.LuckPermsApi;
import java.util.Optional; import java.util.Optional;
/** /**
* Static access to LuckPerms * Singleton for the {@link LuckPermsApi}.
*
* <p> Ideally, the ServiceManager for the platform should be used to obtain and cache an instance, however, this can be
* used if you need static access.
*/ */
public final class LuckPerms { public final class LuckPerms {
private static LuckPermsApi api = null; private static LuckPermsApi api = null;
/** /**
* Gets an instance of {@link LuckPermsApi} * Gets an instance of {@link LuckPermsApi}, throwing {@link IllegalStateException} if the API is not loaded.
* *
* @return an api instance * @return an api instance
* @throws IllegalStateException if the api is not loaded * @throws IllegalStateException if the api is not loaded
@ -46,8 +49,10 @@ public final class LuckPerms {
} }
/** /**
* Gets an instance of {@link LuckPermsApi} safely. Unlike {@link LuckPerms#getApi}, this method will not throw an * Gets an instance of {@link LuckPermsApi} safely.
* {@link IllegalStateException} if the api is not loaded, rather return an empty {@link Optional}. *
* <p> Unlike {@link LuckPerms#getApi}, this method will not throw an {@link IllegalStateException} if the API is
* not loaded, rather return an empty {@link Optional}.
* *
* @return an optional api instance * @return an optional api instance
*/ */

View File

@ -27,8 +27,9 @@ import me.lucko.luckperms.api.context.ContextSet;
import java.util.Map; import java.util.Map;
/** /**
* Represents the context and options for a permission lookup. * Context and options for a permission lookup.
* All values are immutable. *
* <p> All values are immutable.
* *
* @since 2.11 * @since 2.11
*/ */
@ -67,28 +68,34 @@ public class Contexts {
* The keys for servers and worlds are defined as static values. * The keys for servers and worlds are defined as static values.
*/ */
private final ContextSet context; private final ContextSet context;
/** /**
* The mode to parse defaults on Bukkit * The mode to parse defaults on Bukkit
* *
* @since 2.12 * @since 2.12
*/ */
private final boolean op; private final boolean op;
/** /**
* If global or non server specific nodes should be applied * If global or non server specific nodes should be applied
*/ */
private final boolean includeGlobal; private final boolean includeGlobal;
/** /**
* If global or non world specific nodes should be applied * If global or non world specific nodes should be applied
*/ */
private final boolean includeGlobalWorld; private final boolean includeGlobalWorld;
/** /**
* If parent groups should be applied * If parent groups should be applied
*/ */
private final boolean applyGroups; private final boolean applyGroups;
/** /**
* If global or non server specific group memberships should be applied * If global or non server specific group memberships should be applied
*/ */
private final boolean applyGlobalGroups; private final boolean applyGlobalGroups;
/** /**
* If global or non world specific group memberships should be applied * If global or non world specific group memberships should be applied
*/ */

View File

@ -28,7 +28,7 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
/** /**
* Interface for the internal Datastore instance * Deprecated Storage interface. Use {@link Storage} instead.
* *
* @deprecated as of version 2.14 in favour of {@link Storage}. * @deprecated as of version 2.14 in favour of {@link Storage}.
*/ */

View File

@ -26,14 +26,16 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException; import me.lucko.luckperms.exceptions.ObjectLacksException;
import java.util.List; import java.util.List;
import java.util.OptionalInt;
/** /**
* Interface for internal Group instances * A group which holds permission data.
*/ */
@SuppressWarnings("unused")
public interface Group extends PermissionHolder { public interface Group extends PermissionHolder {
/** /**
* Get the name of the group
*
* @return the name of the group * @return the name of the group
*/ */
String getName(); String getName();
@ -220,11 +222,6 @@ public interface Group extends PermissionHolder {
*/ */
void unsetInheritGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException; void unsetInheritGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException;
/**
* Clear all of the groups permission nodes
*/
void clearNodes();
/** /**
* Get a {@link List} of all of the groups the group inherits, on all servers * Get a {@link List} of all of the groups the group inherits, on all servers
* *
@ -236,6 +233,17 @@ public interface Group extends PermissionHolder {
* Get a {@link List} of the groups the group inherits on a specific server * Get a {@link List} of the groups the group inherits on a specific server
* *
* @param server the server to check * @param server the server to check
* @return a {@link List} of group names
* @throws NullPointerException if the server is null
* @throws IllegalArgumentException if the server is invalid
*/
List<String> getLocalGroups(String server);
/**
* Get a {@link List} of the groups the group inherits on a specific server and world
*
* @param server the server to check
* @param world the world to check * @param world the world to check
* @return a {@link List} of group names * @return a {@link List} of group names
* @throws NullPointerException if the server or world is null * @throws NullPointerException if the server or world is null
@ -244,12 +252,11 @@ public interface Group extends PermissionHolder {
List<String> getLocalGroups(String server, String world); List<String> getLocalGroups(String server, String world);
/** /**
* Get a {@link List} of the groups the group inherits on a specific server * Gets the weight of this group, is present.
* *
* @param server the server to check * @return the group weight
* @return a {@link List} of group names * @since 2.17
* @throws NullPointerException if the server is null
* @throws IllegalArgumentException if the server is invalid
*/ */
List<String> getLocalGroups(String server); OptionalInt getWeight();
} }

View File

@ -20,24 +20,75 @@
* SOFTWARE. * SOFTWARE.
*/ */
package me.lucko.luckperms.common.storage.holder; package me.lucko.luckperms.api;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import me.lucko.luckperms.api.Node;
import java.util.Optional; import java.util.Optional;
import java.util.OptionalLong; import java.util.OptionalLong;
/**
* A relationship between a Holder and a permission
*
* @param <T> the identifier type of the holder
* @since 2.17
*/
public interface HeldPermission<T> { public interface HeldPermission<T> {
/**
* Gets the holder of the permission
*
* @return the holder
*/
T getHolder(); T getHolder();
/**
* Gets the permission being held
*
* @return the permission
*/
String getPermission(); String getPermission();
/**
* Gets the value of the permission
*
* @return the value
*/
boolean getValue(); boolean getValue();
/**
* Gets the server where the permission is held
*
* @return the server
*/
Optional<String> getServer(); Optional<String> getServer();
/**
* Gets the world where the permission is held
*
* @return the world
*/
Optional<String> getWorld(); Optional<String> getWorld();
/**
* Gets the time in unix time when the permission will expire
*
* @return the expiry time
*/
OptionalLong getExpiry(); OptionalLong getExpiry();
/**
* Gets the context for the permission.
*
* @return the context
*/
Multimap<String, String> getContext(); Multimap<String, String> getContext();
/**
* Converts this permission into a Node
*
* @return a Node copy of this permission
*/
Node asNode(); Node asNode();
} }

View File

@ -28,22 +28,24 @@ import me.lucko.luckperms.api.data.MySQLConfiguration;
import java.util.Map; import java.util.Map;
/** /**
* A wrapper interface for the internal LuckPerms configuration, providing read only access. * Read-only access to the LuckPerms configuration settings
*/ */
@SuppressWarnings("unused")
public interface LPConfiguration { public interface LPConfiguration {
/** /**
* Returns the name of this server
* @return the name of this server * @return the name of this server
*/ */
String getServer(); String getServer();
/** /**
* Returns how often a sync task will run in minutes
* @return how often a sync task will run in minutes * @return how often a sync task will run in minutes
*/ */
int getSyncTime(); int getSyncTime();
/** /**
* Returns the default group, in a node representation
* @return the default group, in a node representation * @return the default group, in a node representation
* @deprecated as of 2.6, the default group is always "default" * @deprecated as of 2.6, the default group is always "default"
*/ */
@ -51,6 +53,7 @@ public interface LPConfiguration {
String getDefaultGroupNode(); String getDefaultGroupNode();
/** /**
* Returns the name of the default group
* @return the name of the default group * @return the name of the default group
* @deprecated as of 2.6, the default group is always "default" * @deprecated as of 2.6, the default group is always "default"
*/ */
@ -58,55 +61,65 @@ public interface LPConfiguration {
String getDefaultGroupName(); String getDefaultGroupName();
/** /**
* Returns if the users on this server will have their global permissions applied
* @return if the users on this server will have their global permissions applied * @return if the users on this server will have their global permissions applied
*/ */
boolean getIncludeGlobalPerms(); boolean getIncludeGlobalPerms();
/** /**
* Returns if the users on this server will have their global world permissions applied
* @return if the users on this server will have their global world permissions applied * @return if the users on this server will have their global world permissions applied
* @since 2.9 * @since 2.9
*/ */
boolean getIncludeGlobalWorldPerms(); boolean getIncludeGlobalWorldPerms();
/** /**
* Returns true if the platform is applying global groups
* @return true if the platform is applying global groups * @return true if the platform is applying global groups
* @since 2.9 * @since 2.9
*/ */
boolean getApplyGlobalGroups(); boolean getApplyGlobalGroups();
/** /**
* Returns true if the platform is applying global world groups
* @return true if the platform is applying global world groups * @return true if the platform is applying global world groups
* @since 2.9 * @since 2.9
*/ */
boolean getApplyGlobalWorldGroups(); boolean getApplyGlobalWorldGroups();
/** /**
* @return the online mode setting in the config * Returns the online mode setting
* @return the online mode setting
*/ */
boolean getOnlineMode(); boolean getOnlineMode();
/** /**
* Returns if LuckPerms is applying wildcard permissions
* @return if LuckPerms is applying wildcard permissions * @return if LuckPerms is applying wildcard permissions
*/ */
boolean getApplyWildcards(); boolean getApplyWildcards();
/** /**
* Returns if LuckPerms is resolving and applying regex permissions
* @return if LuckPerms is resolving and applying regex permissions * @return if LuckPerms is resolving and applying regex permissions
*/ */
boolean getApplyRegex(); boolean getApplyRegex();
/** /**
* Returns if LuckPerms is expanding shorthand permissions
* @return if LuckPerms is expanding shorthand permissions * @return if LuckPerms is expanding shorthand permissions
*/ */
boolean getApplyShorthand(); boolean getApplyShorthand();
/** /**
* Returns if LuckPerms will send notifications to users when permissions are modified
* @return if LuckPerms will send notifications to users when permissions are modified * @return if LuckPerms will send notifications to users when permissions are modified
* @since 2.7 * @since 2.7
*/ */
boolean getLogNotify(); boolean getLogNotify();
/** /**
* Returns true if permission checks are being recorded / debugged
* @return true if permission checks are being recorded / debugged * @return true if permission checks are being recorded / debugged
* @since 2.9 * @since 2.9
* @deprecated as this value is now always false. Functionality was replaced by the verbose command. * @deprecated as this value is now always false. Functionality was replaced by the verbose command.
@ -115,36 +128,42 @@ public interface LPConfiguration {
boolean getDebugPermissionChecks(); boolean getDebugPermissionChecks();
/** /**
* Returns true if the vanilla op system is enabled
* @return true if the vanilla op system is enabled * @return true if the vanilla op system is enabled
* @since 2.8 * @since 2.8
*/ */
boolean getEnableOps(); boolean getEnableOps();
/** /**
* Returns true if opped players are allowed to use LuckPerms commands
* @return true if opped players are allowed to use LuckPerms commands * @return true if opped players are allowed to use LuckPerms commands
* @since 2.8 * @since 2.8
*/ */
boolean getCommandsAllowOp(); boolean getCommandsAllowOp();
/** /**
* Returns true if auto op is enabled
* @return true if auto op is enabled * @return true if auto op is enabled
* @since 2.9 * @since 2.9
*/ */
boolean getAutoOp(); boolean getAutoOp();
/** /**
* Returns the name of the server used within Vault operations
* @return the name of the server used within Vault operations * @return the name of the server used within Vault operations
* @since 2.7 * @since 2.7
*/ */
String getVaultServer(); String getVaultServer();
/** /**
* Returns true if global permissions should be considered when retrieving meta or player groups
* @return true if global permissions should be considered when retrieving meta or player groups * @return true if global permissions should be considered when retrieving meta or player groups
* @since 2.7 * @since 2.7
*/ */
boolean getVaultIncludeGlobal(); boolean getVaultIncludeGlobal();
/** /**
* Returns the database values set in the configuration
* @return the database values set in the configuration * @return the database values set in the configuration
* @deprecated use {@link #getDatastoreConfig()} * @deprecated use {@link #getDatastoreConfig()}
*/ */
@ -153,22 +172,26 @@ public interface LPConfiguration {
MySQLConfiguration getDatabaseValues(); MySQLConfiguration getDatabaseValues();
/** /**
* Returns the values set for data storage in the configuration
* @return the values set for data storage in the configuration * @return the values set for data storage in the configuration
*/ */
DatastoreConfiguration getDatastoreConfig(); DatastoreConfiguration getDatastoreConfig();
/** /**
* Returns the storage method string from the configuration
* @return the storage method string from the configuration * @return the storage method string from the configuration
*/ */
String getStorageMethod(); String getStorageMethod();
/** /**
* Returns true if split storage is enabled
* @return true if split storage is enabled * @return true if split storage is enabled
* @since 2.7 * @since 2.7
*/ */
boolean getSplitStorage(); boolean getSplitStorage();
/** /**
* Returns a map of split storage options
* @return a map of split storage options, where the key is the storage section, and the value is the storage * @return a map of split storage options, where the key is the storage section, and the value is the storage
* method. For example: key = user, value = json * method. For example: key = user, value = json
* @since 2.7 * @since 2.7

View File

@ -23,14 +23,14 @@
package me.lucko.luckperms.api; package me.lucko.luckperms.api;
/** /**
* Represents a Node and where it was inherited from. * A node with a traceable origin
* *
* @since 2.11 * @since 2.11
*/ */
public interface LocalizedNode extends Node { public interface LocalizedNode extends Node {
/** /**
* Gets the node * Gets the delegate node
* *
* @return the node this instance is representing * @return the node this instance is representing
*/ */

View File

@ -27,10 +27,11 @@ import java.util.SortedSet;
import java.util.UUID; import java.util.UUID;
/** /**
* Represents the internal LuckPerms log. All content internally is immutable. You can add to the log using the {@link * Represents the internal LuckPerms log.
* Datastore}, and then request an updated copy. *
* <p> The returned instance provides a copy of the data at the time of retrieval. Any changes made to log entries will
* only apply to this instance of the log. You can add to the log using the {@link Storage}, and then request an updated copy.
*/ */
@SuppressWarnings("unused")
public interface Log { public interface Log {
/** /**
@ -48,6 +49,8 @@ public interface Log {
* *
* @param pageNo the page number * @param pageNo the page number
* @return the page content * @return the page content
* @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()}}
*/ */
SortedMap<Integer, LogEntry> getRecent(int pageNo); SortedMap<Integer, LogEntry> getRecent(int pageNo);
@ -69,6 +72,8 @@ public interface Log {
* @param pageNo the page number * @param pageNo the page number
* @param actor the uuid of the actor to filter by * @param actor the uuid of the actor to filter by
* @return the page content * @return the page content
* @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); SortedMap<Integer, LogEntry> getRecent(int pageNo, UUID actor);
@ -91,6 +96,8 @@ public interface Log {
* @param pageNo the page number * @param pageNo the page number
* @param uuid the uuid of the acted user to filter by * @param uuid the uuid of the acted user to filter by
* @return the page content * @return the page content
* @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); SortedMap<Integer, LogEntry> getUserHistory(int pageNo, UUID uuid);
@ -113,6 +120,8 @@ public interface Log {
* @param pageNo the page number * @param pageNo the page number
* @param name the name of the acted group to filter by * @param name the name of the acted group to filter by
* @return the page content * @return the page content
* @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); SortedMap<Integer, LogEntry> getGroupHistory(int pageNo, String name);
@ -141,9 +150,12 @@ public interface Log {
/** /**
* @param name the name to filter by * @param name the name to filter by
* @return the max page number allowed in the {@link #getTrackHistory(int, String)} method * @return the max page number allowed in the {@link #getTrackHistory(int, String)} method
* @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(String name);
/** /**
* @param query the query to filter by * @param query the query to filter by
* @return all content in this log where the content matches query * @return all content in this log where the content matches query
@ -156,6 +168,8 @@ public interface Log {
* @param pageNo the page number * @param pageNo the page number
* @param query the query to filter by * @param query the query to filter by
* @return the page content * @return the page content
* @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); SortedMap<Integer, LogEntry> getSearch(int pageNo, String query);

View File

@ -25,9 +25,10 @@ package me.lucko.luckperms.api;
import java.util.UUID; import java.util.UUID;
/** /**
* Represents a single entry in a log * A single entry in the log
*
* <p> Implements {@link Comparable} ordering based upon the timestamp of the entry.
*/ */
@SuppressWarnings({"unused", "WeakerAccess"})
public class LogEntry implements Comparable<LogEntry> { public class LogEntry implements Comparable<LogEntry> {
private static final String FORMAT = "&8(&e%s&8) [&a%s&8] (&b%s&8) &7--> &f%s"; private static final String FORMAT = "&8(&e%s&8) [&a%s&8] (&b%s&8) &7--> &f%s";
@ -154,9 +155,15 @@ public class LogEntry implements Comparable<LogEntry> {
@Override @Override
public String toString() { public String toString() {
return "LogEntry(timestamp=" + this.getTimestamp() + ", actor=" + this.getActor() + ", actorName=" + return "LogEntry(" +
this.getActorName() + ", type=" + this.getType() + ", acted=" + this.getActed() + ", actedName=" + "timestamp=" + this.getTimestamp() + ", " +
this.getActedName() + ", action=" + this.getAction() + ")"; "actor=" + this.getActor() + ", " +
"actorName=" + this.getActorName() + ", " +
"type=" + this.getType() + ", " +
"acted=" + this.getActed() + ", " +
"actedName=" + this.getActedName() + ", " +
"action=" + this.getAction() +
")";
} }
@Override @Override
@ -165,41 +172,25 @@ public class LogEntry implements Comparable<LogEntry> {
if (!(o instanceof LogEntry)) return false; if (!(o instanceof LogEntry)) return false;
final LogEntry other = (LogEntry) o; final LogEntry other = (LogEntry) o;
if (this.getTimestamp() != other.getTimestamp()) return false; if (this.getTimestamp() != other.getTimestamp()) return false;
final Object this$actor = this.getActor(); if (this.getActor() == null ? other.getActor() != null : !this.getActor().equals(other.getActor())) return false;
final Object other$actor = other.getActor(); if (this.getActorName() == null ? other.getActorName() != null : !this.getActorName().equals(other.getActorName())) return false;
if (this$actor == null ? other$actor != null : !this$actor.equals(other$actor)) return false;
final Object this$actorName = this.getActorName();
final Object other$actorName = other.getActorName();
if (this$actorName == null ? other$actorName != null : !this$actorName.equals(other$actorName)) return false;
if (this.getType() != other.getType()) return false; if (this.getType() != other.getType()) return false;
final Object this$acted = this.getActed(); if (this.getActed() == null ? other.getActed() != null : !this.getActed().equals(other.getActed())) return false;
final Object other$acted = other.getActed(); if (this.getActedName() == null ? other.getActedName() != null : !this.getActedName().equals(other.getActedName())) return false;
if (this$acted == null ? other$acted != null : !this$acted.equals(other$acted)) return false; return this.getAction() == null ? other.getAction() == null : this.getAction().equals(other.getAction());
final Object this$actedName = this.getActedName();
final Object other$actedName = other.getActedName();
if (this$actedName == null ? other$actedName != null : !this$actedName.equals(other$actedName)) return false;
final Object this$action = this.getAction();
final Object other$action = other.getAction();
return this$action == null ? other$action == null : this$action.equals(other$action);
} }
@Override @Override
public int hashCode() { public int hashCode() {
final int PRIME = 59; final int PRIME = 59;
int result = 1; int result = 1;
final long $timestamp = this.getTimestamp(); result = result * PRIME + (int) (this.getTimestamp() >>> 32 ^ this.getTimestamp());
result = result * PRIME + (int) ($timestamp >>> 32 ^ $timestamp); result = result * PRIME + (this.getActor() == null ? 43 : this.getActor().hashCode());
final Object $actor = this.getActor(); result = result * PRIME + (this.getActorName() == null ? 43 : this.getActorName().hashCode());
result = result * PRIME + ($actor == null ? 43 : $actor.hashCode());
final Object $actorName = this.getActorName();
result = result * PRIME + ($actorName == null ? 43 : $actorName.hashCode());
result = result * PRIME + this.getType(); result = result * PRIME + this.getType();
final Object $acted = this.getActed(); result = result * PRIME + (this.getActed() == null ? 43 : this.getActed().hashCode());
result = result * PRIME + ($acted == null ? 43 : $acted.hashCode()); result = result * PRIME + (this.getActedName() == null ? 43 : this.getActedName().hashCode());
final Object $actedName = this.getActedName(); result = result * PRIME + (this.getAction() == null ? 43 : this.getAction().hashCode());
result = result * PRIME + ($actedName == null ? 43 : $actedName.hashCode());
final Object $action = this.getAction();
result = result * PRIME + ($action == null ? 43 : $action.hashCode());
return result; return result;
} }
@ -214,6 +205,7 @@ public class LogEntry implements Comparable<LogEntry> {
protected LogEntryBuilder getThis() { protected LogEntryBuilder getThis() {
return this; return this;
} }
} }
public static abstract class AbstractLogEntryBuilder<T extends LogEntry, B extends AbstractLogEntryBuilder<T, B>> { public static abstract class AbstractLogEntryBuilder<T extends LogEntry, B extends AbstractLogEntryBuilder<T, B>> {
@ -311,9 +303,15 @@ public class LogEntry implements Comparable<LogEntry> {
@Override @Override
public String toString() { public String toString() {
return "LogEntry.LogEntryBuilder(timestamp=" + getTimestamp() + ", actor=" + getActor() + ", actorName=" + return "LogEntry.LogEntryBuilder(" +
getActorName() + ", type=" + getType() + ", acted=" + getActed() + ", actedName=" + getActedName() + "timestamp=" + this.getTimestamp() + ", " +
", action=" + getAction() + ")"; "actor=" + this.getActor() + ", " +
"actorName=" + this.getActorName() + ", " +
"type=" + this.getType() + ", " +
"acted=" + this.getActed() + ", " +
"actedName=" + this.getActedName() + ", " +
"action=" + this.getAction() +
")";
} }
} }

View File

@ -23,7 +23,7 @@
package me.lucko.luckperms.api; package me.lucko.luckperms.api;
/** /**
* A wrapper interface for platform logger instances. * A wrapper interface for platform logger instances
* *
* <p> Bukkit/Bungee both use java.util.logging, and Sponge uses org.slf4j. This class wraps those classes so the * <p> Bukkit/Bungee both use java.util.logging, and Sponge uses org.slf4j. This class wraps those classes so the
* commons module can access a logger. * commons module can access a logger.

View File

@ -23,6 +23,7 @@
package me.lucko.luckperms.api; package me.lucko.luckperms.api;
import me.lucko.luckperms.api.context.ContextListener; import me.lucko.luckperms.api.context.ContextListener;
import me.lucko.luckperms.api.context.ContextSet;
import me.lucko.luckperms.api.context.IContextCalculator; import me.lucko.luckperms.api.context.IContextCalculator;
import me.lucko.luckperms.api.event.LPListener; import me.lucko.luckperms.api.event.LPListener;
@ -31,9 +32,8 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
/** /**
* The root API interface in LuckPerms * The root API interface for LuckPerms
*/ */
@SuppressWarnings("unused")
public interface LuckPermsApi { public interface LuckPermsApi {
/** /**
@ -250,6 +250,13 @@ public interface LuckPermsApi {
*/ */
boolean isTrackLoaded(String name); boolean isTrackLoaded(String name);
/**
* Gets the node factory instance for the platform
*
* @return the node factory
*/
NodeFactory getNodeFactory();
/** /**
* Returns a permission builder instance * Returns a permission builder instance
* *
@ -279,11 +286,21 @@ public interface LuckPermsApi {
/** /**
* Gets a calculated context instance for the user using the rules of the platform. * Gets a calculated context instance for the user using the rules of the platform.
* These values are calculated using the options in the configuration, and the provided calculators. *
* <p> These values are calculated using the options in the configuration, and the provided calculators.
* *
* @param user the user to get contexts for * @param user the user to get contexts for
* @return an optional containing contexts. Will return empty if the user is not online. * @return an optional containing contexts. Will return empty if the user is not online.
*/ */
Optional<Contexts> getContextForUser(User user); Optional<Contexts> getContextForUser(User user);
/**
* Gets set of contexts applicable to a player using the platforms {@link IContextCalculator}s.
*
* @param player the player to calculate for. Must be the player instance for the platform.
* @return a set of contexts.
* @since 2.17
*/
ContextSet getContextForPlayer(Object player);
} }

View File

@ -23,7 +23,7 @@
package me.lucko.luckperms.api; package me.lucko.luckperms.api;
/** /**
* Exposes any networking provider being used on the platform. e.g. Redis * A means to push changes to other servers using the platforms networking
* *
* @since 2.14 * @since 2.14
*/ */
@ -31,7 +31,9 @@ public interface MessagingService {
/** /**
* Uses the messaging service to inform other servers about changes. * Uses the messaging service to inform other servers about changes.
* This will push the update asynchronously, and this method will return almost immediately. *
* <p> This will push the update asynchronously, and this method will return immediately. Calling this method is
* equivalent to running "/lp networksync", except will not sync this server.
*/ */
void pushUpdate(); void pushUpdate();

View File

@ -31,12 +31,12 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
/** /**
* Represents an immutable node object * An immutable permission node
*
* <p> Use {@link LuckPermsApi#buildNode(String)} to get an instance. * <p> Use {@link LuckPermsApi#buildNode(String)} to get an instance.
* *
* @since 2.6 * @since 2.6
*/ */
@SuppressWarnings("unused")
public interface Node extends Map.Entry<String, Boolean> { public interface Node extends Map.Entry<String, Boolean> {
/** /**

View File

@ -0,0 +1,101 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.api;
/**
* Builds {@link Node} instances
*
* @since 2.17
*/
public interface NodeFactory {
/**
* Creates a node from a serialised node string
*
* @param serialisedPermission the serialised permission string
* @param value the value of the node
* @return a node instance
* @throws NullPointerException if the permission is null
*/
Node fromSerialisedNode(String serialisedPermission, boolean value);
/**
* Creates a new node builder from a given base permission string
*
* @param permission the permission
* @return a node builder instance
* @throws NullPointerException if the permission is null
*/
Node.Builder newBuilder(String permission);
/**
* Creates a node builder instance from an existing node
*
* @param other the other node
* @return a node builder instance
* @throws NullPointerException if the other node is null
*/
Node.Builder newBuilderFromExisting(Node other);
/**
* Creates a node builder from a serialised node string
* @param serialisedPermission the serialised permission string
* @param value the value of the node
* @return a node builder instance
* @throws NullPointerException if the permission is null
*/
Node.Builder newBuilderFromSerialisedNode(String serialisedPermission, boolean value);
/**
* Creates a node builder from a key value pair
*
* @param key the key
* @param value the value
* @return a node builder instance
* @throws NullPointerException if the key or value is null
*/
Node.Builder makeMetaNode(String key, String value);
/**
* Creates a node builder from a prefix string and priority
*
* @param priority the priority
* @param prefix the prefix string
* @return a node builder instance
* @throws NullPointerException if the prefix is null
*/
Node.Builder makePrefixNode(int priority, String prefix);
/**
* Creates a node builder from a prefix string and priority
*
* @param priority the priority
* @param suffix the suffix string
* @return a node builder instance
* @throws NullPointerException if the suffix is null
*/
Node.Builder makeSuffixNode(int priority, String suffix);
}

View File

@ -31,19 +31,24 @@ import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
/** /**
* Interface for internal PermissionHolder (user/group) instances * An object capable of holding permissions
*
* <p> Any changes made will be lost unless the instance is saved back to the {@link Storage}.
*/ */
@SuppressWarnings("unused")
public interface PermissionHolder { public interface PermissionHolder {
/** /**
* @return the identifier for this object. either a uuid string or name However, you should really just use {@link * Gets the objects name
* User#getUuid()}, {@link User#getName()} or {@link Group#getName()} *
* <p> {@link User#getUuid()}, {@link User#getName()} or {@link Group#getName()} should normally be used instead of
* this method.
*
* @return the identifier for this object. Either a uuid string or name.
*/ */
String getObjectName(); String getObjectName();
/** /**
* Gets an immutable Set of the objects permission nodes * Gets a sorted set of all held permissions.
* *
* @return an immutable set of permissions in priority order * @return an immutable set of permissions in priority order
* @since 2.6 * @since 2.6
@ -51,20 +56,22 @@ public interface PermissionHolder {
SortedSet<? extends Node> getPermissions(); SortedSet<? extends Node> getPermissions();
/** /**
* Similar to {@link #getPermissions()}, except excluding transient permissions * Similar to {@link #getPermissions()}, except without transient permissions
* *
* @return a set of nodes * @return a set of nodes
* @since 2.6 * @since 2.6
*/ */
Set<Node> getEnduringPermissions(); Set<? extends Node> getEnduringPermissions();
/** /**
* Similar to {@link #getPermissions()}, except excluding non-transient permissions * Gets an immutable set of all transiently held permissions.
*
* <p> Transient permissions only exist for the duration of the session.
* *
* @return a set of nodes * @return a set of nodes
* @since 2.6 * @since 2.6
*/ */
Set<Node> getTransientPermissions(); Set<? extends Node> getTransientPermissions();
/** /**
@ -91,7 +98,7 @@ public interface PermissionHolder {
SortedSet<LocalizedNode> getAllNodes(Contexts contexts); SortedSet<LocalizedNode> getAllNodes(Contexts contexts);
/** /**
* Gets a mutable set of the nodes that is objects has and inherits, filtered by context. * Gets a mutable set of the nodes that this object has and inherits, filtered by context.
* Unlike {@link #getAllNodes(Contexts)}, this method WILL filter individual nodes, and only return ones that fully * Unlike {@link #getAllNodes(Contexts)}, this method WILL filter individual nodes, and only return ones that fully
* meet the context provided. * meet the context provided.
* *
@ -102,6 +109,14 @@ public interface PermissionHolder {
*/ */
Set<LocalizedNode> getAllNodesFiltered(Contexts contexts); Set<LocalizedNode> getAllNodesFiltered(Contexts contexts);
/**
* Converts the output of {@link #getAllNodesFiltered(Contexts)}, and expands shorthand permissions.
* @param contexts the context for the lookup
* @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);
/** /**
* Gets an immutable Map of the objects permission nodes * Gets an immutable Map of the objects permission nodes
* *
@ -111,6 +126,11 @@ public interface PermissionHolder {
@Deprecated @Deprecated
Map<String, Boolean> getNodes(); Map<String, Boolean> getNodes();
/**
* Removes temporary permissions that have expired
*/
void auditTemporaryPermissions();
/** /**
* Checks to see if the object has a certain permission * Checks to see if the object has a certain permission
* *
@ -508,6 +528,109 @@ public interface PermissionHolder {
@Deprecated @Deprecated
void unsetPermission(String node, String server, String world, boolean temporary) throws ObjectLacksException; void unsetPermission(String node, String server, String world, boolean temporary) throws ObjectLacksException;
/**
* Clears all nodes held by the object
*
* @since 2.17
*/
void clearNodes();
/**
* Clears all nodes held by the object on a specific server
*
* @param server the server to filter by, can be null
* @since 2.17
*/
void clearNodes(String server);
/**
* Clears all nodes held by the object on a specific server and world
*
* @param server the server to filter by, can be null
* @param world the world to filter by, can be null
* @since 2.17
*/
void clearNodes(String server, String world);
/**
* Clears all parent groups
*
* @since 2.17
*/
void clearParents();
/**
* Clears all parents on a specific server
*
* @param server the server to filter by, can be null
* @since 2.17
*/
void clearParents(String server);
/**
* Clears all parents on a specific server and world
*
* @param server the server to filter by, can be null
* @param world the world to filter by, can be null
* @since 2.17
*/
void clearParents(String server, String world);
/**
* Clears all meta held by the object
*
* @since 2.17
*/
void clearMeta();
/**
* Clears all meta held by the object on a specific server
*
* @param server the server to filter by, can be null
* @since 2.17
*/
void clearMeta(String server);
/**
* Clears all meta held by the object on a specific server and world
*
* @param server the server to filter by, can be null
* @param world the world to filter by, can be null
* @since 2.17
*/
void clearMeta(String server, String world);
/**
* Clears all meta for a given key.
*
* @param key the meta key
* @param server the server to filter by, can be null
* @param world the world to filter by, can be null
* @param temporary whether the query is for temporary nodes or not.
*/
void clearMetaKeys(String key, String server, String world, boolean temporary);
/**
* Clears all transient permissions the holder has.
*/
void clearTransientNodes();
/**
* Processes the nodes and returns the non-temporary ones.
*
* @return a set of permanent nodes
* @since 2.6
*/
Set<Node> getPermanentPermissionNodes();
/**
* Processes the nodes and returns the temporary ones.
*
* @return a set of temporary nodes
* @since 2.6
*/
Set<Node> getTemporaryPermissionNodes();
/** /**
* Gets the permissions and inherited permissions that apply to a specific server and world * Gets the permissions and inherited permissions that apply to a specific server and world
* *
@ -581,14 +704,6 @@ public interface PermissionHolder {
@Deprecated @Deprecated
Map<Map.Entry<String, Boolean>, Long> getTemporaryNodes(); Map<Map.Entry<String, Boolean>, Long> getTemporaryNodes();
/**
* Processes the nodes and returns the temporary ones.
*
* @return a set of temporary nodes
* @since 2.6
*/
Set<Node> getTemporaryPermissionNodes();
/** /**
* Processes the nodes and returns the non-temporary ones. * Processes the nodes and returns the non-temporary ones.
* *
@ -598,17 +713,4 @@ public interface PermissionHolder {
@Deprecated @Deprecated
Map<String, Boolean> getPermanentNodes(); Map<String, Boolean> getPermanentNodes();
/**
* Processes the nodes and returns the non-temporary ones.
*
* @return a set of permanent nodes
* @since 2.6
*/
Set<Node> getPermanentPermissionNodes();
/**
* Removes temporary permissions that have expired
*/
void auditTemporaryPermissions();
} }

View File

@ -23,7 +23,7 @@
package me.lucko.luckperms.api; package me.lucko.luckperms.api;
/** /**
* Represents the platform type that LuckPerms is running on * The platforms which LuckPerms can run on
* *
* @since 2.7 * @since 2.7
*/ */

View File

@ -22,6 +22,7 @@
package me.lucko.luckperms.api; package me.lucko.luckperms.api;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -29,7 +30,7 @@ import java.util.concurrent.Executor;
import java.util.function.Consumer; import java.util.function.Consumer;
/** /**
* Interface for the internal Storage instance * A means of loading and saving data to/from the Storage provider.
* *
* <p>All methods return {@link CompletableFuture}s, which will be populated with the result once the data has been * <p>All methods return {@link CompletableFuture}s, which will be populated with the result once the data has been
* loaded asynchronously. Care should be taken when using the methods to ensure that the main server thread is not * loaded asynchronously. Care should be taken when using the methods to ensure that the main server thread is not
@ -124,6 +125,16 @@ public interface Storage {
*/ */
CompletableFuture<Set<UUID>> getUniqueUsers(); CompletableFuture<Set<UUID>> getUniqueUsers();
/**
* Searches for a list of users with a given permission.
*
* @param permission the permission to search for
* @return a list of held permissions, or null if the operation failed
* @throws NullPointerException if the permission is null
* @since 2.17
*/
CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(String permission);
/** /**
* Creates and loads a group into the plugins local storage * Creates and loads a group into the plugins local storage
* *
@ -171,6 +182,16 @@ public interface Storage {
*/ */
CompletableFuture<Boolean> deleteGroup(Group group); CompletableFuture<Boolean> deleteGroup(Group group);
/**
* Searches for a list of groups with a given permission.
*
* @param permission the permission to search for
* @return a list of held permissions, or null if the operation failed
* @throws NullPointerException if the permission is null
* @since 2.17
*/
CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(String permission);
/** /**
* Creates and loads a track into the plugins local storage * Creates and loads a track into the plugins local storage
* *
@ -239,4 +260,14 @@ public interface Storage {
*/ */
CompletableFuture<UUID> getUUID(String username); CompletableFuture<UUID> getUUID(String username);
/**
* Gets a username from a UUID
*
* @param uuid the corresponding uuid
* @return a name string, could be null
* @throws NullPointerException if either parameters are null
* @since 2.17
*/
CompletableFuture<String> getName(UUID uuid);
} }

View File

@ -28,19 +28,20 @@ import me.lucko.luckperms.exceptions.ObjectLacksException;
import java.util.List; import java.util.List;
/** /**
* Interface for internal Track instances * An ordered collection of groups for easy promotions and demotions
*/ */
@SuppressWarnings("unused")
public interface Track { public interface Track {
/** /**
* Gets the name of this track
* @return the name of this track * @return the name of this track
*/ */
String getName(); String getName();
/** /**
* Gets an ordered list of the groups on this track * Gets an ordered list of the groups on this track
* Index 0 is the first/lowest group in (or start of) the track *
* <p> Index 0 is the first/lowest group in (or start of) the track
* *
* @return an ordered {@link List} of the groups on this track * @return an ordered {@link List} of the groups on this track
*/ */
@ -136,7 +137,7 @@ public interface Track {
boolean containsGroup(String group); boolean containsGroup(String group);
/** /**
* Clear all of the groups within this track * Clear all of the groups from this track
*/ */
void clearGroups(); void clearGroups();

View File

@ -23,14 +23,34 @@
package me.lucko.luckperms.api; package me.lucko.luckperms.api;
/** /**
* Represents a permission value * Represents a permission setting.
*
* <p> Consider a value of {@link #FALSE} to be a "negated" setting, and a value of {@link #UNDEFINED} to be a
* non-existent value.
*/ */
public enum Tristate { public enum Tristate {
/**
* A value indicating a holder has a permission set.
*/
TRUE(true), TRUE(true),
/**
* A value indicating a holder has a negated value for a permission.
*/
FALSE(false), FALSE(false),
/**
* A value indicating a holder doesn't have a value for a permission set.
*/
UNDEFINED(false); UNDEFINED(false);
/**
* Converts from {@link Boolean} a boolean
*
* @param b the boolean
* @return {@link #TRUE} or {@link #FALSE}, depending on the value of the boolean.
*/
public static Tristate fromBoolean(boolean b) { public static Tristate fromBoolean(boolean b) {
return b ? TRUE : FALSE; return b ? TRUE : FALSE;
} }
@ -41,6 +61,12 @@ public enum Tristate {
this.booleanValue = booleanValue; this.booleanValue = booleanValue;
} }
/**
* Returns the value of the Tristate as a boolean.
* <p> A value of {@link #UNDEFINED} converts to false.
*
* @return a boolean representation of the Tristate.
*/
public boolean asBoolean() { public boolean asBoolean() {
return booleanValue; return booleanValue;
} }

View File

@ -31,17 +31,20 @@ import java.util.Optional;
import java.util.UUID; import java.util.UUID;
/** /**
* Interface for internal User instances * A player holding permission data
*/ */
@SuppressWarnings("unused")
public interface User extends PermissionHolder { public interface User extends PermissionHolder {
/** /**
* Gets the users unique ID
*
* @return the users Mojang assigned unique id * @return the users Mojang assigned unique id
*/ */
UUID getUuid(); UUID getUuid();
/** /**
* Gets the users username
*
* @return the Users Username * @return the Users Username
*/ */
String getName(); String getName();
@ -64,7 +67,10 @@ public interface User extends PermissionHolder {
void setPrimaryGroup(String group) throws ObjectAlreadyHasException; void setPrimaryGroup(String group) throws ObjectAlreadyHasException;
/** /**
* Refresh and re-assign the users permissions * Refresh and re-assign the users permissions.
*
* <p> This request is not buffered, and the refresh call will be ran directly. This should ideally be called on
* an asynchronous thread.
*/ */
void refreshPermissions(); void refreshPermissions();
@ -76,6 +82,13 @@ public interface User extends PermissionHolder {
*/ */
Optional<UserData> getUserDataCache(); Optional<UserData> getUserDataCache();
/**
* Sets up the users data cache, if the don't have one setup already.
*
* @since 2.17
*/
void setupDataCache();
/** /**
* Check to see if the user is a member of a group * Check to see if the user is a member of a group
* *
@ -255,11 +268,6 @@ public interface User extends PermissionHolder {
*/ */
void removeGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException; void removeGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException;
/**
* Clear all of the users permission nodes
*/
void clearNodes();
/** /**
* Get a {@link List} of all of the groups the user is a member of, on all servers * Get a {@link List} of all of the groups the user is a member of, on all servers
* *

View File

@ -28,16 +28,15 @@ import java.util.UUID;
* A UUID cache for online users, between external Mojang UUIDs, and internal LuckPerms UUIDs. * A UUID cache for online users, between external Mojang UUIDs, and internal LuckPerms UUIDs.
* *
* <p> This UuidCache is a means of allowing users to have the same internal UUID across a network of offline mode * <p> This UuidCache is a means of allowing users to have the same internal UUID across a network of offline mode
* servers or mixed offline mode and online mode servers. Platforms running in offline mode generate a random UUID for a * servers or mixed offline mode and online mode servers. Platforms running in offline mode generate a UUID for a
* user when they first join the server, but this UUID will then not be consistent across the network. LuckPerms will * user when they first join the server, but this UUID will then not be consistent across the network. LuckPerms will
* instead check the datastore cache, to get a UUID for a user that is consistent across an entire network. * instead check the datastore cache, to get a UUID for a user that is consistent across an entire network.
* *
* <p> If you want to get a user object from the Storage using the api on a server in offline mode, you will need to use * <p> If you want to get a user object from the Storage using the api on a server in offline mode, you will need to use
* this cache, OR use Storage#getUUID, for users that are not online. * this cache, OR use Storage#getUUID, for users that are not online.
* *
* <p> WARNING: THIS IS ONLY EFFECTIVE FOR ONLINE PLAYERS. USE THE DATASTORE METHODS FOR OFFLINE PLAYERS. * <p> THIS IS ONLY EFFECTIVE FOR ONLINE PLAYERS. USE THE DATASTORE METHODS FOR OFFLINE PLAYERS.
*/ */
@SuppressWarnings("unused")
public interface UuidCache { public interface UuidCache {
/** /**

View File

@ -44,7 +44,8 @@ public interface PermissionData {
/** /**
* Invalidates the underlying permission calculator cache. * Invalidates the underlying permission calculator cache.
* Can be called to allow for an update in defaults. *
* <p> Can be called to allow for an update in defaults.
*/ */
void invalidateCache(); void invalidateCache();

View File

@ -38,7 +38,8 @@ public interface UserData {
/** /**
* Gets PermissionData from the cache, given a specified context. * Gets PermissionData from the cache, given a specified context.
* If the data is not cached, it is calculated. Therefore, this call could be costly. *
* <p> If the data is not cached, it is calculated. Therefore, this call could be costly.
* *
* @param contexts the contexts to get the permission data in * @param contexts the contexts to get the permission data in
* @return a permission data instance * @return a permission data instance
@ -48,7 +49,8 @@ public interface UserData {
/** /**
* Gets MetaData from the cache, given a specified context. * Gets MetaData from the cache, given a specified context.
* If the data is not cached, it is calculated. Therefore, this call could be costly. *
* <p> If the data is not cached, it is calculated. Therefore, this call could be costly.
* *
* @param contexts the contexts to get the permission data in * @param contexts the contexts to get the permission data in
* @return a meta data instance * @return a meta data instance
@ -75,8 +77,10 @@ public interface UserData {
MetaData calculateMeta(Contexts contexts); MetaData calculateMeta(Contexts contexts);
/** /**
* Calculates permission data and stores it in the cache. If there is already data cached for the given contexts, * Calculates permission data and stores it in the cache.
* and if the resultant output is different, the cached value is updated. *
* <p> If there is already data cached for the given contexts, and if the resultant output is different,
* the cached value is updated.
* *
* @param contexts the contexts to recalculate in. * @param contexts the contexts to recalculate in.
* @throws NullPointerException if contexts is null * @throws NullPointerException if contexts is null
@ -84,8 +88,10 @@ public interface UserData {
void recalculatePermissions(Contexts contexts); void recalculatePermissions(Contexts contexts);
/** /**
* Calculates meta data and stores it in the cache. If there is already data cached for the given contexts, * Calculates meta data and stores it in the cache.
* and if the resultant output is different, the cached value is updated. *
* <p> If there is already data cached for the given contexts, and if the resultant output is different,
* the cached value is updated.
* *
* @param contexts the contexts to recalculate in. * @param contexts the contexts to recalculate in.
* @throws NullPointerException if contexts is null * @throws NullPointerException if contexts is null
@ -111,8 +117,9 @@ public interface UserData {
void preCalculate(Set<Contexts> contexts); void preCalculate(Set<Contexts> contexts);
/** /**
* Ensures that PermissionData and MetaData is cached for a context. If the cache does not contain any data for the * Ensures that PermissionData and MetaData is cached for a context.
* context, it will be calculated and saved. *
* <p> If the cache does not contain any data for the context, it will be calculated and saved.
* *
* @param contexts the contexts to pre-calculate for * @param contexts the contexts to pre-calculate for
* @throws NullPointerException if contexts is null * @throws NullPointerException if contexts is null

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.16-SNAPSHOT</version> <version>2.17-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.16-SNAPSHOT</version> <version>2.17-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.16-SNAPSHOT</version> <version>2.17-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.16-SNAPSHOT</version> <version>2.17-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.16-SNAPSHOT</version> <version>2.17-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -35,24 +35,26 @@ import me.lucko.luckperms.api.Logger;
import me.lucko.luckperms.api.LuckPermsApi; import me.lucko.luckperms.api.LuckPermsApi;
import me.lucko.luckperms.api.MessagingService; import me.lucko.luckperms.api.MessagingService;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.NodeFactory;
import me.lucko.luckperms.api.PlatformType; import me.lucko.luckperms.api.PlatformType;
import me.lucko.luckperms.api.Storage; import me.lucko.luckperms.api.Storage;
import me.lucko.luckperms.api.Track; import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.User; import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.UuidCache; import me.lucko.luckperms.api.UuidCache;
import me.lucko.luckperms.api.context.ContextListener; import me.lucko.luckperms.api.context.ContextListener;
import me.lucko.luckperms.api.context.ContextSet;
import me.lucko.luckperms.api.context.IContextCalculator; import me.lucko.luckperms.api.context.IContextCalculator;
import me.lucko.luckperms.api.event.LPEvent; import me.lucko.luckperms.api.event.LPEvent;
import me.lucko.luckperms.api.event.LPListener; import me.lucko.luckperms.api.event.LPListener;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.api.internal.DatastoreLink; import me.lucko.luckperms.common.api.delegate.DatastoreDelegate;
import me.lucko.luckperms.common.api.internal.GroupLink; import me.lucko.luckperms.common.api.delegate.GroupDelegate;
import me.lucko.luckperms.common.api.internal.LPConfigurationLink; import me.lucko.luckperms.common.api.delegate.LPConfigurationDelegate;
import me.lucko.luckperms.common.api.internal.StorageLink; import me.lucko.luckperms.common.api.delegate.NodeFactoryDelegate;
import me.lucko.luckperms.common.api.internal.TrackLink; import me.lucko.luckperms.common.api.delegate.StorageDelegate;
import me.lucko.luckperms.common.api.internal.UserLink; import me.lucko.luckperms.common.api.delegate.TrackDelegate;
import me.lucko.luckperms.common.api.internal.Utils; import me.lucko.luckperms.common.api.delegate.UserDelegate;
import me.lucko.luckperms.common.api.internal.UuidCacheLink; import me.lucko.luckperms.common.api.delegate.UuidCacheDelegate;
import me.lucko.luckperms.common.core.NodeBuilder; import me.lucko.luckperms.common.core.NodeBuilder;
import me.lucko.luckperms.common.core.UserIdentifier; import me.lucko.luckperms.common.core.UserIdentifier;
@ -61,7 +63,7 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static me.lucko.luckperms.common.api.internal.Utils.checkNode; import static me.lucko.luckperms.common.api.ApiUtils.checkNode;
/** /**
* Implements the LuckPerms API using the plugin instance * Implements the LuckPerms API using the plugin instance
@ -92,7 +94,7 @@ public class ApiProvider implements LuckPermsApi {
@Override @Override
public double getApiVersion() { public double getApiVersion() {
return 2.16; return 2.17;
} }
@Override @Override
@ -117,18 +119,18 @@ public class ApiProvider implements LuckPermsApi {
@Override @Override
public LPConfiguration getConfiguration() { public LPConfiguration getConfiguration() {
return new LPConfigurationLink(plugin.getConfiguration()); return new LPConfigurationDelegate(plugin.getConfiguration());
} }
@Override @Override
public Storage getStorage() { public Storage getStorage() {
return new StorageLink(plugin, plugin.getStorage()); return new StorageDelegate(plugin, plugin.getStorage());
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public Datastore getDatastore() { public Datastore getDatastore() {
return new DatastoreLink(plugin, plugin.getStorage()); return new DatastoreDelegate(plugin, plugin.getStorage());
} }
@Override @Override
@ -138,7 +140,7 @@ public class ApiProvider implements LuckPermsApi {
@Override @Override
public UuidCache getUuidCache() { public UuidCache getUuidCache() {
return new UuidCacheLink(plugin.getUuidCache()); return new UuidCacheDelegate(plugin.getUuidCache());
} }
@Override @Override
@ -149,7 +151,7 @@ public class ApiProvider implements LuckPermsApi {
@Override @Override
public User getUser(@NonNull UUID uuid) { public User getUser(@NonNull UUID uuid) {
final me.lucko.luckperms.common.core.model.User user = plugin.getUserManager().get(uuid); final me.lucko.luckperms.common.core.model.User user = plugin.getUserManager().get(uuid);
return user == null ? null : new UserLink(user); return user == null ? null : new UserDelegate(user);
} }
@Override @Override
@ -160,7 +162,7 @@ public class ApiProvider implements LuckPermsApi {
@Override @Override
public User getUser(@NonNull String name) { public User getUser(@NonNull String name) {
final me.lucko.luckperms.common.core.model.User user = plugin.getUserManager().getByUsername(name); final me.lucko.luckperms.common.core.model.User user = plugin.getUserManager().getByUsername(name);
return user == null ? null : new UserLink(user); return user == null ? null : new UserDelegate(user);
} }
@Override @Override
@ -170,7 +172,7 @@ public class ApiProvider implements LuckPermsApi {
@Override @Override
public Set<User> getUsers() { public Set<User> getUsers() {
return plugin.getUserManager().getAll().values().stream().map(UserLink::new).collect(Collectors.toSet()); return plugin.getUserManager().getAll().values().stream().map(UserDelegate::new).collect(Collectors.toSet());
} }
@Override @Override
@ -180,14 +182,14 @@ public class ApiProvider implements LuckPermsApi {
@Override @Override
public void cleanupUser(@NonNull User user) { public void cleanupUser(@NonNull User user) {
Utils.checkUser(user); ApiUtils.checkUser(user);
plugin.getUserManager().cleanup(((UserLink) user).getMaster()); plugin.getUserManager().cleanup(((UserDelegate) user).getMaster());
} }
@Override @Override
public Group getGroup(@NonNull String name) { public Group getGroup(@NonNull String name) {
final me.lucko.luckperms.common.core.model.Group group = plugin.getGroupManager().getIfLoaded(name); final me.lucko.luckperms.common.core.model.Group group = plugin.getGroupManager().getIfLoaded(name);
return group == null ? null : new GroupLink(group); return group == null ? null : new GroupDelegate(group);
} }
@Override @Override
@ -197,7 +199,7 @@ public class ApiProvider implements LuckPermsApi {
@Override @Override
public Set<Group> getGroups() { public Set<Group> getGroups() {
return plugin.getGroupManager().getAll().values().stream().map(GroupLink::new).collect(Collectors.toSet()); return plugin.getGroupManager().getAll().values().stream().map(GroupDelegate::new).collect(Collectors.toSet());
} }
@Override @Override
@ -208,7 +210,7 @@ public class ApiProvider implements LuckPermsApi {
@Override @Override
public Track getTrack(@NonNull String name) { public Track getTrack(@NonNull String name) {
final me.lucko.luckperms.common.core.model.Track track = plugin.getTrackManager().getIfLoaded(name); final me.lucko.luckperms.common.core.model.Track track = plugin.getTrackManager().getIfLoaded(name);
return track == null ? null : new TrackLink(track); return track == null ? null : new TrackDelegate(track);
} }
@Override @Override
@ -218,7 +220,7 @@ public class ApiProvider implements LuckPermsApi {
@Override @Override
public Set<Track> getTracks() { public Set<Track> getTracks() {
return plugin.getTrackManager().getAll().values().stream().map(TrackLink::new).collect(Collectors.toSet()); return plugin.getTrackManager().getAll().values().stream().map(TrackDelegate::new).collect(Collectors.toSet());
} }
@Override @Override
@ -226,6 +228,11 @@ public class ApiProvider implements LuckPermsApi {
return plugin.getTrackManager().isLoaded(name); return plugin.getTrackManager().isLoaded(name);
} }
@Override
public NodeFactory getNodeFactory() {
return NodeFactoryDelegate.INSTANCE;
}
@Override @Override
public Node.Builder buildNode(@NonNull String permission) throws IllegalArgumentException { public Node.Builder buildNode(@NonNull String permission) throws IllegalArgumentException {
return new NodeBuilder(checkNode(permission)); return new NodeBuilder(checkNode(permission));
@ -245,7 +252,13 @@ public class ApiProvider implements LuckPermsApi {
@Override @Override
public Optional<Contexts> getContextForUser(User user) { public Optional<Contexts> getContextForUser(User user) {
Utils.checkUser(user); ApiUtils.checkUser(user);
return Optional.ofNullable(plugin.getContextForUser(((UserLink) user).getMaster())); return Optional.ofNullable(plugin.getContextForUser(((UserDelegate) user).getMaster()));
}
@SuppressWarnings("unchecked")
@Override
public ContextSet getContextForPlayer(Object player) {
return plugin.getContextManager().getApplicableContext(player);
} }
} }

View File

@ -20,7 +20,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package me.lucko.luckperms.common.api.internal; package me.lucko.luckperms.common.api;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
@ -29,21 +29,24 @@ import com.google.common.base.Preconditions;
import me.lucko.luckperms.api.Group; import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.Track; import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.User; import me.lucko.luckperms.api.User;
import me.lucko.luckperms.common.api.delegate.GroupDelegate;
import me.lucko.luckperms.common.api.delegate.TrackDelegate;
import me.lucko.luckperms.common.api.delegate.UserDelegate;
import me.lucko.luckperms.common.utils.ArgumentChecker; import me.lucko.luckperms.common.utils.ArgumentChecker;
@UtilityClass @UtilityClass
public class Utils { public class ApiUtils {
public static void checkUser(User user) { public static void checkUser(User user) {
Preconditions.checkState(user instanceof UserLink, "User instance cannot be handled by this implementation."); Preconditions.checkState(user instanceof UserDelegate, "User instance cannot be handled by this implementation.");
} }
public static void checkGroup(Group group) { public static void checkGroup(Group group) {
Preconditions.checkState(group instanceof GroupLink, "Group instance cannot be handled by this implementation."); Preconditions.checkState(group instanceof GroupDelegate, "Group instance cannot be handled by this implementation.");
} }
public static void checkTrack(Track track) { public static void checkTrack(Track track) {
Preconditions.checkState(track instanceof TrackLink, "Track instance cannot be handled by this implementation."); Preconditions.checkState(track instanceof TrackDelegate, "Track instance cannot be handled by this implementation.");
} }
public static String checkUsername(String s) { public static String checkUsername(String s) {

View File

@ -20,7 +20,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package me.lucko.luckperms.common.api.internal; package me.lucko.luckperms.common.api.delegate;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
@ -39,19 +39,14 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import static me.lucko.luckperms.common.api.internal.Utils.checkGroup; import static me.lucko.luckperms.common.api.ApiUtils.checkGroup;
import static me.lucko.luckperms.common.api.internal.Utils.checkName; import static me.lucko.luckperms.common.api.ApiUtils.checkName;
import static me.lucko.luckperms.common.api.internal.Utils.checkTrack; import static me.lucko.luckperms.common.api.ApiUtils.checkTrack;
import static me.lucko.luckperms.common.api.internal.Utils.checkUser; import static me.lucko.luckperms.common.api.ApiUtils.checkUser;
import static me.lucko.luckperms.common.api.internal.Utils.checkUsername; import static me.lucko.luckperms.common.api.ApiUtils.checkUsername;
/** @SuppressWarnings("deprecation")
* Provides a link between {@link Datastore} and {@link Storage} public class DatastoreDelegate implements Datastore {
*
* Note that this class only provides for the old deprecated interface, see {@link StorageLink} for the new one.
*/
@SuppressWarnings({"unused", "WeakerAccess", "deprecation"})
public class DatastoreLink implements Datastore {
private final LuckPermsPlugin plugin; private final LuckPermsPlugin plugin;
private final Storage master; private final Storage master;
@ -59,7 +54,7 @@ public class DatastoreLink implements Datastore {
private final Sync sync; private final Sync sync;
private final Future future; private final Future future;
public DatastoreLink(@NonNull LuckPermsPlugin plugin, @NonNull Storage master) { public DatastoreDelegate(@NonNull LuckPermsPlugin plugin, @NonNull Storage master) {
this.plugin = plugin; this.plugin = plugin;
this.master = master; this.master = master;
this.async = new Async(master); this.async = new Async(master);
@ -109,7 +104,7 @@ public class DatastoreLink implements Datastore {
@Override @Override
public void getLog(@NonNull Callback<Log> callback) { public void getLog(@NonNull Callback<Log> callback) {
master.force().getLog().thenAcceptAsync(log -> callback.onComplete(new LogLink(log)), plugin.getSyncExecutor()); master.force().getLog().thenAcceptAsync(log -> callback.onComplete(new LogDelegate(log)), plugin.getSyncExecutor());
} }
@Override @Override
@ -130,7 +125,7 @@ public class DatastoreLink implements Datastore {
@Override @Override
public void saveUser(@NonNull User user, Callback<Boolean> callback) { public void saveUser(@NonNull User user, Callback<Boolean> callback) {
checkUser(user); checkUser(user);
registerCallback(master.force().saveUser(((UserLink) user).getMaster()), callback); registerCallback(master.force().saveUser(((UserDelegate) user).getMaster()), callback);
} }
@Override @Override
@ -161,7 +156,7 @@ public class DatastoreLink implements Datastore {
@Override @Override
public void saveGroup(@NonNull Group group, Callback<Boolean> callback) { public void saveGroup(@NonNull Group group, Callback<Boolean> callback) {
checkGroup(group); checkGroup(group);
registerCallback(master.force().saveGroup(((GroupLink) group).getMaster()), callback); registerCallback(master.force().saveGroup(((GroupDelegate) group).getMaster()), callback);
} }
@Override @Override
@ -170,7 +165,7 @@ public class DatastoreLink implements Datastore {
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) { if (group.getName().equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) {
throw new IllegalArgumentException("Cannot delete the default group."); throw new IllegalArgumentException("Cannot delete the default group.");
} }
registerCallback(master.force().deleteGroup(((GroupLink) group).getMaster()), callback); registerCallback(master.force().deleteGroup(((GroupDelegate) group).getMaster()), callback);
} }
@Override @Override
@ -191,13 +186,13 @@ public class DatastoreLink implements Datastore {
@Override @Override
public void saveTrack(@NonNull Track track, Callback<Boolean> callback) { public void saveTrack(@NonNull Track track, Callback<Boolean> callback) {
checkTrack(track); checkTrack(track);
registerCallback(master.force().saveTrack(((TrackLink) track).getMaster()), callback); registerCallback(master.force().saveTrack(((TrackDelegate) track).getMaster()), callback);
} }
@Override @Override
public void deleteTrack(@NonNull Track track, Callback<Boolean> callback) { public void deleteTrack(@NonNull Track track, Callback<Boolean> callback) {
checkTrack(track); checkTrack(track);
registerCallback(master.force().deleteTrack(((TrackLink) track).getMaster()), callback); registerCallback(master.force().deleteTrack(((TrackDelegate) track).getMaster()), callback);
} }
@Override @Override
@ -226,7 +221,7 @@ public class DatastoreLink implements Datastore {
if (log == null) { if (log == null) {
return null; return null;
} }
return new LogLink(log); return new LogDelegate(log);
} }
@Override @Override
@ -247,7 +242,7 @@ public class DatastoreLink implements Datastore {
@Override @Override
public boolean saveUser(@NonNull User user) { public boolean saveUser(@NonNull User user) {
checkUser(user); checkUser(user);
return master.force().saveUser(((UserLink) user).getMaster()).join(); return master.force().saveUser(((UserDelegate) user).getMaster()).join();
} }
@Override @Override
@ -278,7 +273,7 @@ public class DatastoreLink implements Datastore {
@Override @Override
public boolean saveGroup(@NonNull Group group) { public boolean saveGroup(@NonNull Group group) {
checkGroup(group); checkGroup(group);
return master.force().saveGroup(((GroupLink) group).getMaster()).join(); return master.force().saveGroup(((GroupDelegate) group).getMaster()).join();
} }
@Override @Override
@ -287,7 +282,7 @@ public class DatastoreLink implements Datastore {
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) { if (group.getName().equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) {
throw new IllegalArgumentException("Cannot delete the default group."); throw new IllegalArgumentException("Cannot delete the default group.");
} }
return master.force().deleteGroup(((GroupLink) group).getMaster()).join(); return master.force().deleteGroup(((GroupDelegate) group).getMaster()).join();
} }
@Override @Override
@ -308,13 +303,13 @@ public class DatastoreLink implements Datastore {
@Override @Override
public boolean saveTrack(@NonNull Track track) { public boolean saveTrack(@NonNull Track track) {
checkTrack(track); checkTrack(track);
return master.force().saveTrack(((TrackLink) track).getMaster()).join(); return master.force().saveTrack(((TrackDelegate) track).getMaster()).join();
} }
@Override @Override
public boolean deleteTrack(@NonNull Track track) { public boolean deleteTrack(@NonNull Track track) {
checkTrack(track); checkTrack(track);
return master.force().deleteTrack(((TrackLink) track).getMaster()).join(); return master.force().deleteTrack(((TrackDelegate) track).getMaster()).join();
} }
@Override @Override
@ -339,7 +334,7 @@ public class DatastoreLink implements Datastore {
@Override @Override
public java.util.concurrent.Future<Log> getLog() { public java.util.concurrent.Future<Log> getLog() {
return master.force().getLog().thenApply(log -> log == null ? null : new LogLink(log)); return master.force().getLog().thenApply(log -> log == null ? null : new LogDelegate(log));
} }
@Override @Override
@ -360,7 +355,7 @@ public class DatastoreLink implements Datastore {
@Override @Override
public java.util.concurrent.Future<Boolean> saveUser(@NonNull User user) { public java.util.concurrent.Future<Boolean> saveUser(@NonNull User user) {
checkUser(user); checkUser(user);
return master.force().saveUser(((UserLink) user).getMaster()); return master.force().saveUser(((UserDelegate) user).getMaster());
} }
@Override @Override
@ -391,7 +386,7 @@ public class DatastoreLink implements Datastore {
@Override @Override
public java.util.concurrent.Future<Boolean> saveGroup(@NonNull Group group) { public java.util.concurrent.Future<Boolean> saveGroup(@NonNull Group group) {
checkGroup(group); checkGroup(group);
return master.force().saveGroup(((GroupLink) group).getMaster()); return master.force().saveGroup(((GroupDelegate) group).getMaster());
} }
@Override @Override
@ -400,7 +395,7 @@ public class DatastoreLink implements Datastore {
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) { if (group.getName().equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) {
throw new IllegalArgumentException("Cannot delete the default group."); throw new IllegalArgumentException("Cannot delete the default group.");
} }
return master.force().deleteGroup(((GroupLink) group).getMaster()); return master.force().deleteGroup(((GroupDelegate) group).getMaster());
} }
@Override @Override
@ -421,13 +416,13 @@ public class DatastoreLink implements Datastore {
@Override @Override
public java.util.concurrent.Future<Boolean> saveTrack(@NonNull Track track) { public java.util.concurrent.Future<Boolean> saveTrack(@NonNull Track track) {
checkTrack(track); checkTrack(track);
return master.force().saveTrack(((TrackLink) track).getMaster()); return master.force().saveTrack(((TrackDelegate) track).getMaster());
} }
@Override @Override
public java.util.concurrent.Future<Boolean> deleteTrack(@NonNull Track track) { public java.util.concurrent.Future<Boolean> deleteTrack(@NonNull Track track) {
checkTrack(track); checkTrack(track);
return master.force().deleteTrack(((TrackLink) track).getMaster()); return master.force().deleteTrack(((TrackDelegate) track).getMaster());
} }
@Override @Override

View File

@ -20,7 +20,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package me.lucko.luckperms.common.api.internal; package me.lucko.luckperms.common.api.delegate;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -32,17 +32,17 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException; import me.lucko.luckperms.exceptions.ObjectLacksException;
import java.util.List; import java.util.List;
import java.util.OptionalInt;
import static me.lucko.luckperms.common.api.internal.Utils.checkGroup; import static me.lucko.luckperms.common.api.ApiUtils.checkGroup;
import static me.lucko.luckperms.common.api.internal.Utils.checkServer; import static me.lucko.luckperms.common.api.ApiUtils.checkServer;
import static me.lucko.luckperms.common.api.internal.Utils.checkTime; import static me.lucko.luckperms.common.api.ApiUtils.checkTime;
/** /**
* Provides a link between {@link Group} and {@link me.lucko.luckperms.common.core.model.Group} * Provides a link between {@link Group} and {@link me.lucko.luckperms.common.core.model.Group}
*/ */
@EqualsAndHashCode(of = {"name"}, callSuper = false) @EqualsAndHashCode(of = {"name"}, callSuper = false)
@SuppressWarnings("unused") public class GroupDelegate extends PermissionHolderDelegate implements Group {
public class GroupLink extends PermissionHolderLink implements Group {
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private final me.lucko.luckperms.common.core.model.Group master; private final me.lucko.luckperms.common.core.model.Group master;
@ -50,7 +50,7 @@ public class GroupLink extends PermissionHolderLink implements Group {
@Getter @Getter
private final String name; private final String name;
public GroupLink(@NonNull me.lucko.luckperms.common.core.model.Group master) { public GroupDelegate(@NonNull me.lucko.luckperms.common.core.model.Group master) {
super(master); super(master);
this.master = master; this.master = master;
this.name = master.getName(); this.name = master.getName();
@ -59,91 +59,91 @@ public class GroupLink extends PermissionHolderLink implements Group {
@Override @Override
public boolean inheritsGroup(@NonNull Group group) { public boolean inheritsGroup(@NonNull Group group) {
checkGroup(group); checkGroup(group);
return master.inheritsGroup(((GroupLink) group).getMaster()); return master.inheritsGroup(((GroupDelegate) group).getMaster());
} }
@Override @Override
public boolean inheritsGroup(@NonNull Group group, @NonNull String server) { public boolean inheritsGroup(@NonNull Group group, @NonNull String server) {
checkGroup(group); checkGroup(group);
return master.inheritsGroup(((GroupLink) group).getMaster(), server); return master.inheritsGroup(((GroupDelegate) group).getMaster(), server);
} }
@Override @Override
public boolean inheritsGroup(@NonNull Group group, @NonNull String server, @NonNull String world) { public boolean inheritsGroup(@NonNull Group group, @NonNull String server, @NonNull String world) {
checkGroup(group); checkGroup(group);
return master.inheritsGroup(((GroupLink) group).getMaster(), server, world); return master.inheritsGroup(((GroupDelegate) group).getMaster(), server, world);
} }
@Override @Override
public void setInheritGroup(@NonNull Group group) throws ObjectAlreadyHasException { public void setInheritGroup(@NonNull Group group) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.setInheritGroup(((GroupLink) group).getMaster()); master.setInheritGroup(((GroupDelegate) group).getMaster());
} }
@Override @Override
public void setInheritGroup(@NonNull Group group, @NonNull String server) throws ObjectAlreadyHasException { public void setInheritGroup(@NonNull Group group, @NonNull String server) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.setInheritGroup(((GroupLink) group).getMaster(), checkServer(server)); master.setInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server));
} }
@Override @Override
public void setInheritGroup(@NonNull Group group, @NonNull String server, @NonNull String world) throws ObjectAlreadyHasException { public void setInheritGroup(@NonNull Group group, @NonNull String server, @NonNull String world) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.setInheritGroup(((GroupLink) group).getMaster(), checkServer(server), world); master.setInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server), world);
} }
@Override @Override
public void setInheritGroup(@NonNull Group group, @NonNull long expireAt) throws ObjectAlreadyHasException { public void setInheritGroup(@NonNull Group group, @NonNull long expireAt) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.setInheritGroup(((GroupLink) group).getMaster(), checkTime(expireAt)); master.setInheritGroup(((GroupDelegate) group).getMaster(), checkTime(expireAt));
} }
@Override @Override
public void setInheritGroup(@NonNull Group group, @NonNull String server, @NonNull long expireAt) throws ObjectAlreadyHasException { public void setInheritGroup(@NonNull Group group, @NonNull String server, @NonNull long expireAt) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.setInheritGroup(((GroupLink) group).getMaster(), checkServer(server), checkTime(expireAt)); master.setInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server), checkTime(expireAt));
} }
@Override @Override
public void setInheritGroup(@NonNull Group group, @NonNull String server, @NonNull String world, @NonNull long expireAt) throws ObjectAlreadyHasException { public void setInheritGroup(@NonNull Group group, @NonNull String server, @NonNull String world, @NonNull long expireAt) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.setInheritGroup(((GroupLink) group).getMaster(), checkServer(server), world, checkTime(expireAt)); master.setInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server), world, checkTime(expireAt));
} }
@Override @Override
public void unsetInheritGroup(@NonNull Group group) throws ObjectLacksException { public void unsetInheritGroup(@NonNull Group group) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.unsetInheritGroup(((GroupLink) group).getMaster()); master.unsetInheritGroup(((GroupDelegate) group).getMaster());
} }
@Override @Override
public void unsetInheritGroup(@NonNull Group group, @NonNull boolean temporary) throws ObjectLacksException { public void unsetInheritGroup(@NonNull Group group, @NonNull boolean temporary) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.unsetInheritGroup(((GroupLink) group).getMaster(), temporary); master.unsetInheritGroup(((GroupDelegate) group).getMaster(), temporary);
} }
@Override @Override
public void unsetInheritGroup(@NonNull Group group, @NonNull String server) throws ObjectLacksException { public void unsetInheritGroup(@NonNull Group group, @NonNull String server) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.unsetInheritGroup(((GroupLink) group).getMaster(), checkServer(server)); master.unsetInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server));
} }
@Override @Override
public void unsetInheritGroup(@NonNull Group group, @NonNull String server, @NonNull String world) throws ObjectLacksException { public void unsetInheritGroup(@NonNull Group group, @NonNull String server, @NonNull String world) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.unsetInheritGroup(((GroupLink) group).getMaster(), checkServer(server), world); master.unsetInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server), world);
} }
@Override @Override
public void unsetInheritGroup(@NonNull Group group, @NonNull String server, @NonNull boolean temporary) throws ObjectLacksException { public void unsetInheritGroup(@NonNull Group group, @NonNull String server, @NonNull boolean temporary) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.unsetInheritGroup(((GroupLink) group).getMaster(), checkServer(server), temporary); master.unsetInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server), temporary);
} }
@Override @Override
public void unsetInheritGroup(@NonNull Group group, @NonNull String server, @NonNull String world, @NonNull boolean temporary) throws ObjectLacksException { public void unsetInheritGroup(@NonNull Group group, @NonNull String server, @NonNull String world, @NonNull boolean temporary) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.unsetInheritGroup(((GroupLink) group).getMaster(), checkServer(server), world, temporary); master.unsetInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server), world, temporary);
} }
@Override @Override
@ -161,6 +161,11 @@ public class GroupLink extends PermissionHolderLink implements Group {
return master.getLocalGroups(checkServer(server), world); return master.getLocalGroups(checkServer(server), world);
} }
@Override
public OptionalInt getWeight() {
return master.getWeight();
}
@Override @Override
public List<String> getLocalGroups(@NonNull String server) { public List<String> getLocalGroups(@NonNull String server) {
return master.getLocalGroups(checkServer(server)); return master.getLocalGroups(checkServer(server));

View File

@ -20,7 +20,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package me.lucko.luckperms.common.api.internal; package me.lucko.luckperms.common.api.delegate;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -34,7 +34,7 @@ import java.util.Map;
* Provides a link between {@link LPConfiguration} and {@link me.lucko.luckperms.common.config.LPConfiguration} * Provides a link between {@link LPConfiguration} and {@link me.lucko.luckperms.common.config.LPConfiguration}
*/ */
@AllArgsConstructor @AllArgsConstructor
public class LPConfigurationLink implements LPConfiguration { public class LPConfigurationDelegate implements LPConfiguration {
private final me.lucko.luckperms.common.config.LPConfiguration master; private final me.lucko.luckperms.common.config.LPConfiguration master;
@Override @Override

View File

@ -20,7 +20,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package me.lucko.luckperms.common.api.internal; package me.lucko.luckperms.common.api.delegate;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
@ -32,13 +32,13 @@ import java.util.SortedMap;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.UUID; import java.util.UUID;
import static me.lucko.luckperms.common.api.internal.Utils.checkName; import static me.lucko.luckperms.common.api.ApiUtils.checkName;
/** /**
* Provides a link between {@link Log} and {@link me.lucko.luckperms.common.data.Log} * Provides a link between {@link Log} and {@link me.lucko.luckperms.common.data.Log}
*/ */
@AllArgsConstructor @AllArgsConstructor
public class LogLink implements Log { public class LogDelegate implements Log {
private final me.lucko.luckperms.common.data.Log master; private final me.lucko.luckperms.common.data.Log master;
@Override @Override

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.api.delegate;
import lombok.NonNull;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.common.core.NodeFactory;
public class NodeFactoryDelegate implements me.lucko.luckperms.api.NodeFactory {
public static final NodeFactoryDelegate INSTANCE = new NodeFactoryDelegate();
@Override
public Node fromSerialisedNode(@NonNull String serialisedPermission, boolean value) {
return NodeFactory.fromSerialisedNode(serialisedPermission, value);
}
@Override
public Node.Builder newBuilder(@NonNull String permission) {
return NodeFactory.newBuilder(permission);
}
@Override
public Node.Builder newBuilderFromExisting(@NonNull Node other) {
return NodeFactory.builderFromExisting(other);
}
@Override
public Node.Builder newBuilderFromSerialisedNode(@NonNull String serialisedPermission, boolean value) {
return NodeFactory.builderFromSerialisedNode(serialisedPermission, value);
}
@Override
public Node.Builder makeMetaNode(@NonNull String key, @NonNull String value) {
return NodeFactory.makeMetaNode(key, value);
}
@Override
public Node.Builder makePrefixNode(int priority, @NonNull String prefix) {
return NodeFactory.makePrefixNode(priority, prefix);
}
@Override
public Node.Builder makeSuffixNode(int priority, @NonNull String suffix) {
return NodeFactory.makeSuffixNode(priority, suffix);
}
}

View File

@ -20,11 +20,15 @@
* SOFTWARE. * SOFTWARE.
*/ */
package me.lucko.luckperms.common.api.internal; package me.lucko.luckperms.common.api.delegate;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.LocalizedNode; import me.lucko.luckperms.api.LocalizedNode;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
@ -36,16 +40,17 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException; import me.lucko.luckperms.exceptions.ObjectLacksException;
import java.util.AbstractMap; import java.util.AbstractMap;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet;
import static me.lucko.luckperms.common.api.internal.Utils.checkNode; import static me.lucko.luckperms.common.api.ApiUtils.checkNode;
import static me.lucko.luckperms.common.api.internal.Utils.checkServer; import static me.lucko.luckperms.common.api.ApiUtils.checkServer;
import static me.lucko.luckperms.common.api.internal.Utils.checkTime; import static me.lucko.luckperms.common.api.ApiUtils.checkTime;
import static me.lucko.luckperms.common.core.model.PermissionHolder.exportToLegacy; import static me.lucko.luckperms.common.core.model.PermissionHolder.exportToLegacy;
/** /**
@ -53,7 +58,7 @@ import static me.lucko.luckperms.common.core.model.PermissionHolder.exportToLega
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
@AllArgsConstructor @AllArgsConstructor
public class PermissionHolderLink implements PermissionHolder { public class PermissionHolderDelegate implements PermissionHolder {
private final me.lucko.luckperms.common.core.model.PermissionHolder master; private final me.lucko.luckperms.common.core.model.PermissionHolder master;
@Override @Override
@ -63,37 +68,42 @@ public class PermissionHolderLink implements PermissionHolder {
@Override @Override
public SortedSet<? extends Node> getPermissions() { public SortedSet<? extends Node> getPermissions() {
return master.getPermissions(false); return ImmutableSortedSet.copyOf(master.getPermissions(false));
} }
@Override @Override
public Set<Node> getEnduringPermissions() { public Set<Node> getEnduringPermissions() {
return master.getNodes(); return ImmutableSet.copyOf(master.getNodes());
} }
@Override @Override
public Set<Node> getTransientPermissions() { public Set<Node> getTransientPermissions() {
return master.getTransientNodes(); return ImmutableSet.copyOf(master.getTransientNodes());
} }
@Override @Override
public Set<Node> getAllNodes() { public Set<Node> getAllNodes() {
return Collections.unmodifiableSet(master.getAllNodes(null, ExtractedContexts.generate(Contexts.allowAll()))); return ImmutableSet.copyOf(master.getAllNodes(null, ExtractedContexts.generate(Contexts.allowAll())));
} }
@Override @Override
public SortedSet<LocalizedNode> getAllNodes(@NonNull Contexts contexts) { public SortedSet<LocalizedNode> getAllNodes(@NonNull Contexts contexts) {
return master.getAllNodes(null, ExtractedContexts.generate(contexts)); return new TreeSet<>(master.getAllNodes(null, ExtractedContexts.generate(contexts)));
} }
@Override @Override
public Set<LocalizedNode> getAllNodesFiltered(@NonNull Contexts contexts) { public Set<LocalizedNode> getAllNodesFiltered(@NonNull Contexts contexts) {
return master.getAllNodesFiltered(ExtractedContexts.generate(contexts)); return new HashSet<>(master.getAllNodesFiltered(ExtractedContexts.generate(contexts)));
}
@Override
public Map<String, Boolean> exportNodes(Contexts contexts, boolean lowerCase) {
return new HashMap<>(master.exportNodes(contexts, lowerCase));
} }
@Override @Override
public Map<String, Boolean> getNodes() { public Map<String, Boolean> getNodes() {
return exportToLegacy(master.getNodes()); return ImmutableMap.copyOf(exportToLegacy(master.getNodes()));
} }
@Override @Override
@ -251,6 +261,61 @@ public class PermissionHolderLink implements PermissionHolder {
master.unsetPermission(checkNode(node), checkServer(server), world, temporary); master.unsetPermission(checkNode(node), checkServer(server), world, temporary);
} }
@Override
public void clearNodes() {
master.clearNodes();
}
@Override
public void clearNodes(String server) {
master.clearNodes(server);
}
@Override
public void clearNodes(String server, String world) {
master.clearNodes(server, world);
}
@Override
public void clearParents() {
master.clearParents();
}
@Override
public void clearParents(String server) {
master.clearParents(server);
}
@Override
public void clearParents(String server, String world) {
master.clearParents(server, world);
}
@Override
public void clearMeta() {
master.clearMeta();
}
@Override
public void clearMeta(String server) {
master.clearMeta(server);
}
@Override
public void clearMeta(String server, String world) {
master.clearMeta(server, world);
}
@Override
public void clearMetaKeys(String key, String server, String world, boolean temporary) {
master.clearMetaKeys(key, server, world, temporary);
}
@Override
public void clearTransientNodes() {
master.clearTransientNodes();
}
@Override @Override
public Map<String, Boolean> getLocalPermissions(String server, String world, List<String> excludedGroups, List<String> possibleNodes) { public Map<String, Boolean> getLocalPermissions(String server, String world, List<String> excludedGroups, List<String> possibleNodes) {
Map<String, String> context = new HashMap<>(); Map<String, String> context = new HashMap<>();

View File

@ -20,12 +20,13 @@
* SOFTWARE. * SOFTWARE.
*/ */
package me.lucko.luckperms.common.api.internal; package me.lucko.luckperms.common.api.delegate;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
import me.lucko.luckperms.api.Group; import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.Log; import me.lucko.luckperms.api.Log;
import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.api.Storage; import me.lucko.luckperms.api.Storage;
@ -33,22 +34,23 @@ import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.User; import me.lucko.luckperms.api.User;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import static me.lucko.luckperms.common.api.internal.Utils.checkGroup; import static me.lucko.luckperms.common.api.ApiUtils.checkGroup;
import static me.lucko.luckperms.common.api.internal.Utils.checkName; import static me.lucko.luckperms.common.api.ApiUtils.checkName;
import static me.lucko.luckperms.common.api.internal.Utils.checkTrack; import static me.lucko.luckperms.common.api.ApiUtils.checkTrack;
import static me.lucko.luckperms.common.api.internal.Utils.checkUser; import static me.lucko.luckperms.common.api.ApiUtils.checkUser;
import static me.lucko.luckperms.common.api.internal.Utils.checkUsername; import static me.lucko.luckperms.common.api.ApiUtils.checkUsername;
/** /**
* Provides a link between {@link Storage} and {@link me.lucko.luckperms.common.storage.Storage} * Provides a link between {@link Storage} and {@link me.lucko.luckperms.common.storage.Storage}
*/ */
@AllArgsConstructor @AllArgsConstructor
public class StorageLink implements Storage { public class StorageDelegate implements Storage {
private final LuckPermsPlugin plugin; private final LuckPermsPlugin plugin;
private final me.lucko.luckperms.common.storage.Storage master; private final me.lucko.luckperms.common.storage.Storage master;
@ -79,7 +81,7 @@ public class StorageLink implements Storage {
@Override @Override
public CompletableFuture<Log> getLog() { public CompletableFuture<Log> getLog() {
return master.force().getLog().thenApply(log -> log == null ? null : new LogLink(log)); return master.force().getLog().thenApply(log -> log == null ? null : new LogDelegate(log));
} }
@Override @Override
@ -90,7 +92,7 @@ public class StorageLink implements Storage {
@Override @Override
public CompletableFuture<Boolean> saveUser(User user) { public CompletableFuture<Boolean> saveUser(User user) {
checkUser(user); checkUser(user);
return master.force().saveUser(((UserLink) user).getMaster()); return master.force().saveUser(((UserDelegate) user).getMaster());
} }
@Override @Override
@ -103,6 +105,11 @@ public class StorageLink implements Storage {
return master.force().getUniqueUsers(); return master.force().getUniqueUsers();
} }
@Override
public CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@NonNull String permission) {
return master.force().getUsersWithPermission(permission);
}
@Override @Override
public CompletableFuture<Boolean> createAndLoadGroup(String name) { public CompletableFuture<Boolean> createAndLoadGroup(String name) {
return master.force().createAndLoadGroup(checkName(name)); return master.force().createAndLoadGroup(checkName(name));
@ -121,7 +128,7 @@ public class StorageLink implements Storage {
@Override @Override
public CompletableFuture<Boolean> saveGroup(Group group) { public CompletableFuture<Boolean> saveGroup(Group group) {
checkGroup(group); checkGroup(group);
return master.force().saveGroup(((GroupLink) group).getMaster()); return master.force().saveGroup(((GroupDelegate) group).getMaster());
} }
@Override @Override
@ -130,7 +137,12 @@ public class StorageLink implements Storage {
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) { if (group.getName().equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) {
throw new IllegalArgumentException("Cannot delete the default group."); throw new IllegalArgumentException("Cannot delete the default group.");
} }
return master.force().deleteGroup(((GroupLink) group).getMaster()); return master.force().deleteGroup(((GroupDelegate) group).getMaster());
}
@Override
public CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@NonNull String permission) {
return master.force().getGroupsWithPermission(permission);
} }
@Override @Override
@ -151,13 +163,13 @@ public class StorageLink implements Storage {
@Override @Override
public CompletableFuture<Boolean> saveTrack(Track track) { public CompletableFuture<Boolean> saveTrack(Track track) {
checkTrack(track); checkTrack(track);
return master.force().saveTrack(((TrackLink) track).getMaster()); return master.force().saveTrack(((TrackDelegate) track).getMaster());
} }
@Override @Override
public CompletableFuture<Boolean> deleteTrack(Track track) { public CompletableFuture<Boolean> deleteTrack(Track track) {
checkTrack(track); checkTrack(track);
return master.force().deleteTrack(((TrackLink) track).getMaster()); return master.force().deleteTrack(((TrackDelegate) track).getMaster());
} }
@Override @Override
@ -169,4 +181,9 @@ public class StorageLink implements Storage {
public CompletableFuture<UUID> getUUID(String username) { public CompletableFuture<UUID> getUUID(String username) {
return master.force().getUUID(checkUsername(username)); return master.force().getUUID(checkUsername(username));
} }
@Override
public CompletableFuture<String> getName(@NonNull UUID uuid) {
return master.force().getName(uuid);
}
} }

View File

@ -20,7 +20,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package me.lucko.luckperms.common.api.internal; package me.lucko.luckperms.common.api.delegate;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -34,14 +34,14 @@ import me.lucko.luckperms.exceptions.ObjectLacksException;
import java.util.List; import java.util.List;
import static me.lucko.luckperms.common.api.internal.Utils.checkGroup; import static me.lucko.luckperms.common.api.ApiUtils.checkGroup;
/** /**
* Provides a link between {@link Track} and {@link me.lucko.luckperms.common.core.model.Track} * Provides a link between {@link Track} and {@link me.lucko.luckperms.common.core.model.Track}
*/ */
@EqualsAndHashCode(of = {"name"}) @EqualsAndHashCode(of = {"name"})
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class TrackLink implements Track { public class TrackDelegate implements Track {
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private final me.lucko.luckperms.common.core.model.Track master; private final me.lucko.luckperms.common.core.model.Track master;
@ -49,7 +49,7 @@ public class TrackLink implements Track {
@Getter @Getter
private final String name; private final String name;
public TrackLink(@NonNull me.lucko.luckperms.common.core.model.Track master) { public TrackDelegate(@NonNull me.lucko.luckperms.common.core.model.Track master) {
this.master = master; this.master = master;
this.name = master.getName(); this.name = master.getName();
} }
@ -67,31 +67,31 @@ public class TrackLink implements Track {
@Override @Override
public String getNext(@NonNull Group current) throws ObjectLacksException { public String getNext(@NonNull Group current) throws ObjectLacksException {
checkGroup(current); checkGroup(current);
return master.getNext(((GroupLink) current).getMaster()); return master.getNext(((GroupDelegate) current).getMaster());
} }
@Override @Override
public String getPrevious(@NonNull Group current) throws ObjectLacksException { public String getPrevious(@NonNull Group current) throws ObjectLacksException {
checkGroup(current); checkGroup(current);
return master.getPrevious(((GroupLink) current).getMaster()); return master.getPrevious(((GroupDelegate) current).getMaster());
} }
@Override @Override
public void appendGroup(@NonNull Group group) throws ObjectAlreadyHasException { public void appendGroup(@NonNull Group group) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.appendGroup(((GroupLink) group).getMaster()); master.appendGroup(((GroupDelegate) group).getMaster());
} }
@Override @Override
public void insertGroup(@NonNull Group group, @NonNull int position) throws ObjectAlreadyHasException, IndexOutOfBoundsException { public void insertGroup(@NonNull Group group, @NonNull int position) throws ObjectAlreadyHasException, IndexOutOfBoundsException {
checkGroup(group); checkGroup(group);
master.insertGroup(((GroupLink) group).getMaster(), position); master.insertGroup(((GroupDelegate) group).getMaster(), position);
} }
@Override @Override
public void removeGroup(@NonNull Group group) throws ObjectLacksException { public void removeGroup(@NonNull Group group) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.removeGroup(((GroupLink) group).getMaster()); master.removeGroup(((GroupDelegate) group).getMaster());
} }
@Override @Override
@ -102,7 +102,7 @@ public class TrackLink implements Track {
@Override @Override
public boolean containsGroup(@NonNull Group group) { public boolean containsGroup(@NonNull Group group) {
checkGroup(group); checkGroup(group);
return master.containsGroup(((GroupLink) group).getMaster()); return master.containsGroup(((GroupDelegate) group).getMaster());
} }
@Override @Override

View File

@ -20,7 +20,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package me.lucko.luckperms.common.api.internal; package me.lucko.luckperms.common.api.delegate;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
@ -36,16 +36,16 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import static me.lucko.luckperms.common.api.internal.Utils.checkGroup; import static me.lucko.luckperms.common.api.ApiUtils.checkGroup;
import static me.lucko.luckperms.common.api.internal.Utils.checkServer; import static me.lucko.luckperms.common.api.ApiUtils.checkServer;
import static me.lucko.luckperms.common.api.internal.Utils.checkTime; import static me.lucko.luckperms.common.api.ApiUtils.checkTime;
/** /**
* Provides a link between {@link User} and {@link me.lucko.luckperms.common.core.model.User} * Provides a link between {@link User} and {@link me.lucko.luckperms.common.core.model.User}
*/ */
@EqualsAndHashCode(of = {"uuid"}, callSuper = false) @EqualsAndHashCode(of = {"uuid"}, callSuper = false)
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class UserLink extends PermissionHolderLink implements User { public class UserDelegate extends PermissionHolderDelegate implements User {
@Getter @Getter
private final me.lucko.luckperms.common.core.model.User master; private final me.lucko.luckperms.common.core.model.User master;
@ -53,7 +53,7 @@ public class UserLink extends PermissionHolderLink implements User {
@Getter @Getter
private final UUID uuid; private final UUID uuid;
public UserLink(@NonNull me.lucko.luckperms.common.core.model.User master) { public UserDelegate(@NonNull me.lucko.luckperms.common.core.model.User master) {
super(master); super(master);
this.master = master; this.master = master;
this.uuid = master.getUuid(); this.uuid = master.getUuid();
@ -92,94 +92,99 @@ public class UserLink extends PermissionHolderLink implements User {
return Optional.ofNullable(master.getUserData()); return Optional.ofNullable(master.getUserData());
} }
@Override
public void setupDataCache() {
master.setupData(false);
}
@Override @Override
public boolean isInGroup(@NonNull Group group) { public boolean isInGroup(@NonNull Group group) {
checkGroup(group); checkGroup(group);
return master.inheritsGroup(((GroupLink) group).getMaster()); return master.inheritsGroup(((GroupDelegate) group).getMaster());
} }
@Override @Override
public boolean isInGroup(@NonNull Group group, @NonNull String server) { public boolean isInGroup(@NonNull Group group, @NonNull String server) {
checkGroup(group); checkGroup(group);
return master.inheritsGroup(((GroupLink) group).getMaster(), server); return master.inheritsGroup(((GroupDelegate) group).getMaster(), server);
} }
@Override @Override
public boolean isInGroup(@NonNull Group group, @NonNull String server, @NonNull String world) { public boolean isInGroup(@NonNull Group group, @NonNull String server, @NonNull String world) {
checkGroup(group); checkGroup(group);
return master.inheritsGroup(((GroupLink) group).getMaster(), server, world); return master.inheritsGroup(((GroupDelegate) group).getMaster(), server, world);
} }
@Override @Override
public void addGroup(@NonNull Group group) throws ObjectAlreadyHasException { public void addGroup(@NonNull Group group) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.setInheritGroup(((GroupLink) group).getMaster()); master.setInheritGroup(((GroupDelegate) group).getMaster());
} }
@Override @Override
public void addGroup(@NonNull Group group, @NonNull String server) throws ObjectAlreadyHasException { public void addGroup(@NonNull Group group, @NonNull String server) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.setInheritGroup(((GroupLink) group).getMaster(), checkServer(server)); master.setInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server));
} }
@Override @Override
public void addGroup(@NonNull Group group, @NonNull String server, @NonNull String world) throws ObjectAlreadyHasException { public void addGroup(@NonNull Group group, @NonNull String server, @NonNull String world) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.setInheritGroup(((GroupLink) group).getMaster(), checkServer(server), world); master.setInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server), world);
} }
@Override @Override
public void addGroup(@NonNull Group group, @NonNull long expireAt) throws ObjectAlreadyHasException { public void addGroup(@NonNull Group group, @NonNull long expireAt) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.setInheritGroup(((GroupLink) group).getMaster(), checkTime(expireAt)); master.setInheritGroup(((GroupDelegate) group).getMaster(), checkTime(expireAt));
} }
@Override @Override
public void addGroup(@NonNull Group group, @NonNull String server, @NonNull long expireAt) throws ObjectAlreadyHasException { public void addGroup(@NonNull Group group, @NonNull String server, @NonNull long expireAt) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.setInheritGroup(((GroupLink) group).getMaster(), checkServer(server), checkTime(expireAt)); master.setInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server), checkTime(expireAt));
} }
@Override @Override
public void addGroup(@NonNull Group group, @NonNull String server, @NonNull String world, @NonNull long expireAt) throws ObjectAlreadyHasException { public void addGroup(@NonNull Group group, @NonNull String server, @NonNull String world, @NonNull long expireAt) throws ObjectAlreadyHasException {
checkGroup(group); checkGroup(group);
master.setInheritGroup(((GroupLink) group).getMaster(), checkServer(server), world, checkTime(expireAt)); master.setInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server), world, checkTime(expireAt));
} }
@Override @Override
public void removeGroup(@NonNull Group group) throws ObjectLacksException { public void removeGroup(@NonNull Group group) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.unsetInheritGroup(((GroupLink) group).getMaster()); master.unsetInheritGroup(((GroupDelegate) group).getMaster());
} }
@Override @Override
public void removeGroup(@NonNull Group group, @NonNull boolean temporary) throws ObjectLacksException { public void removeGroup(@NonNull Group group, @NonNull boolean temporary) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.unsetInheritGroup(((GroupLink) group).getMaster(), temporary); master.unsetInheritGroup(((GroupDelegate) group).getMaster(), temporary);
} }
@Override @Override
public void removeGroup(@NonNull Group group, @NonNull String server) throws ObjectLacksException { public void removeGroup(@NonNull Group group, @NonNull String server) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.unsetInheritGroup(((GroupLink) group).getMaster(), checkServer(server)); master.unsetInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server));
} }
@Override @Override
public void removeGroup(@NonNull Group group, @NonNull String server, @NonNull String world) throws ObjectLacksException { public void removeGroup(@NonNull Group group, @NonNull String server, @NonNull String world) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.unsetInheritGroup(((GroupLink) group).getMaster(), checkServer(server), world); master.unsetInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server), world);
} }
@Override @Override
public void removeGroup(@NonNull Group group, @NonNull String server, @NonNull boolean temporary) throws ObjectLacksException { public void removeGroup(@NonNull Group group, @NonNull String server, @NonNull boolean temporary) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.unsetInheritGroup(((GroupLink) group).getMaster(), checkServer(server), temporary); master.unsetInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server), temporary);
} }
@Override @Override
public void removeGroup(@NonNull Group group, @NonNull String server, @NonNull String world, @NonNull boolean temporary) throws ObjectLacksException { public void removeGroup(@NonNull Group group, @NonNull String server, @NonNull String world, @NonNull boolean temporary) throws ObjectLacksException {
checkGroup(group); checkGroup(group);
master.unsetInheritGroup(((GroupLink) group).getMaster(), checkServer(server), world, temporary); master.unsetInheritGroup(((GroupDelegate) group).getMaster(), checkServer(server), world, temporary);
} }
@Override @Override

View File

@ -20,7 +20,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package me.lucko.luckperms.common.api.internal; package me.lucko.luckperms.common.api.delegate;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
@ -33,7 +33,7 @@ import java.util.UUID;
* Provides a link between {@link UuidCache} and {@link me.lucko.luckperms.common.core.UuidCache} * Provides a link between {@link UuidCache} and {@link me.lucko.luckperms.common.core.UuidCache}
*/ */
@AllArgsConstructor @AllArgsConstructor
public class UuidCacheLink implements UuidCache { public class UuidCacheDelegate implements UuidCache {
private final me.lucko.luckperms.common.core.UuidCache master; private final me.lucko.luckperms.common.core.UuidCache master;
@Override @Override

View File

@ -22,6 +22,7 @@
package me.lucko.luckperms.common.commands.misc; package me.lucko.luckperms.common.commands.misc;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.Arg;
import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandException;
@ -31,7 +32,6 @@ import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.constants.Permission;
import me.lucko.luckperms.common.storage.holder.HeldPermission;
import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.Predicates;
import io.github.mkremins.fanciful.FancyMessage; import io.github.mkremins.fanciful.FancyMessage;

View File

@ -27,8 +27,8 @@ import com.google.common.base.Objects;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.event.events.UserDemoteEvent; import me.lucko.luckperms.api.event.events.UserDemoteEvent;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.api.internal.TrackLink; import me.lucko.luckperms.common.api.delegate.TrackDelegate;
import me.lucko.luckperms.common.api.internal.UserLink; import me.lucko.luckperms.common.api.delegate.UserDelegate;
import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.Arg;
import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.CommandResult;
@ -150,7 +150,7 @@ public class UserDemote extends SubCommand<User> {
.action("demote " + args.stream().collect(Collectors.joining(" "))) .action("demote " + args.stream().collect(Collectors.joining(" ")))
.build().submit(plugin, sender); .build().submit(plugin, sender);
save(user, sender, plugin); save(user, sender, plugin);
plugin.getApiProvider().fireEventAsync(new UserDemoteEvent(new TrackLink(track), new UserLink(user), old, null)); plugin.getApiProvider().fireEventAsync(new UserDemoteEvent(new TrackDelegate(track), new UserDelegate(user), old, null));
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }
@ -194,7 +194,7 @@ public class UserDemote extends SubCommand<User> {
.action("demote " + args.stream().collect(Collectors.joining(" "))) .action("demote " + args.stream().collect(Collectors.joining(" ")))
.build().submit(plugin, sender); .build().submit(plugin, sender);
save(user, sender, plugin); save(user, sender, plugin);
plugin.getApiProvider().fireEventAsync(new UserDemoteEvent(new TrackLink(track), new UserLink(user), old, previousGroup.getName())); plugin.getApiProvider().fireEventAsync(new UserDemoteEvent(new TrackDelegate(track), new UserDelegate(user), old, previousGroup.getName()));
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }

View File

@ -27,8 +27,8 @@ import com.google.common.base.Objects;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.event.events.UserPromoteEvent; import me.lucko.luckperms.api.event.events.UserPromoteEvent;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.api.internal.TrackLink; import me.lucko.luckperms.common.api.delegate.TrackDelegate;
import me.lucko.luckperms.common.api.internal.UserLink; import me.lucko.luckperms.common.api.delegate.UserDelegate;
import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.Arg;
import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.CommandResult;
@ -147,7 +147,7 @@ public class UserPromote extends SubCommand<User> {
.action("promote " + args.stream().collect(Collectors.joining(" "))) .action("promote " + args.stream().collect(Collectors.joining(" ")))
.build().submit(plugin, sender); .build().submit(plugin, sender);
save(user, sender, plugin); save(user, sender, plugin);
plugin.getApiProvider().fireEventAsync(new UserPromoteEvent(new TrackLink(track), new UserLink(user), null, first)); plugin.getApiProvider().fireEventAsync(new UserPromoteEvent(new TrackDelegate(track), new UserDelegate(user), null, first));
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }
@ -211,7 +211,7 @@ public class UserPromote extends SubCommand<User> {
.action("promote " + args.stream().collect(Collectors.joining(" "))) .action("promote " + args.stream().collect(Collectors.joining(" ")))
.build().submit(plugin, sender); .build().submit(plugin, sender);
save(user, sender, plugin); save(user, sender, plugin);
plugin.getApiProvider().fireEventAsync(new UserPromoteEvent(new TrackLink(track), new UserLink(user), old, nextGroup.getName())); plugin.getApiProvider().fireEventAsync(new UserPromoteEvent(new TrackDelegate(track), new UserDelegate(user), old, nextGroup.getName()));
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }

View File

@ -26,6 +26,7 @@ import lombok.experimental.UtilityClass;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.LocalizedNode; import me.lucko.luckperms.api.LocalizedNode;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.Tristate;
@ -35,7 +36,6 @@ import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.constants.Patterns; import me.lucko.luckperms.common.constants.Patterns;
import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.PermissionHolder;
import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.storage.holder.HeldPermission;
import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.DateUtil;
import io.github.mkremins.fanciful.ChatColor; import io.github.mkremins.fanciful.ChatColor;

View File

@ -45,8 +45,8 @@ import me.lucko.luckperms.api.event.events.PermissionNodeExpireEvent;
import me.lucko.luckperms.api.event.events.PermissionNodeSetEvent; import me.lucko.luckperms.api.event.events.PermissionNodeSetEvent;
import me.lucko.luckperms.api.event.events.PermissionNodeUnsetEvent; import me.lucko.luckperms.api.event.events.PermissionNodeUnsetEvent;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.api.internal.GroupLink; import me.lucko.luckperms.common.api.delegate.GroupDelegate;
import me.lucko.luckperms.common.api.internal.PermissionHolderLink; import me.lucko.luckperms.common.api.delegate.PermissionHolderDelegate;
import me.lucko.luckperms.common.caching.MetaHolder; import me.lucko.luckperms.common.caching.MetaHolder;
import me.lucko.luckperms.common.caching.handlers.CachedStateManager; import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
import me.lucko.luckperms.common.caching.handlers.GroupReference; import me.lucko.luckperms.common.caching.handlers.GroupReference;
@ -581,7 +581,7 @@ public abstract class PermissionHolder {
return false; return false;
} }
PermissionHolderLink link = new PermissionHolderLink(this); PermissionHolderDelegate link = new PermissionHolderDelegate(this);
for (Node r : removed) { for (Node r : removed) {
plugin.getApiProvider().fireEventAsync(new PermissionNodeExpireEvent(link, r)); plugin.getApiProvider().fireEventAsync(new PermissionNodeExpireEvent(link, r));
} }
@ -700,7 +700,7 @@ public abstract class PermissionHolder {
} }
invalidateCache(true); invalidateCache(true);
plugin.getApiProvider().fireEventAsync(new PermissionNodeSetEvent(new PermissionHolderLink(this), node)); plugin.getApiProvider().fireEventAsync(new PermissionNodeSetEvent(new PermissionHolderDelegate(this), node));
} }
/** /**
@ -719,7 +719,7 @@ public abstract class PermissionHolder {
} }
invalidateCache(false); invalidateCache(false);
plugin.getApiProvider().fireEventAsync(new PermissionNodeSetEvent(new PermissionHolderLink(this), node)); plugin.getApiProvider().fireEventAsync(new PermissionNodeSetEvent(new PermissionHolderDelegate(this), node));
} }
public void setPermission(String node, boolean value) throws ObjectAlreadyHasException { public void setPermission(String node, boolean value) throws ObjectAlreadyHasException {
@ -763,10 +763,10 @@ public abstract class PermissionHolder {
invalidateCache(true); invalidateCache(true);
if (node.isGroupNode()) { if (node.isGroupNode()) {
plugin.getApiProvider().fireEventAsync(new GroupRemoveEvent(new PermissionHolderLink(this), plugin.getApiProvider().fireEventAsync(new GroupRemoveEvent(new PermissionHolderDelegate(this),
node.getGroupName(), node.getServer().orElse(null), node.getWorld().orElse(null), node.isTemporary())); node.getGroupName(), node.getServer().orElse(null), node.getWorld().orElse(null), node.isTemporary()));
} else { } else {
plugin.getApiProvider().fireEventAsync(new PermissionNodeUnsetEvent(new PermissionHolderLink(this), node)); plugin.getApiProvider().fireEventAsync(new PermissionNodeUnsetEvent(new PermissionHolderDelegate(this), node));
} }
} }
@ -787,10 +787,10 @@ public abstract class PermissionHolder {
invalidateCache(false); invalidateCache(false);
if (node.isGroupNode()) { if (node.isGroupNode()) {
plugin.getApiProvider().fireEventAsync(new GroupRemoveEvent(new PermissionHolderLink(this), plugin.getApiProvider().fireEventAsync(new GroupRemoveEvent(new PermissionHolderDelegate(this),
node.getGroupName(), node.getServer().orElse(null), node.getWorld().orElse(null), node.isTemporary())); node.getGroupName(), node.getServer().orElse(null), node.getWorld().orElse(null), node.isTemporary()));
} else { } else {
plugin.getApiProvider().fireEventAsync(new PermissionNodeUnsetEvent(new PermissionHolderLink(this), node)); plugin.getApiProvider().fireEventAsync(new PermissionNodeUnsetEvent(new PermissionHolderDelegate(this), node));
} }
} }
@ -836,7 +836,7 @@ public abstract class PermissionHolder {
} }
setPermission("group." + group.getName(), true); setPermission("group." + group.getName(), true);
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), null, null, 0L)); getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderDelegate(this), new GroupDelegate(group), null, null, 0L));
} }
public void setInheritGroup(Group group, String server) throws ObjectAlreadyHasException { public void setInheritGroup(Group group, String server) throws ObjectAlreadyHasException {
@ -845,7 +845,7 @@ public abstract class PermissionHolder {
} }
setPermission("group." + group.getName(), true, server); setPermission("group." + group.getName(), true, server);
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, null, 0L)); getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderDelegate(this), new GroupDelegate(group), server, null, 0L));
} }
public void setInheritGroup(Group group, String server, String world) throws ObjectAlreadyHasException { public void setInheritGroup(Group group, String server, String world) throws ObjectAlreadyHasException {
@ -854,7 +854,7 @@ public abstract class PermissionHolder {
} }
setPermission("group." + group.getName(), true, server, world); setPermission("group." + group.getName(), true, server, world);
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, world, 0L)); getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderDelegate(this), new GroupDelegate(group), server, world, 0L));
} }
public void setInheritGroup(Group group, long expireAt) throws ObjectAlreadyHasException { public void setInheritGroup(Group group, long expireAt) throws ObjectAlreadyHasException {
@ -863,7 +863,7 @@ public abstract class PermissionHolder {
} }
setPermission("group." + group.getName(), true, expireAt); setPermission("group." + group.getName(), true, expireAt);
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), null, null, expireAt)); getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderDelegate(this), new GroupDelegate(group), null, null, expireAt));
} }
public void setInheritGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException { public void setInheritGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException {
@ -872,7 +872,7 @@ public abstract class PermissionHolder {
} }
setPermission("group." + group.getName(), true, server, expireAt); setPermission("group." + group.getName(), true, server, expireAt);
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, null, expireAt)); getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderDelegate(this), new GroupDelegate(group), server, null, expireAt));
} }
public void setInheritGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException { public void setInheritGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException {
@ -881,7 +881,7 @@ public abstract class PermissionHolder {
} }
setPermission("group." + group.getName(), true, server, world, expireAt); setPermission("group." + group.getName(), true, server, world, expireAt);
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, world, expireAt)); getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderDelegate(this), new GroupDelegate(group), server, world, expireAt));
} }
public void unsetInheritGroup(Group group) throws ObjectLacksException { public void unsetInheritGroup(Group group) throws ObjectLacksException {
@ -1087,6 +1087,8 @@ public abstract class PermissionHolder {
} }
public OptionalInt getWeight() { public OptionalInt getWeight() {
if (this instanceof User) return OptionalInt.empty();
OptionalInt weight = OptionalInt.empty(); OptionalInt weight = OptionalInt.empty();
try { try {
weight = getNodes().stream() weight = getNodes().stream()

View File

@ -30,7 +30,7 @@ import lombok.ToString;
import me.lucko.luckperms.api.caching.UserData; import me.lucko.luckperms.api.caching.UserData;
import me.lucko.luckperms.api.event.events.UserPermissionRefreshEvent; import me.lucko.luckperms.api.event.events.UserPermissionRefreshEvent;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.api.internal.UserLink; import me.lucko.luckperms.common.api.delegate.UserDelegate;
import me.lucko.luckperms.common.caching.UserCache; import me.lucko.luckperms.common.caching.UserCache;
import me.lucko.luckperms.common.caching.handlers.HolderReference; import me.lucko.luckperms.common.caching.handlers.HolderReference;
import me.lucko.luckperms.common.caching.handlers.UserReference; import me.lucko.luckperms.common.caching.handlers.UserReference;
@ -139,7 +139,7 @@ public class User extends PermissionHolder implements Identifiable<UserIdentifie
ud.recalculatePermissions(); ud.recalculatePermissions();
ud.recalculateMeta(); ud.recalculateMeta();
getPlugin().getApiProvider().fireEventAsync(new UserPermissionRefreshEvent(new UserLink(this))); getPlugin().getApiProvider().fireEventAsync(new UserPermissionRefreshEvent(new UserDelegate(this)));
getPlugin().onUserRefresh(this); getPlugin().onUserRefresh(this);
} }

View File

@ -26,6 +26,7 @@ import lombok.AccessLevel;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.experimental.Delegate; import lombok.experimental.Delegate;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Group;
@ -33,7 +34,6 @@ import me.lucko.luckperms.common.core.model.Track;
import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.data.Log; import me.lucko.luckperms.common.data.Log;
import me.lucko.luckperms.common.storage.backing.AbstractBacking; import me.lucko.luckperms.common.storage.backing.AbstractBacking;
import me.lucko.luckperms.common.storage.holder.HeldPermission;
import me.lucko.luckperms.common.storage.wrappings.BufferedOutputStorage; import me.lucko.luckperms.common.storage.wrappings.BufferedOutputStorage;
import me.lucko.luckperms.common.storage.wrappings.TolerantStorage; import me.lucko.luckperms.common.storage.wrappings.TolerantStorage;

View File

@ -24,6 +24,7 @@ package me.lucko.luckperms.common.storage;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Group;
@ -31,7 +32,6 @@ import me.lucko.luckperms.common.core.model.Track;
import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.data.Log; import me.lucko.luckperms.common.data.Log;
import me.lucko.luckperms.common.storage.backing.AbstractBacking; import me.lucko.luckperms.common.storage.backing.AbstractBacking;
import me.lucko.luckperms.common.storage.holder.HeldPermission;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -22,12 +22,12 @@
package me.lucko.luckperms.common.storage; package me.lucko.luckperms.common.storage;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Group;
import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.core.model.Track;
import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.data.Log; import me.lucko.luckperms.common.data.Log;
import me.lucko.luckperms.common.storage.holder.HeldPermission;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;

View File

@ -27,13 +27,13 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Setter; import lombok.Setter;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Group;
import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.core.model.Track;
import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.data.Log; import me.lucko.luckperms.common.data.Log;
import me.lucko.luckperms.common.storage.holder.HeldPermission;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;

View File

@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableList;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonWriter;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.NodeFactory;
@ -36,7 +37,6 @@ import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.managers.GroupManager; import me.lucko.luckperms.common.managers.GroupManager;
import me.lucko.luckperms.common.managers.TrackManager; import me.lucko.luckperms.common.managers.TrackManager;
import me.lucko.luckperms.common.managers.impl.GenericUserManager; import me.lucko.luckperms.common.managers.impl.GenericUserManager;
import me.lucko.luckperms.common.storage.holder.HeldPermission;
import me.lucko.luckperms.common.storage.holder.NodeHeldPermission; import me.lucko.luckperms.common.storage.holder.NodeHeldPermission;
import me.lucko.luckperms.common.utils.ThrowingFunction; import me.lucko.luckperms.common.utils.ThrowingFunction;

View File

@ -31,6 +31,7 @@ import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoDatabase; import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.InsertOneOptions; import com.mongodb.client.model.InsertOneOptions;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
@ -44,7 +45,6 @@ import me.lucko.luckperms.common.managers.GroupManager;
import me.lucko.luckperms.common.managers.TrackManager; import me.lucko.luckperms.common.managers.TrackManager;
import me.lucko.luckperms.common.managers.impl.GenericUserManager; import me.lucko.luckperms.common.managers.impl.GenericUserManager;
import me.lucko.luckperms.common.storage.DatastoreConfiguration; import me.lucko.luckperms.common.storage.DatastoreConfiguration;
import me.lucko.luckperms.common.storage.holder.HeldPermission;
import me.lucko.luckperms.common.storage.holder.NodeHeldPermission; import me.lucko.luckperms.common.storage.holder.NodeHeldPermission;
import org.bson.Document; import org.bson.Document;

View File

@ -29,6 +29,7 @@ import com.google.common.collect.Maps;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
@ -43,7 +44,6 @@ import me.lucko.luckperms.common.managers.impl.GenericUserManager;
import me.lucko.luckperms.common.storage.backing.sqlprovider.SQLProvider; import me.lucko.luckperms.common.storage.backing.sqlprovider.SQLProvider;
import me.lucko.luckperms.common.storage.backing.utils.LegacySchemaMigration; import me.lucko.luckperms.common.storage.backing.utils.LegacySchemaMigration;
import me.lucko.luckperms.common.storage.backing.utils.NodeDataHolder; import me.lucko.luckperms.common.storage.backing.utils.NodeDataHolder;
import me.lucko.luckperms.common.storage.holder.HeldPermission;
import me.lucko.luckperms.common.storage.holder.NodeHeldPermission; import me.lucko.luckperms.common.storage.holder.NodeHeldPermission;
import java.io.BufferedReader; import java.io.BufferedReader;

View File

@ -24,6 +24,7 @@ package me.lucko.luckperms.common.storage.backing;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.NodeFactory;
@ -34,7 +35,6 @@ import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.managers.GroupManager; import me.lucko.luckperms.common.managers.GroupManager;
import me.lucko.luckperms.common.managers.TrackManager; import me.lucko.luckperms.common.managers.TrackManager;
import me.lucko.luckperms.common.managers.impl.GenericUserManager; import me.lucko.luckperms.common.managers.impl.GenericUserManager;
import me.lucko.luckperms.common.storage.holder.HeldPermission;
import me.lucko.luckperms.common.storage.holder.NodeHeldPermission; import me.lucko.luckperms.common.storage.holder.NodeHeldPermission;
import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.DumperOptions;

View File

@ -28,6 +28,7 @@ import lombok.Getter;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.common.storage.backing.utils.NodeDataHolder; import me.lucko.luckperms.common.storage.backing.utils.NodeDataHolder;

View File

@ -26,13 +26,13 @@ import lombok.AccessLevel;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.experimental.Delegate; import lombok.experimental.Delegate;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Group;
import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.core.model.Track;
import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.data.Log; import me.lucko.luckperms.common.data.Log;
import me.lucko.luckperms.common.storage.Storage; import me.lucko.luckperms.common.storage.Storage;
import me.lucko.luckperms.common.storage.holder.HeldPermission;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;

View File

@ -6,7 +6,7 @@
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<version>2.16-SNAPSHOT</version> <version>2.17-SNAPSHOT</version>
<modules> <modules>
<module>common</module> <module>common</module>
<module>api</module> <module>api</module>
@ -38,7 +38,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<release.version>2.16</release.version> <release.version>2.17</release.version>
</properties> </properties>
<distributionManagement> <distributionManagement>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.16-SNAPSHOT</version> <version>2.17-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>