Changes for version 2.16

This commit is contained in:
Luck 2016-12-02 20:20:24 +00:00
parent a063f7664d
commit 307e2b889c
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
264 changed files with 3450 additions and 2063 deletions

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.15-SNAPSHOT</version> <version>2.16-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -34,6 +34,7 @@ public final class LuckPerms {
/** /**
* Gets an instance of {@link LuckPermsApi} * Gets an instance of {@link LuckPermsApi}
*
* @return an api instance * @return an api instance
* @throws IllegalStateException if the api is not loaded * @throws IllegalStateException if the api is not loaded
*/ */
@ -47,6 +48,7 @@ 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. Unlike {@link LuckPerms#getApi}, this method will not throw an
* {@link IllegalStateException} if the api is not loaded, rather return an empty {@link Optional}. * {@link IllegalStateException} if the api is not loaded, rather return an empty {@link Optional}.
*
* @return an optional api instance * @return an optional api instance
*/ */
public static Optional<LuckPermsApi> getApiSafe() { public static Optional<LuckPermsApi> getApiSafe() {

View File

@ -29,15 +29,17 @@ import java.util.Map;
/** /**
* Represents the context and options for a permission lookup. * Represents the context and options for a permission lookup.
* All values are immutable. * All values are immutable.
*
* @since 2.11 * @since 2.11
*/ */
public class Contexts { public class Contexts {
private static final Contexts ALLOW_ALL = new Contexts(ContextSet.empty(), true, true, true, true, true, true);
public static final String SERVER_KEY = "server"; public static final String SERVER_KEY = "server";
public static final String WORLD_KEY = "world"; public static final String WORLD_KEY = "world";
private static final Contexts ALLOW_ALL = new Contexts(ContextSet.empty(), true, true, true, true, true, true);
/** /**
* Gets a context that will allow all nodes * Gets a context that will allow all nodes
*
* @return a context that will not apply any filters * @return a context that will not apply any filters
*/ */
public static Contexts allowAll() { public static Contexts allowAll() {
@ -48,6 +50,50 @@ public class Contexts {
return new Contexts(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, op); return new Contexts(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, op);
} }
@SuppressWarnings("deprecation")
@Deprecated
public static Contexts of(Map<String, String> context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups) {
return new Contexts(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups);
}
@SuppressWarnings("deprecation")
@Deprecated
public static Contexts of(Map<String, String> context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) {
return new Contexts(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, op);
}
/**
* The contexts that apply for this lookup
* The keys for servers and worlds are defined as static values.
*/
private final ContextSet context;
/**
* The mode to parse defaults on Bukkit
*
* @since 2.12
*/
private final boolean op;
/**
* If global or non server specific nodes should be applied
*/
private final boolean includeGlobal;
/**
* If global or non world specific nodes should be applied
*/
private final boolean includeGlobalWorld;
/**
* If parent groups should be applied
*/
private final boolean applyGroups;
/**
* If global or non server specific group memberships should be applied
*/
private final boolean applyGlobalGroups;
/**
* If global or non world specific group memberships should be applied
*/
private final boolean applyGlobalWorldGroups;
public Contexts(ContextSet context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) { public Contexts(ContextSet context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) {
if (context == null) { if (context == null) {
throw new NullPointerException("context"); throw new NullPointerException("context");
@ -62,18 +108,6 @@ public class Contexts {
this.op = op; this.op = op;
} }
@SuppressWarnings("deprecation")
@Deprecated
public static Contexts of(Map<String, String> context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups) {
return new Contexts(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups);
}
@SuppressWarnings("deprecation")
@Deprecated
public static Contexts of(Map<String, String> context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) {
return new Contexts(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, op);
}
@Deprecated @Deprecated
public Contexts(Map<String, String> context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) { public Contexts(Map<String, String> context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) {
this(context == null ? null : ContextSet.fromMap(context), includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, op); this(context == null ? null : ContextSet.fromMap(context), includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, op);
@ -85,45 +119,9 @@ public class Contexts {
this(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, false); this(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, false);
} }
/**
* The contexts that apply for this lookup
* The keys for servers and worlds are defined as static values.
*/
private final ContextSet context;
/**
* The mode to parse defaults on Bukkit
* @since 2.12
*/
private final boolean op;
/**
* If global or non server specific nodes should be applied
*/
private final boolean includeGlobal;
/**
* If global or non world specific nodes should be applied
*/
private final boolean includeGlobalWorld;
/**
* If parent groups should be applied
*/
private final boolean applyGroups;
/**
* If global or non server specific group memberships should be applied
*/
private final boolean applyGlobalGroups;
/**
* If global or non world specific group memberships should be applied
*/
private final boolean applyGlobalWorldGroups;
/** /**
* Gets the contexts that apply for this lookup * Gets the contexts that apply for this lookup
*
* @return an immutable set of context key value pairs * @return an immutable set of context key value pairs
* @since 2.13 * @since 2.13
*/ */
@ -133,6 +131,7 @@ public class Contexts {
/** /**
* Gets the contexts that apply for this lookup * Gets the contexts that apply for this lookup
*
* @return an immutable map of context key value pairs * @return an immutable map of context key value pairs
* @deprecated in favour of {@link #getContexts()} * @deprecated in favour of {@link #getContexts()}
*/ */
@ -143,6 +142,7 @@ public class Contexts {
/** /**
* Gets if OP defaults should be included * Gets if OP defaults should be included
*
* @return true if op defaults should be included * @return true if op defaults should be included
*/ */
public boolean isOp() { public boolean isOp() {
@ -151,6 +151,7 @@ public class Contexts {
/** /**
* Gets if global or non server specific nodes should be applied * Gets if global or non server specific nodes should be applied
*
* @return true if global or non server specific nodes should be applied * @return true if global or non server specific nodes should be applied
*/ */
public boolean isIncludeGlobal() { public boolean isIncludeGlobal() {
@ -159,6 +160,7 @@ public class Contexts {
/** /**
* Gets if global or non world specific nodes should be applied * Gets if global or non world specific nodes should be applied
*
* @return true if global or non world specific nodes should be applied * @return true if global or non world specific nodes should be applied
*/ */
public boolean isIncludeGlobalWorld() { public boolean isIncludeGlobalWorld() {
@ -167,6 +169,7 @@ public class Contexts {
/** /**
* Gets if parent groups should be applied * Gets if parent groups should be applied
*
* @return true if parent groups should be applied * @return true if parent groups should be applied
*/ */
public boolean isApplyGroups() { public boolean isApplyGroups() {
@ -175,6 +178,7 @@ public class Contexts {
/** /**
* Gets if global or non server specific group memberships should be applied * Gets if global or non server specific group memberships should be applied
*
* @return true if global or non server specific group memberships should be applied * @return true if global or non server specific group memberships should be applied
*/ */
public boolean isApplyGlobalGroups() { public boolean isApplyGlobalGroups() {
@ -183,6 +187,7 @@ public class Contexts {
/** /**
* Gets if global or non world specific group memberships should be applied * Gets if global or non world specific group memberships should be applied
*
* @return true if global or non world specific group memberships should be applied * @return true if global or non world specific group memberships should be applied
*/ */
public boolean isApplyGlobalWorldGroups() { public boolean isApplyGlobalWorldGroups() {
@ -207,6 +212,7 @@ public class Contexts {
/** /**
* Check for equality * Check for equality
*
* @param o the other * @param o the other
* @return true if equal * @return true if equal
* @since 2.12 * @since 2.12
@ -229,6 +235,7 @@ public class Contexts {
/** /**
* Gets the hashcode * Gets the hashcode
*
* @return the hashcode * @return the hashcode
* @since 2.12 * @since 2.12
*/ */

View File

@ -29,12 +29,14 @@ import java.util.UUID;
/** /**
* Interface for the internal Datastore instance * Interface for the internal Datastore instance
*
* @deprecated as of version 2.14 in favour of {@link Storage}. * @deprecated as of version 2.14 in favour of {@link Storage}.
*/ */
@Deprecated @Deprecated
public interface Datastore { public interface Datastore {
String getName(); String getName();
boolean isAcceptingLogins(); boolean isAcceptingLogins();
@Deprecated @Deprecated
@ -49,78 +51,135 @@ public interface Datastore {
@Deprecated @Deprecated
interface Sync { interface Sync {
boolean logAction(LogEntry entry); boolean logAction(LogEntry entry);
Log getLog(); Log getLog();
@Deprecated @Deprecated
boolean loadOrCreateUser(UUID uuid, String username); boolean loadOrCreateUser(UUID uuid, String username);
@Deprecated @Deprecated
boolean loadUser(UUID uuid); boolean loadUser(UUID uuid);
boolean loadUser(UUID uuid, String username); boolean loadUser(UUID uuid, String username);
boolean saveUser(User user); boolean saveUser(User user);
boolean cleanupUsers(); boolean cleanupUsers();
Set<UUID> getUniqueUsers(); Set<UUID> getUniqueUsers();
boolean createAndLoadGroup(String name); boolean createAndLoadGroup(String name);
boolean loadGroup(String name); boolean loadGroup(String name);
boolean loadAllGroups(); boolean loadAllGroups();
boolean saveGroup(Group group); boolean saveGroup(Group group);
boolean deleteGroup(Group group); boolean deleteGroup(Group group);
boolean createAndLoadTrack(String name); boolean createAndLoadTrack(String name);
boolean loadTrack(String name); boolean loadTrack(String name);
boolean loadAllTracks(); boolean loadAllTracks();
boolean saveTrack(Track track); boolean saveTrack(Track track);
boolean deleteTrack(Track track); boolean deleteTrack(Track track);
boolean saveUUIDData(String username, UUID uuid); boolean saveUUIDData(String username, UUID uuid);
UUID getUUID(String username); UUID getUUID(String username);
} }
@Deprecated @Deprecated
interface Async { interface Async {
void logAction(LogEntry entry, Callback<Boolean> callback); void logAction(LogEntry entry, Callback<Boolean> callback);
void getLog(Callback<Log> callback); void getLog(Callback<Log> callback);
@Deprecated @Deprecated
void loadOrCreateUser(UUID uuid, String username, Callback<Boolean> callback); void loadOrCreateUser(UUID uuid, String username, Callback<Boolean> callback);
@Deprecated @Deprecated
void loadUser(UUID uuid, Callback<Boolean> callback); void loadUser(UUID uuid, Callback<Boolean> callback);
void loadUser(UUID uuid, String username, Callback<Boolean> callback); void loadUser(UUID uuid, String username, Callback<Boolean> callback);
void saveUser(User user, Callback<Boolean> callback); void saveUser(User user, Callback<Boolean> callback);
void cleanupUsers(Callback<Boolean> callback); void cleanupUsers(Callback<Boolean> callback);
void getUniqueUsers(Callback<Set<UUID>> callback); void getUniqueUsers(Callback<Set<UUID>> callback);
void createAndLoadGroup(String name, Callback<Boolean> callback); void createAndLoadGroup(String name, Callback<Boolean> callback);
void loadGroup(String name, Callback<Boolean> callback); void loadGroup(String name, Callback<Boolean> callback);
void loadAllGroups(Callback<Boolean> callback); void loadAllGroups(Callback<Boolean> callback);
void saveGroup(Group group, Callback<Boolean> callback); void saveGroup(Group group, Callback<Boolean> callback);
void deleteGroup(Group group, Callback<Boolean> callback); void deleteGroup(Group group, Callback<Boolean> callback);
void createAndLoadTrack(String name, Callback<Boolean> callback); void createAndLoadTrack(String name, Callback<Boolean> callback);
void loadTrack(String name, Callback<Boolean> callback); void loadTrack(String name, Callback<Boolean> callback);
void loadAllTracks(Callback<Boolean> callback); void loadAllTracks(Callback<Boolean> callback);
void saveTrack(Track track, Callback<Boolean> callback); void saveTrack(Track track, Callback<Boolean> callback);
void deleteTrack(Track track, Callback<Boolean> callback); void deleteTrack(Track track, Callback<Boolean> callback);
void saveUUIDData(String username, UUID uuid, Callback<Boolean> callback); void saveUUIDData(String username, UUID uuid, Callback<Boolean> callback);
void getUUID(String username, Callback<UUID> callback); void getUUID(String username, Callback<UUID> callback);
} }
@Deprecated @Deprecated
interface Future { interface Future {
java.util.concurrent.Future<Boolean> logAction(LogEntry entry); java.util.concurrent.Future<Boolean> logAction(LogEntry entry);
java.util.concurrent.Future<Log> getLog(); java.util.concurrent.Future<Log> getLog();
@Deprecated @Deprecated
java.util.concurrent.Future<Boolean> loadOrCreateUser(UUID uuid, String username); java.util.concurrent.Future<Boolean> loadOrCreateUser(UUID uuid, String username);
@Deprecated @Deprecated
java.util.concurrent.Future<Boolean> loadUser(UUID uuid); java.util.concurrent.Future<Boolean> loadUser(UUID uuid);
java.util.concurrent.Future<Boolean> loadUser(UUID uuid, String username); java.util.concurrent.Future<Boolean> loadUser(UUID uuid, String username);
java.util.concurrent.Future<Boolean> saveUser(User user); java.util.concurrent.Future<Boolean> saveUser(User user);
java.util.concurrent.Future<Boolean> cleanupUsers(); java.util.concurrent.Future<Boolean> cleanupUsers();
java.util.concurrent.Future<Set<UUID>> getUniqueUsers(); java.util.concurrent.Future<Set<UUID>> getUniqueUsers();
java.util.concurrent.Future<Boolean> createAndLoadGroup(String name); java.util.concurrent.Future<Boolean> createAndLoadGroup(String name);
java.util.concurrent.Future<Boolean> loadGroup(String name); java.util.concurrent.Future<Boolean> loadGroup(String name);
java.util.concurrent.Future<Boolean> loadAllGroups(); java.util.concurrent.Future<Boolean> loadAllGroups();
java.util.concurrent.Future<Boolean> saveGroup(Group group); java.util.concurrent.Future<Boolean> saveGroup(Group group);
java.util.concurrent.Future<Boolean> deleteGroup(Group group); java.util.concurrent.Future<Boolean> deleteGroup(Group group);
java.util.concurrent.Future<Boolean> createAndLoadTrack(String name); java.util.concurrent.Future<Boolean> createAndLoadTrack(String name);
java.util.concurrent.Future<Boolean> loadTrack(String name); java.util.concurrent.Future<Boolean> loadTrack(String name);
java.util.concurrent.Future<Boolean> loadAllTracks(); java.util.concurrent.Future<Boolean> loadAllTracks();
java.util.concurrent.Future<Boolean> saveTrack(Track track); java.util.concurrent.Future<Boolean> saveTrack(Track track);
java.util.concurrent.Future<Boolean> deleteTrack(Track track); java.util.concurrent.Future<Boolean> deleteTrack(Track track);
java.util.concurrent.Future<Boolean> saveUUIDData(String username, UUID uuid); java.util.concurrent.Future<Boolean> saveUUIDData(String username, UUID uuid);
java.util.concurrent.Future<UUID> getUUID(String username); java.util.concurrent.Future<UUID> getUUID(String username);
} }
} }

View File

@ -40,6 +40,7 @@ public interface Group extends PermissionHolder {
/** /**
* Check to see if a group inherits a group * Check to see if a group inherits a group
*
* @param group The group to check membership of * @param group The group to check membership of
* @return true if the group inherits the other group * @return true if the group inherits the other group
* @throws NullPointerException if the group is null * @throws NullPointerException if the group is null
@ -49,6 +50,7 @@ public interface Group extends PermissionHolder {
/** /**
* Check to see if the group inherits a group on a specific server * Check to see if the group inherits a group on a specific server
*
* @param group The group to check membership of * @param group The group to check membership of
* @param server The server to check on * @param server The server to check on
* @return true if the group inherits the group on the server * @return true if the group inherits the group on the server
@ -60,6 +62,7 @@ public interface Group extends PermissionHolder {
/** /**
* Check to see if the group inherits a group on a specific server and world * Check to see if the group inherits a group on a specific server and world
*
* @param group The group to check membership of * @param group The group to check membership of
* @param server The server to check on * @param server The server to check on
* @param world The world to check on * @param world The world to check on
@ -72,6 +75,7 @@ public interface Group extends PermissionHolder {
/** /**
* Make this group inherit another group * Make this group inherit another group
*
* @param group the group to be inherited * @param group the group to be inherited
* @throws ObjectAlreadyHasException if the group already inherits the group * @throws ObjectAlreadyHasException if the group already inherits the group
* @throws NullPointerException if the group is null * @throws NullPointerException if the group is null
@ -81,6 +85,7 @@ public interface Group extends PermissionHolder {
/** /**
* Make this group inherit another group on a specific server * Make this group inherit another group on a specific server
*
* @param group the group to be inherited * @param group the group to be inherited
* @param server The server to inherit the group on * @param server The server to inherit the group on
* @throws ObjectAlreadyHasException if the group already inherits the group on that server * @throws ObjectAlreadyHasException if the group already inherits the group on that server
@ -92,6 +97,7 @@ public interface Group extends PermissionHolder {
/** /**
* Make this group inherit another group on a specific server and world * Make this group inherit another group on a specific server and world
*
* @param group the group to be inherited * @param group the group to be inherited
* @param server The server to inherit the group on * @param server The server to inherit the group on
* @param world The world to inherit the group on * @param world The world to inherit the group on
@ -104,6 +110,7 @@ public interface Group extends PermissionHolder {
/** /**
* Make this group inherit another group temporarily * Make this group inherit another group temporarily
*
* @param group the group to be inherited * @param group the group to be inherited
* @param expireAt the unix time when the group should expire * @param expireAt the unix time when the group should expire
* @throws ObjectAlreadyHasException if the group already inherits the group temporarily * @throws ObjectAlreadyHasException if the group already inherits the group temporarily
@ -115,6 +122,7 @@ public interface Group extends PermissionHolder {
/** /**
* Make this group inherit another group on a specific server temporarily * Make this group inherit another group on a specific server temporarily
*
* @param group the group to be inherited * @param group the group to be inherited
* @param server The server inherit add the group on * @param server The server inherit add the group on
* @param expireAt when the group should expire * @param expireAt when the group should expire
@ -127,6 +135,7 @@ public interface Group extends PermissionHolder {
/** /**
* Make this group inherit another group on a specific server and world temporarily * Make this group inherit another group on a specific server and world temporarily
*
* @param group the group to be inherited * @param group the group to be inherited
* @param server The server to inherit the group on * @param server The server to inherit the group on
* @param world The world to inherit the group on * @param world The world to inherit the group on
@ -140,6 +149,7 @@ public interface Group extends PermissionHolder {
/** /**
* Remove a previously set inheritance rule * Remove a previously set inheritance rule
*
* @param group the group to uninherit * @param group the group to uninherit
* @throws ObjectLacksException if the group does not already inherit the group * @throws ObjectLacksException if the group does not already inherit the group
* @throws NullPointerException if the group is null * @throws NullPointerException if the group is null
@ -149,6 +159,7 @@ public interface Group extends PermissionHolder {
/** /**
* Remove a previously set inheritance rule * Remove a previously set inheritance rule
*
* @param group the group to uninherit * @param group the group to uninherit
* @param temporary if the group being removed is temporary * @param temporary if the group being removed is temporary
* @throws ObjectLacksException if the group does not already inherit the group * @throws ObjectLacksException if the group does not already inherit the group
@ -159,6 +170,7 @@ public interface Group extends PermissionHolder {
/** /**
* Remove a previously set inheritance rule on a specific server * Remove a previously set inheritance rule on a specific server
*
* @param group the group to uninherit * @param group the group to uninherit
* @param server The server to remove the group on * @param server The server to remove the group on
* @throws ObjectLacksException if the group does not already inherit the group on that server * @throws ObjectLacksException if the group does not already inherit the group on that server
@ -170,6 +182,7 @@ public interface Group extends PermissionHolder {
/** /**
* Remove a previously set inheritance rule on a specific server and world * Remove a previously set inheritance rule on a specific server and world
*
* @param group the group to uninherit * @param group the group to uninherit
* @param server The server to remove the group on * @param server The server to remove the group on
* @param world The world to remove the group on * @param world The world to remove the group on
@ -182,6 +195,7 @@ public interface Group extends PermissionHolder {
/** /**
* Remove a previously set inheritance rule on a specific server * Remove a previously set inheritance rule on a specific server
*
* @param group the group to uninherit * @param group the group to uninherit
* @param server The server to remove the group on * @param server The server to remove the group on
* @param temporary if the group being removed is temporary * @param temporary if the group being removed is temporary
@ -194,6 +208,7 @@ public interface Group extends PermissionHolder {
/** /**
* Remove a previously set inheritance rule on a specific server and world * Remove a previously set inheritance rule on a specific server and world
*
* @param group the group to uninherit * @param group the group to uninherit
* @param server The server to remove the group on * @param server The server to remove the group on
* @param world The world to remove the group on * @param world The world to remove the group on
@ -212,12 +227,14 @@ public interface Group extends PermissionHolder {
/** /**
* 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
*
* @return a {@link List} of group names * @return a {@link List} of group names
*/ */
List<String> getGroupNames(); List<String> getGroupNames();
/** /**
* 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
* @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
@ -228,6 +245,7 @@ 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 * @return a {@link List} of group names
* @throws NullPointerException if the server is null * @throws NullPointerException if the server is null

View File

@ -169,8 +169,8 @@ public interface LPConfiguration {
boolean getSplitStorage(); boolean getSplitStorage();
/** /**
* @return a map of split storage options, where the key is the storage section, and the value is the storage method. * @return a map of split storage options, where the key is the storage section, and the value is the storage
* For example: key = user, value = json * method. For example: key = user, value = json
* @since 2.7 * @since 2.7
*/ */
Map<String, String> getSplitStorageOptions(); Map<String, String> getSplitStorageOptions();

View File

@ -24,18 +24,21 @@ package me.lucko.luckperms.api;
/** /**
* Represents a Node and where it was inherited from. * Represents a Node and where it was inherited from.
*
* @since 2.11 * @since 2.11
*/ */
public interface LocalizedNode extends Node { public interface LocalizedNode extends Node {
/** /**
* Gets the node * Gets the node
*
* @return the node this instance is representing * @return the node this instance is representing
*/ */
Node getNode(); Node getNode();
/** /**
* Gets the location where the {@link Node} is inherited from * Gets the location where the {@link Node} is inherited from
*
* @return where the node was inherited from. Will not return null. * @return where the node was inherited from. Will not return null.
* @see PermissionHolder#getObjectName() * @see PermissionHolder#getObjectName()
*/ */

View File

@ -27,8 +27,8 @@ import java.util.SortedSet;
import java.util.UUID; import java.util.UUID;
/** /**
* Represents the internal LuckPerms log. * Represents the internal LuckPerms log. All content internally is immutable. You can add to the log using the {@link
* All content internally is immutable. You can add to the log using the {@link Datastore}, and then request an updated copy. * Datastore}, and then request an updated copy.
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public interface Log { public interface Log {
@ -45,6 +45,7 @@ public interface Log {
/** /**
* Gets the recent content separated by page * Gets the recent content separated by page
*
* @param pageNo the page number * @param pageNo the page number
* @return the page content * @return the page content
*/ */
@ -64,6 +65,7 @@ public interface Log {
/** /**
* Gets the recent content for the uuid, separated into pages * Gets the recent content for the uuid, separated into pages
*
* @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
@ -85,6 +87,7 @@ public interface Log {
/** /**
* Gets the user history content, separated by pages * Gets the user history content, separated by pages
*
* @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
@ -106,6 +109,7 @@ public interface Log {
/** /**
* Gets the group history content, separated by pages * Gets the group history content, separated by pages
*
* @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
@ -127,6 +131,7 @@ public interface Log {
/** /**
* Gets the track history content, separated by pages * Gets the track history content, separated by pages
*
* @param pageNo the page number * @param pageNo the page number
* @param name the name of the acted track to filter by * @param name the name of the acted track to filter by
* @return the page content * @return the page content
@ -147,6 +152,7 @@ public interface Log {
/** /**
* Gets the search content, separated by pages * Gets the search content, separated by pages
*
* @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

View File

@ -29,12 +29,12 @@ import java.util.UUID;
*/ */
@SuppressWarnings({"unused", "WeakerAccess"}) @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";
public static LogEntryBuilder builder() { public static LogEntryBuilder builder() {
return new LogEntryBuilder(); return new LogEntryBuilder();
} }
private static final String FORMAT = "&8(&e%s&8) [&a%s&8] (&b%s&8) &7--> &f%s";
private long timestamp; private long timestamp;
private UUID actor; private UUID actor;
private String actorName; private String actorName;
@ -100,54 +100,54 @@ public class LogEntry implements Comparable<LogEntry> {
return timestamp; return timestamp;
} }
public UUID getActor() {
return actor;
}
public String getActorName() {
return actorName;
}
public char getType() {
return type;
}
public UUID getActed() {
return acted;
}
public String getActedName() {
return actedName;
}
public String getAction() {
return action;
}
void setTimestamp(long timestamp) { void setTimestamp(long timestamp) {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
public UUID getActor() {
return actor;
}
void setActor(UUID actor) { void setActor(UUID actor) {
this.actor = actor; this.actor = actor;
} }
public String getActorName() {
return actorName;
}
void setActorName(String actorName) { void setActorName(String actorName) {
this.actorName = actorName; this.actorName = actorName;
} }
public char getType() {
return type;
}
void setType(char type) { void setType(char type) {
this.type = type; this.type = type;
} }
public UUID getActed() {
return acted;
}
void setActed(UUID acted) { void setActed(UUID acted) {
this.acted = acted; this.acted = acted;
} }
public String getActedName() {
return actedName;
}
void setActedName(String actedName) { void setActedName(String actedName) {
this.actedName = actedName; this.actedName = actedName;
} }
public String getAction() {
return action;
}
void setAction(String action) { void setAction(String action) {
this.action = action; this.action = action;
} }
@ -226,6 +226,7 @@ public class LogEntry implements Comparable<LogEntry> {
} }
protected abstract T createObj(); protected abstract T createObj();
protected abstract B getThis(); protected abstract B getThis();
public long getTimestamp() { public long getTimestamp() {

View File

@ -25,13 +25,15 @@ 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 commons * <p> Bukkit/Bungee both use java.util.logging, and Sponge uses org.slf4j. This class wraps those classes so the
* module can access a logger. * commons module can access a logger.
*/ */
public interface Logger { public interface Logger {
void info(String s); void info(String s);
void warn(String s); void warn(String s);
void severe(String s); void severe(String s);
} }

View File

@ -60,6 +60,7 @@ public interface LuckPermsApi {
/** /**
* Registers a listener to be sent LuckPerms events * Registers a listener to be sent LuckPerms events
*
* @param listener the listener instance * @param listener the listener instance
* @throws NullPointerException if the listener is null * @throws NullPointerException if the listener is null
*/ */
@ -67,6 +68,7 @@ public interface LuckPermsApi {
/** /**
* Unregisters a previously registered listener from the EventBus * Unregisters a previously registered listener from the EventBus
*
* @param listener the listener instance to unregister * @param listener the listener instance to unregister
* @throws NullPointerException if the listener is null * @throws NullPointerException if the listener is null
*/ */
@ -74,12 +76,14 @@ public interface LuckPermsApi {
/** /**
* Gets a wrapped {@link LPConfiguration} instance, with read only access * Gets a wrapped {@link LPConfiguration} instance, with read only access
*
* @return a configuration instance * @return a configuration instance
*/ */
LPConfiguration getConfiguration(); LPConfiguration getConfiguration();
/** /**
* Gets a wrapped {@link Storage} instance. * Gets a wrapped {@link Storage} instance.
*
* @return a storage instance * @return a storage instance
* @since 2.14 * @since 2.14
*/ */
@ -87,6 +91,7 @@ public interface LuckPermsApi {
/** /**
* Gets a wrapped Datastore instance. * Gets a wrapped Datastore instance.
*
* @return a datastore instance * @return a datastore instance
* @deprecated in favour of {@link #getStorage()} * @deprecated in favour of {@link #getStorage()}
*/ */
@ -96,24 +101,28 @@ public interface LuckPermsApi {
/** /**
* Gets the messaging service in use on the platform, if present. * Gets the messaging service in use on the platform, if present.
*
* @return an optional that may contain a messaging service instance. * @return an optional that may contain a messaging service instance.
*/ */
Optional<MessagingService> getMessagingService(); Optional<MessagingService> getMessagingService();
/** /**
* Gets the {@link Logger} wrapping used by the platform * Gets the {@link Logger} wrapping used by the platform
*
* @return the logger instance * @return the logger instance
*/ */
Logger getLogger(); Logger getLogger();
/** /**
* Gets a wrapped {@link UuidCache} instance, providing read access to the LuckPerms internal uuid caching system * Gets a wrapped {@link UuidCache} instance, providing read access to the LuckPerms internal uuid caching system
*
* @return a uuid cache instance * @return a uuid cache instance
*/ */
UuidCache getUuidCache(); UuidCache getUuidCache();
/** /**
* Gets a wrapped user object from the user storage * Gets a wrapped user object from the user storage
*
* @param uuid the uuid of the user to get * @param uuid the uuid of the user to get
* @return a {@link User} object, if one matching the uuid is loaded, or null if not * @return a {@link User} object, if one matching the uuid is loaded, or null if not
* @throws NullPointerException if the uuid is null * @throws NullPointerException if the uuid is null
@ -122,6 +131,7 @@ public interface LuckPermsApi {
/** /**
* Gets a wrapped user object from the user storage. This method does not return null, unlike {@link #getUser(UUID)} * Gets a wrapped user object from the user storage. This method does not return null, unlike {@link #getUser(UUID)}
*
* @param uuid the uuid of the user to get * @param uuid the uuid of the user to get
* @return an optional {@link User} object * @return an optional {@link User} object
* @throws NullPointerException if the uuid is null * @throws NullPointerException if the uuid is null
@ -130,6 +140,7 @@ public interface LuckPermsApi {
/** /**
* Gets a wrapped user object from the user storage * Gets a wrapped user object from the user storage
*
* @param name the username of the user to get * @param name the username of the user to get
* @return a {@link User} object, if one matching the uuid is loaded, or null if not * @return a {@link User} object, if one matching the uuid is loaded, or null if not
* @throws NullPointerException if the name is null * @throws NullPointerException if the name is null
@ -137,7 +148,9 @@ public interface LuckPermsApi {
User getUser(String name); User getUser(String name);
/** /**
* Gets a wrapped user object from the user storage. This method does not return null, unlike {@link #getUser(String)} * Gets a wrapped user object from the user storage. This method does not return null, unlike {@link
* #getUser(String)}
*
* @param name the username of the user to get * @param name the username of the user to get
* @return an optional {@link User} object * @return an optional {@link User} object
* @throws NullPointerException if the name is null * @throws NullPointerException if the name is null
@ -146,12 +159,14 @@ public interface LuckPermsApi {
/** /**
* Gets a set of all loaded users. * Gets a set of all loaded users.
*
* @return a {@link Set} of {@link User} objects * @return a {@link Set} of {@link User} objects
*/ */
Set<User> getUsers(); Set<User> getUsers();
/** /**
* Check if a user is loaded in memory * Check if a user is loaded in memory
*
* @param uuid the uuid to check for * @param uuid the uuid to check for
* @return true if the user is loaded * @return true if the user is loaded
* @throws NullPointerException if the uuid is null * @throws NullPointerException if the uuid is null
@ -160,6 +175,7 @@ public interface LuckPermsApi {
/** /**
* Unload a user from the internal storage, if they're not currently online. * Unload a user from the internal storage, if they're not currently online.
*
* @param user the user to unload * @param user the user to unload
* @throws NullPointerException if the user is null * @throws NullPointerException if the user is null
* @since 2.6 * @since 2.6
@ -168,6 +184,7 @@ public interface LuckPermsApi {
/** /**
* Gets a wrapped group object from the group storage * Gets a wrapped group object from the group storage
*
* @param name the name of the group to get * @param name the name of the group to get
* @return a {@link Group} object, if one matching the name exists, or null if not * @return a {@link Group} object, if one matching the name exists, or null if not
* @throws NullPointerException if the name is null * @throws NullPointerException if the name is null
@ -176,6 +193,7 @@ public interface LuckPermsApi {
/** /**
* Gets a wrapped group object from the group storage. This method does not return null, unlike {@link #getGroup} * Gets a wrapped group object from the group storage. This method does not return null, unlike {@link #getGroup}
*
* @param name the name of the group to get * @param name the name of the group to get
* @return an optional {@link Group} object * @return an optional {@link Group} object
* @throws NullPointerException if the name is null * @throws NullPointerException if the name is null
@ -184,12 +202,14 @@ public interface LuckPermsApi {
/** /**
* Gets a set of all loaded groups. * Gets a set of all loaded groups.
*
* @return a {@link Set} of {@link Group} objects * @return a {@link Set} of {@link Group} objects
*/ */
Set<Group> getGroups(); Set<Group> getGroups();
/** /**
* Check if a group is loaded in memory * Check if a group is loaded in memory
*
* @param name the name to check for * @param name the name to check for
* @return true if the group is loaded * @return true if the group is loaded
* @throws NullPointerException if the name is null * @throws NullPointerException if the name is null
@ -198,6 +218,7 @@ public interface LuckPermsApi {
/** /**
* Gets a wrapped track object from the track storage * Gets a wrapped track object from the track storage
*
* @param name the name of the track to get * @param name the name of the track to get
* @return a {@link Track} object, if one matching the name exists, or null if not * @return a {@link Track} object, if one matching the name exists, or null if not
* @throws NullPointerException if the name is null * @throws NullPointerException if the name is null
@ -206,6 +227,7 @@ public interface LuckPermsApi {
/** /**
* Gets a wrapped track object from the track storage. This method does not return null, unlike {@link #getTrack} * Gets a wrapped track object from the track storage. This method does not return null, unlike {@link #getTrack}
*
* @param name the name of the track to get * @param name the name of the track to get
* @return an optional {@link Track} object * @return an optional {@link Track} object
* @throws NullPointerException if the name is null * @throws NullPointerException if the name is null
@ -214,12 +236,14 @@ public interface LuckPermsApi {
/** /**
* Gets a set of all loaded tracks. * Gets a set of all loaded tracks.
*
* @return a {@link Set} of {@link Track} objects * @return a {@link Set} of {@link Track} objects
*/ */
Set<Track> getTracks(); Set<Track> getTracks();
/** /**
* Check if a track is loaded in memory * Check if a track is loaded in memory
*
* @param name the name to check for * @param name the name to check for
* @return true if the track is loaded * @return true if the track is loaded
* @throws NullPointerException if the name is null * @throws NullPointerException if the name is null
@ -228,6 +252,7 @@ public interface LuckPermsApi {
/** /**
* Returns a permission builder instance * Returns a permission builder instance
*
* @param permission the main permission node to build * @param permission the main permission node to build
* @return a {@link Node.Builder} instance * @return a {@link Node.Builder} instance
* @throws IllegalArgumentException if the permission is invalid * @throws IllegalArgumentException if the permission is invalid
@ -238,6 +263,7 @@ public interface LuckPermsApi {
/** /**
* Register a custom context calculator to the server * Register a custom context calculator to the server
*
* @param contextCalculator the context calculator to register. The type MUST be the player class of the platform. * @param contextCalculator the context calculator to register. The type MUST be the player class of the platform.
* @throws ClassCastException if the type is not the player class of the platform. * @throws ClassCastException if the type is not the player class of the platform.
*/ */
@ -245,6 +271,7 @@ public interface LuckPermsApi {
/** /**
* Registers a custom context listener to the server, * Registers a custom context listener to the server,
*
* @param contextListener the context listener to register. The type MUST be the player class of the platform. * @param contextListener the context listener to register. The type MUST be the player class of the platform.
* @throws ClassCastException if the type is not the player class of the platform. * @throws ClassCastException if the type is not the player class of the platform.
*/ */
@ -253,6 +280,7 @@ 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. * 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.
*/ */

View File

@ -24,6 +24,7 @@ package me.lucko.luckperms.api;
/** /**
* Exposes any networking provider being used on the platform. e.g. Redis * Exposes any networking provider being used on the platform. e.g. Redis
*
* @since 2.14 * @since 2.14
*/ */
public interface MessagingService { public interface MessagingService {

View File

@ -32,14 +32,14 @@ import java.util.Set;
/** /**
* A collection of utilities to help retrieve meta values for {@link PermissionHolder}s * A collection of utilities to help retrieve meta values for {@link PermissionHolder}s
*
* @since 2.7 * @since 2.7
*/ */
public class MetaUtils { public class MetaUtils {
private MetaUtils(){}
/** /**
* Escapes special characters used within LuckPerms, so the string can be saved without issues * Escapes special characters used within LuckPerms, so the string can be saved without issues
*
* @param s the string to escape * @param s the string to escape
* @return an escaped string * @return an escaped string
* @throws NullPointerException if the string is null * @throws NullPointerException if the string is null
@ -58,6 +58,7 @@ public class MetaUtils {
/** /**
* Unescapes special characters used within LuckPerms, the inverse of {@link #escapeCharacters(String)} * Unescapes special characters used within LuckPerms, the inverse of {@link #escapeCharacters(String)}
*
* @param s the string to unescape * @param s the string to unescape
* @return an unescaped string * @return an unescaped string
* @throws NullPointerException if the string is null * @throws NullPointerException if the string is null
@ -76,6 +77,7 @@ public class MetaUtils {
/** /**
* Sets a meta value on a holder * Sets a meta value on a holder
*
* @param holder the holder to apply the meta node to * @param holder the holder to apply the meta node to
* @param server the server to apply the meta on, can be null * @param server the server to apply the meta on, can be null
* @param world the world to apply the meta on, can be null * @param world the world to apply the meta on, can be null
@ -122,7 +124,8 @@ public class MetaUtils {
for (Node n : toRemove) { for (Node n : toRemove) {
try { try {
holder.unsetPermission(n); holder.unsetPermission(n);
} catch (ObjectLacksException ignored) {} } catch (ObjectLacksException ignored) {
}
} }
Node.Builder metaNode = LuckPerms.getApi().buildNode("meta." + node + "." + value).setValue(true); Node.Builder metaNode = LuckPerms.getApi().buildNode("meta." + node + "." + value).setValue(true);
@ -135,11 +138,13 @@ public class MetaUtils {
try { try {
holder.setPermission(metaNode.build()); holder.setPermission(metaNode.build());
} catch (ObjectAlreadyHasException ignored) {} } catch (ObjectAlreadyHasException ignored) {
}
} }
/** /**
* Gets a meta value for the holder * Gets a meta value for the holder
*
* @param holder the holder to get the meta from * @param holder the holder to get the meta from
* @param server the server to retrieve the meta on, can be null * @param server the server to retrieve the meta on, can be null
* @param world the world to retrieve the meta on, can be null * @param world the world to retrieve the meta on, can be null
@ -217,11 +222,13 @@ public class MetaUtils {
try { try {
holder.setPermission(node.build()); holder.setPermission(node.build());
} catch (ObjectAlreadyHasException ignored) {} } catch (ObjectAlreadyHasException ignored) {
}
} }
/** /**
* Adds a prefix to a holder on a specific server and world * Adds a prefix to a holder on a specific server and world
*
* @param holder the holder to set the prefix for * @param holder the holder to set the prefix for
* @param prefix the prefix value * @param prefix the prefix value
* @param priority the priority to set the prefix at * @param priority the priority to set the prefix at
@ -236,6 +243,7 @@ public class MetaUtils {
/** /**
* Adds a suffix to a holder on a specific server and world * Adds a suffix to a holder on a specific server and world
*
* @param holder the holder to set the suffix for * @param holder the holder to set the suffix for
* @param suffix the suffix value * @param suffix the suffix value
* @param priority the priority to set the suffix at * @param priority the priority to set the suffix at
@ -289,6 +297,7 @@ public class MetaUtils {
/** /**
* Returns a holders highest priority prefix, if they have one * Returns a holders highest priority prefix, if they have one
*
* @param holder the holder * @param holder the holder
* @param server the server to retrieve the prefix on * @param server the server to retrieve the prefix on
* @param world the world to retrieve the prefix on * @param world the world to retrieve the prefix on
@ -302,6 +311,7 @@ public class MetaUtils {
/** /**
* Returns a holders highest priority suffix, if they have one * Returns a holders highest priority suffix, if they have one
*
* @param holder the holder * @param holder the holder
* @param server the server to retrieve the suffix on * @param server the server to retrieve the suffix on
* @param world the world to retrieve the suffix on * @param world the world to retrieve the suffix on
@ -313,4 +323,7 @@ public class MetaUtils {
return getChatMeta(false, holder, server, world, includeGlobal); return getChatMeta(false, holder, server, world, includeGlobal);
} }
private MetaUtils() {
}
} }

View File

@ -24,11 +24,16 @@ package me.lucko.luckperms.api;
import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.ContextSet;
import java.util.*; import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
/** /**
* Represents an immutable node object * Represents an immutable node object
* <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") @SuppressWarnings("unused")
@ -41,6 +46,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Get what value the permission is set to. A negated node would return <code>false</code>. * Get what value the permission is set to. A negated node would return <code>false</code>.
*
* @return the permission's value * @return the permission's value
*/ */
@Override @Override
@ -59,18 +65,21 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* If this node is set to override explicitly. * If this node is set to override explicitly.
* This value does not persist across saves, and is therefore only useful for transient nodes * This value does not persist across saves, and is therefore only useful for transient nodes
*
* @return true if this node is set to override explicitly * @return true if this node is set to override explicitly
*/ */
boolean isOverride(); boolean isOverride();
/** /**
* Gets the server this node applies on, if the node is server specific * Gets the server this node applies on, if the node is server specific
*
* @return an {@link Optional} containing the server, if one is defined * @return an {@link Optional} containing the server, if one is defined
*/ */
Optional<String> getServer(); Optional<String> getServer();
/** /**
* Gets the world this node applies on, if the node is world specific * Gets the world this node applies on, if the node is world specific
*
* @return an {@link Optional} containing the world, if one is defined * @return an {@link Optional} containing the world, if one is defined
*/ */
Optional<String> getWorld(); Optional<String> getWorld();
@ -87,6 +96,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* If this node should apply on a specific server * If this node should apply on a specific server
*
* @param server the name of the server * @param server the name of the server
* @param includeGlobal if global permissions should apply * @param includeGlobal if global permissions should apply
* @param applyRegex if regex should be applied * @param applyRegex if regex should be applied
@ -96,6 +106,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* If this node should apply on a specific world * If this node should apply on a specific world
*
* @param world the name of the world * @param world the name of the world
* @param includeGlobal if global permissions should apply * @param includeGlobal if global permissions should apply
* @param applyRegex if regex should be applied * @param applyRegex if regex should be applied
@ -105,6 +116,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* If this node should apply in the given context * If this node should apply in the given context
*
* @param context the context key value pairs * @param context the context key value pairs
* @param worldAndServer if world and server contexts should be checked * @param worldAndServer if world and server contexts should be checked
* @return true if the node should apply * @return true if the node should apply
@ -114,6 +126,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* If this node should apply in the given context * If this node should apply in the given context
*
* @param context the context key value pairs * @param context the context key value pairs
* @return true if the node should apply * @return true if the node should apply
* @since 2.13 * @since 2.13
@ -122,6 +135,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* If this node should apply in the given context * If this node should apply in the given context
*
* @param context the context key value pairs * @param context the context key value pairs
* @param worldAndServer if world and server contexts should be checked * @param worldAndServer if world and server contexts should be checked
* @return true if the node should apply * @return true if the node should apply
@ -134,6 +148,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* If this node should apply in the given context * If this node should apply in the given context
*
* @param context the context key value pairs * @param context the context key value pairs
* @return true if the node should apply * @return true if the node should apply
* @deprecated in favour of {@link #shouldApplyWithContext(ContextSet)} * @deprecated in favour of {@link #shouldApplyWithContext(ContextSet)}
@ -145,6 +160,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Similar to {@link #shouldApplyOnServer(String, boolean, boolean)}, except this method accepts a List * Similar to {@link #shouldApplyOnServer(String, boolean, boolean)}, except this method accepts a List
*
* @param servers the list of servers * @param servers the list of servers
* @param includeGlobal if global permissions should apply * @param includeGlobal if global permissions should apply
* @return true if the node should apply * @return true if the node should apply
@ -153,6 +169,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Similar to {@link #shouldApplyOnWorld(String, boolean, boolean)}, except this method accepts a List * Similar to {@link #shouldApplyOnWorld(String, boolean, boolean)}, except this method accepts a List
*
* @param worlds the list of world * @param worlds the list of world
* @param includeGlobal if global permissions should apply * @param includeGlobal if global permissions should apply
* @return true if the node should apply * @return true if the node should apply
@ -161,6 +178,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Resolves a list of wildcards that match this node * Resolves a list of wildcards that match this node
*
* @param possibleNodes a list of possible permission nodes * @param possibleNodes a list of possible permission nodes
* @return a list of permissions that match this wildcard * @return a list of permissions that match this wildcard
*/ */
@ -168,6 +186,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Resolves any shorthand parts of this node and returns the full list * Resolves any shorthand parts of this node and returns the full list
*
* @return a list of full nodes * @return a list of full nodes
*/ */
List<String> resolveShorthand(); List<String> resolveShorthand();
@ -225,6 +244,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Converts this node into a serialized form * Converts this node into a serialized form
*
* @return a serialized node string * @return a serialized node string
*/ */
String toSerializedNode(); String toSerializedNode();
@ -247,6 +267,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Gets the level of this wildcard, higher is more specific * Gets the level of this wildcard, higher is more specific
*
* @return the wildcard level * @return the wildcard level
* @throws IllegalStateException if this is not a wildcard * @throws IllegalStateException if this is not a wildcard
*/ */
@ -259,6 +280,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Gets the meta value from this node * Gets the meta value from this node
*
* @return the meta value * @return the meta value
* @throws IllegalStateException if this node is not a meta node * @throws IllegalStateException if this node is not a meta node
*/ */
@ -271,6 +293,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Gets the prefix value from this node * Gets the prefix value from this node
*
* @return the prefix value * @return the prefix value
* @throws IllegalStateException if this node is a not a prefix node * @throws IllegalStateException if this node is a not a prefix node
*/ */
@ -283,6 +306,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Gets the suffix value from this node * Gets the suffix value from this node
*
* @return the suffix value * @return the suffix value
* @throws IllegalStateException if this node is a not a suffix node * @throws IllegalStateException if this node is a not a suffix node
*/ */
@ -290,6 +314,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Checks if this Node is equal to another node * Checks if this Node is equal to another node
*
* @param obj the other node * @param obj the other node
* @return true if this node is equal to the other provided * @return true if this node is equal to the other provided
* @see #equalsIgnoringValue(Node) for a less strict implementation of this method * @see #equalsIgnoringValue(Node) for a less strict implementation of this method
@ -298,6 +323,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Similar to {@link Node#equals(Object)}, except doesn't take note of the value * Similar to {@link Node#equals(Object)}, except doesn't take note of the value
*
* @param other the other node * @param other the other node
* @return true if the two nodes are almost equal * @return true if the two nodes are almost equal
*/ */
@ -305,6 +331,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Similar to {@link Node#equals(Object)}, except doesn't take note of the expiry time or value * Similar to {@link Node#equals(Object)}, except doesn't take note of the expiry time or value
*
* @param other the other node * @param other the other node
* @return true if the two nodes are almost equal * @return true if the two nodes are almost equal
*/ */
@ -312,6 +339,7 @@ public interface Node extends Map.Entry<String, Boolean> {
/** /**
* Similar to {@link Node#equals(Object)}, except doesn't take note of the value or if the node is temporary * Similar to {@link Node#equals(Object)}, except doesn't take note of the value or if the node is temporary
*
* @param other the other node * @param other the other node
* @return true if the two nodes are almost equal * @return true if the two nodes are almost equal
* @since 2.8 * @since 2.8
@ -323,6 +351,7 @@ public interface Node extends Map.Entry<String, Boolean> {
*/ */
interface Builder { interface Builder {
Builder setNegated(boolean negated); Builder setNegated(boolean negated);
Builder setValue(boolean value); Builder setValue(boolean value);
/** /**
@ -332,13 +361,21 @@ public interface Node extends Map.Entry<String, Boolean> {
Builder setOverride(boolean override); Builder setOverride(boolean override);
Builder setExpiry(long expireAt); Builder setExpiry(long expireAt);
Builder setWorld(String world); Builder setWorld(String world);
Builder setServer(String server) throws IllegalArgumentException; Builder setServer(String server) throws IllegalArgumentException;
Builder withExtraContext(String key, String value); Builder withExtraContext(String key, String value);
Builder withExtraContext(Map<String, String> map); Builder withExtraContext(Map<String, String> map);
Builder withExtraContext(Set<Map.Entry<String, String>> context); Builder withExtraContext(Set<Map.Entry<String, String>> context);
Builder withExtraContext(Map.Entry<String, String> entry); Builder withExtraContext(Map.Entry<String, String> entry);
Builder withExtraContext(ContextSet set); Builder withExtraContext(ContextSet set);
Node build(); Node build();
} }

View File

@ -37,13 +37,14 @@ import java.util.SortedSet;
public interface PermissionHolder { public interface PermissionHolder {
/** /**
* @return the identifier for this object. either a uuid string or name * @return the identifier for this object. either a uuid string or name However, you should really just use {@link
* However, you should really just use {@link User#getUuid()}, {@link User#getName()} or {@link Group#getName()} * User#getUuid()}, {@link User#getName()} or {@link Group#getName()}
*/ */
String getObjectName(); String getObjectName();
/** /**
* Gets an immutable Set of the objects permission nodes * Gets an immutable Set of the objects permission nodes
*
* @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,6 +52,7 @@ public interface PermissionHolder {
/** /**
* Similar to {@link #getPermissions()}, except excluding transient permissions * Similar to {@link #getPermissions()}, except excluding transient permissions
*
* @return a set of nodes * @return a set of nodes
* @since 2.6 * @since 2.6
*/ */
@ -58,6 +60,7 @@ public interface PermissionHolder {
/** /**
* Similar to {@link #getPermissions()}, except excluding non-transient permissions * Similar to {@link #getPermissions()}, except excluding non-transient permissions
*
* @return a set of nodes * @return a set of nodes
* @since 2.6 * @since 2.6
*/ */
@ -66,6 +69,7 @@ public interface PermissionHolder {
/** /**
* Gets an immutable set of the nodes that this object has and inherits * Gets an immutable set of the nodes that this object has and inherits
*
* @return an immutable set of permissions * @return an immutable set of permissions
* @since 2.6 * @since 2.6
* @deprecated in favour of {@link #getAllNodes(Contexts)} * @deprecated in favour of {@link #getAllNodes(Contexts)}
@ -78,6 +82,7 @@ public interface PermissionHolder {
* Unlike {@link #getAllNodesFiltered(Contexts)}, this method will not filter individual nodes. The context is only * Unlike {@link #getAllNodesFiltered(Contexts)}, this method will not filter individual nodes. The context is only
* used to determine which groups should apply. * used to determine which groups should apply.
* Nodes are sorted into priority order. * Nodes are sorted into priority order.
*
* @param contexts the context for the lookup, * @param contexts the context for the lookup,
* @return a mutable sorted set of permissions * @return a mutable sorted set of permissions
* @throws NullPointerException if the context is null * @throws NullPointerException if the context is null
@ -89,6 +94,7 @@ public interface PermissionHolder {
* Gets a mutable set of the nodes that is objects has and inherits, filtered by context. * Gets a mutable set of the nodes that is objects 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.
*
* @param contexts the context for the lookup * @param contexts the context for the lookup
* @return a mutable set of permissions * @return a mutable set of permissions
* @throws NullPointerException if the context is null * @throws NullPointerException if the context is null
@ -98,6 +104,7 @@ public interface PermissionHolder {
/** /**
* Gets an immutable Map of the objects permission nodes * Gets an immutable Map of the objects permission nodes
*
* @return an immutable map of permissions * @return an immutable map of permissions
* @deprecated in favour of {@link #getPermissions()} * @deprecated in favour of {@link #getPermissions()}
*/ */
@ -106,6 +113,7 @@ public interface PermissionHolder {
/** /**
* Checks to see if the object has a certain permission * Checks to see if the object has a certain permission
*
* @param node the node to check for * @param node the node to check for
* @return a Tristate for the holders permission status for the node * @return a Tristate for the holders permission status for the node
* @throws NullPointerException if the node is null * @throws NullPointerException if the node is null
@ -115,6 +123,7 @@ public interface PermissionHolder {
/** /**
* Checks to see if the object has a certain permission * Checks to see if the object has a certain permission
*
* @param node the node to check for * @param node the node to check for
* @return a Tristate for the holders permission status for the node * @return a Tristate for the holders permission status for the node
* @throws NullPointerException if the node is null * @throws NullPointerException if the node is null
@ -124,6 +133,7 @@ public interface PermissionHolder {
/** /**
* Checks to see if the object has a certain permission * Checks to see if the object has a certain permission
*
* @param node The permission node * @param node The permission node
* @param b If the node is true/false(negated) * @param b If the node is true/false(negated)
* @return true if the object has the permission * @return true if the object has the permission
@ -134,6 +144,7 @@ public interface PermissionHolder {
/** /**
* Checks to see the the object has a permission on a certain server * Checks to see the the object has a permission on a certain server
*
* @param node The permission node * @param node The permission node
* @param b If the node is true/false(negated) * @param b If the node is true/false(negated)
* @param server The server * @param server The server
@ -145,6 +156,7 @@ public interface PermissionHolder {
/** /**
* Checks to see the the object has a permission on a certain server and world * Checks to see the the object has a permission on a certain server and world
*
* @param node The permission node * @param node The permission node
* @param b If the node is true/false(negated) * @param b If the node is true/false(negated)
* @param server The server * @param server The server
@ -157,6 +169,7 @@ public interface PermissionHolder {
/** /**
* Checks to see the the object has a permission * Checks to see the the object has a permission
*
* @param node The permission node * @param node The permission node
* @param b If the node is true/false(negated) * @param b If the node is true/false(negated)
* @param temporary if the permission is temporary * @param temporary if the permission is temporary
@ -168,6 +181,7 @@ public interface PermissionHolder {
/** /**
* Checks to see the the object has a permission on a certain server * Checks to see the the object has a permission on a certain server
*
* @param node The permission node * @param node The permission node
* @param b If the node is true/false(negated) * @param b If the node is true/false(negated)
* @param server The server to check on * @param server The server to check on
@ -180,6 +194,7 @@ public interface PermissionHolder {
/** /**
* Checks to see the the object has a permission on a certain server and world * Checks to see the the object has a permission on a certain server and world
*
* @param node The permission node * @param node The permission node
* @param b If the node is true/false(negated) * @param b If the node is true/false(negated)
* @param server The server to check on * @param server The server to check on
@ -193,6 +208,7 @@ public interface PermissionHolder {
/** /**
* Cheks to see if the object inherits a certain permission * Cheks to see if the object inherits a certain permission
*
* @param node the node to check for * @param node the node to check for
* @return a Tristate for the holders inheritance status for the node * @return a Tristate for the holders inheritance status for the node
* @throws NullPointerException if the node is null * @throws NullPointerException if the node is null
@ -202,6 +218,7 @@ public interface PermissionHolder {
/** /**
* Checks to see if the object inherits a certain permission * Checks to see if the object inherits a certain permission
*
* @param node The permission node * @param node The permission node
* @param b If the node is true/false(negated) * @param b If the node is true/false(negated)
* @return true if the object inherits the permission * @return true if the object inherits the permission
@ -212,6 +229,7 @@ public interface PermissionHolder {
/** /**
* Checks to see the the object inherits a permission on a certain server * Checks to see the the object inherits a permission on a certain server
*
* @param node The permission node * @param node The permission node
* @param b If the node is true/false(negated) * @param b If the node is true/false(negated)
* @param server The server * @param server The server
@ -223,6 +241,7 @@ public interface PermissionHolder {
/** /**
* Checks to see the the object inherits a permission on a certain server and world * Checks to see the the object inherits a permission on a certain server and world
*
* @param node The permission node * @param node The permission node
* @param b If the node is true/false(negated) * @param b If the node is true/false(negated)
* @param server The server * @param server The server
@ -235,6 +254,7 @@ public interface PermissionHolder {
/** /**
* Checks to see if the object inherits a permission * Checks to see if the object inherits a permission
*
* @param node The permission node * @param node The permission node
* @param b If the node is true/false(negated) * @param b If the node is true/false(negated)
* @param temporary if the permission is temporary * @param temporary if the permission is temporary
@ -246,6 +266,7 @@ public interface PermissionHolder {
/** /**
* Checks to see if the object inherits a permission on a certain server * Checks to see if the object inherits a permission on a certain server
*
* @param node The permission node * @param node The permission node
* @param b If the node is true/false(negated) * @param b If the node is true/false(negated)
* @param server The server * @param server The server
@ -258,6 +279,7 @@ public interface PermissionHolder {
/** /**
* Checks to see if the object inherits a permission on a certain server and world * Checks to see if the object inherits a permission on a certain server and world
*
* @param node The permission node * @param node The permission node
* @param b If the node is true/false(negated) * @param b If the node is true/false(negated)
* @param server The server * @param server The server
@ -271,6 +293,7 @@ public interface PermissionHolder {
/** /**
* Sets a permission for the object * Sets a permission for the object
*
* @param node The node to be set * @param node The node to be set
* @throws ObjectAlreadyHasException if the object already has the permission * @throws ObjectAlreadyHasException if the object already has the permission
* @throws NullPointerException if the node is null * @throws NullPointerException if the node is null
@ -289,6 +312,7 @@ public interface PermissionHolder {
* want it to persist, and have to worry about removing it when they log out. * want it to persist, and have to worry about removing it when they log out.
* *
* <p> For unsetting a transient permission, see {@link #unsetTransientPermission(Node)} * <p> For unsetting a transient permission, see {@link #unsetTransientPermission(Node)}
*
* @param node The node to be set * @param node The node to be set
* @throws ObjectAlreadyHasException if the object already has the permission * @throws ObjectAlreadyHasException if the object already has the permission
* @throws NullPointerException if the node is null * @throws NullPointerException if the node is null
@ -298,6 +322,7 @@ public interface PermissionHolder {
/** /**
* Sets a permission for the object * Sets a permission for the object
*
* @param node The node to be set * @param node The node to be set
* @param value What to set the node to - true/false(negated) * @param value What to set the node to - true/false(negated)
* @throws ObjectAlreadyHasException if the object already has the permission * @throws ObjectAlreadyHasException if the object already has the permission
@ -310,6 +335,7 @@ public interface PermissionHolder {
/** /**
* Sets a permission for the object on a specific server * Sets a permission for the object on a specific server
*
* @param node The node to set * @param node The node to set
* @param value What to set the node to - true/false(negated) * @param value What to set the node to - true/false(negated)
* @param server The server to set the permission on * @param server The server to set the permission on
@ -323,6 +349,7 @@ public interface PermissionHolder {
/** /**
* Sets a permission for the object on a specific server and world * Sets a permission for the object on a specific server and world
*
* @param node The node to set * @param node The node to set
* @param value What to set the node to - true/false(negated) * @param value What to set the node to - true/false(negated)
* @param server The server to set the permission on * @param server The server to set the permission on
@ -337,6 +364,7 @@ public interface PermissionHolder {
/** /**
* Sets a temporary permission for the object * Sets a temporary permission for the object
*
* @param node The node to set * @param node The node to set
* @param value What to set the node to - true/false(negated) * @param value What to set the node to - true/false(negated)
* @param expireAt The time in unixtime when the permission will expire * @param expireAt The time in unixtime when the permission will expire
@ -350,6 +378,7 @@ public interface PermissionHolder {
/** /**
* Sets a temporary permission for the object on a specific server * Sets a temporary permission for the object on a specific server
*
* @param node The node to set * @param node The node to set
* @param value What to set the node to - true/false(negated) * @param value What to set the node to - true/false(negated)
* @param server The server to set the permission on * @param server The server to set the permission on
@ -364,6 +393,7 @@ public interface PermissionHolder {
/** /**
* Sets a temporary permission for the object on a specific server and world * Sets a temporary permission for the object on a specific server and world
*
* @param node The node to set * @param node The node to set
* @param value What to set the node to - true/false(negated) * @param value What to set the node to - true/false(negated)
* @param server The server to set the permission on * @param server The server to set the permission on
@ -379,6 +409,7 @@ public interface PermissionHolder {
/** /**
* Unsets a permission for the object * Unsets a permission for the object
*
* @param node The node to be unset * @param node The node to be unset
* @throws ObjectLacksException if the node wasn't already set * @throws ObjectLacksException if the node wasn't already set
* @throws NullPointerException if the node is null * @throws NullPointerException if the node is null
@ -388,6 +419,7 @@ public interface PermissionHolder {
/** /**
* Unsets a transient permission for the object * Unsets a transient permission for the object
*
* @param node The node to be unset * @param node The node to be unset
* @throws ObjectLacksException if the node wasn't already set * @throws ObjectLacksException if the node wasn't already set
* @throws NullPointerException if the node is null * @throws NullPointerException if the node is null
@ -397,6 +429,7 @@ public interface PermissionHolder {
/** /**
* Unsets a permission for the object * Unsets a permission for the object
*
* @param node The node to be unset * @param node The node to be unset
* @param temporary if the permission being removed is temporary * @param temporary if the permission being removed is temporary
* @throws ObjectLacksException if the node wasn't already set * @throws ObjectLacksException if the node wasn't already set
@ -409,6 +442,7 @@ public interface PermissionHolder {
/** /**
* Unsets a permission for the object * Unsets a permission for the object
*
* @param node The node to be unset * @param node The node to be unset
* @throws ObjectLacksException if the node wasn't already set * @throws ObjectLacksException if the node wasn't already set
* @throws NullPointerException if the node is null * @throws NullPointerException if the node is null
@ -420,6 +454,7 @@ public interface PermissionHolder {
/** /**
* Unsets a permission for the object on a specific server * Unsets a permission for the object on a specific server
*
* @param node The node to be unset * @param node The node to be unset
* @param server The server to unset the node on * @param server The server to unset the node on
* @throws ObjectLacksException if the node wasn't already set * @throws ObjectLacksException if the node wasn't already set
@ -432,6 +467,7 @@ public interface PermissionHolder {
/** /**
* Unsets a permission for the object on a specific server and world * Unsets a permission for the object on a specific server and world
*
* @param node The node to be unset * @param node The node to be unset
* @param server The server to unset the node on * @param server The server to unset the node on
* @param world The world to unset the node on * @param world The world to unset the node on
@ -445,6 +481,7 @@ public interface PermissionHolder {
/** /**
* Unsets a permission for the object on a specific server * Unsets a permission for the object on a specific server
*
* @param node The node to be unset * @param node The node to be unset
* @param server The server to unset the node on * @param server The server to unset the node on
* @param temporary if the permission being unset is temporary * @param temporary if the permission being unset is temporary
@ -458,6 +495,7 @@ public interface PermissionHolder {
/** /**
* Unsets a permission for the object on a specific server and world * Unsets a permission for the object on a specific server and world
*
* @param node The node to be unset * @param node The node to be unset
* @param server The server to unset the node on * @param server The server to unset the node on
* @param world The world to unset the node on * @param world The world to unset the node on
@ -472,6 +510,7 @@ public interface PermissionHolder {
/** /**
* 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
*
* @param server The server to get nodes for * @param server The server to get nodes for
* @param world The world to get nodes for * @param world The world to get nodes for
* @param excludedGroups Groups that shouldn't be inherited (to prevent circular inheritance issues) * @param excludedGroups Groups that shouldn't be inherited (to prevent circular inheritance issues)
@ -484,6 +523,7 @@ public interface PermissionHolder {
/** /**
* 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
*
* @param server The server to get nodes for * @param server The server to get nodes for
* @param world The world to get nodes for * @param world The world to get nodes for
* @param excludedGroups Groups that shouldn't be inherited (to prevent circular inheritance issues) * @param excludedGroups Groups that shouldn't be inherited (to prevent circular inheritance issues)
@ -495,6 +535,7 @@ public interface PermissionHolder {
/** /**
* Gets the permissions and inherited permissions that apply to a specific server * Gets the permissions and inherited permissions that apply to a specific server
*
* @param server The server to get nodes for * @param server The server to get nodes for
* @param excludedGroups Groups that shouldn't be inherited (to prevent circular inheritance issues) * @param excludedGroups Groups that shouldn't be inherited (to prevent circular inheritance issues)
* @param possibleNodes A list of possible permission nodes for wildcard permission handling * @param possibleNodes A list of possible permission nodes for wildcard permission handling
@ -506,6 +547,7 @@ public interface PermissionHolder {
/** /**
* Gets the permissions and inherited permissions that apply to a specific server * Gets the permissions and inherited permissions that apply to a specific server
*
* @param server The server to get nodes for * @param server The server to get nodes for
* @param excludedGroups Groups that shouldn't be inherited (to prevent circular inheritance issues) * @param excludedGroups Groups that shouldn't be inherited (to prevent circular inheritance issues)
* @return a {@link Map} of the permissions * @return a {@link Map} of the permissions
@ -516,6 +558,7 @@ public interface PermissionHolder {
/** /**
* Convert the holders nodes into a Map of permissions to be applied on the platform * Convert the holders nodes into a Map of permissions to be applied on the platform
*
* @param server the server * @param server the server
* @param world the world * @param world the world
* @param extraContext any extra context to filter by * @param extraContext any extra context to filter by
@ -531,6 +574,7 @@ public interface PermissionHolder {
/** /**
* Processes the nodes and returns the temporary ones. * Processes the nodes and returns the temporary ones.
*
* @return a map of temporary nodes * @return a map of temporary nodes
* @deprecated in favour of {@link #getTemporaryPermissionNodes()} * @deprecated in favour of {@link #getTemporaryPermissionNodes()}
*/ */
@ -539,6 +583,7 @@ public interface PermissionHolder {
/** /**
* Processes the nodes and returns the temporary ones. * Processes the nodes and returns the temporary ones.
*
* @return a set of temporary nodes * @return a set of temporary nodes
* @since 2.6 * @since 2.6
*/ */
@ -546,6 +591,7 @@ public interface PermissionHolder {
/** /**
* Processes the nodes and returns the non-temporary ones. * Processes the nodes and returns the non-temporary ones.
*
* @return a map of permanent nodes * @return a map of permanent nodes
* @deprecated in favour of {@link #getPermanentPermissionNodes()} * @deprecated in favour of {@link #getPermanentPermissionNodes()}
*/ */
@ -554,6 +600,7 @@ public interface PermissionHolder {
/** /**
* Processes the nodes and returns the non-temporary ones. * Processes the nodes and returns the non-temporary ones.
*
* @return a set of permanent nodes * @return a set of permanent nodes
* @since 2.6 * @since 2.6
*/ */

View File

@ -24,6 +24,7 @@ package me.lucko.luckperms.api;
/** /**
* Represents the platform type that LuckPerms is running on * Represents the platform type that LuckPerms is running on
*
* @since 2.7 * @since 2.7
*/ */
public enum PlatformType { public enum PlatformType {

View File

@ -31,12 +31,13 @@ import java.util.function.Consumer;
/** /**
* Interface for the internal Storage instance * Interface for the internal Storage instance
* *
* All methods return {@link CompletableFuture}s, which will be populated with the result once the data has been loaded * <p>All methods return {@link CompletableFuture}s, which will be populated with the result once the data has been
* asynchronously. Care should be taken when using the methods to ensure that the main server thread is not blocked. * loaded asynchronously. Care should be taken when using the methods to ensure that the main server thread is not
* blocked.
* *
* Methods such as {@link CompletableFuture#get()} and equivalent should <strong>not</strong> be called on the main server thread. * <p>Methods such as {@link CompletableFuture#get()} and equivalent should <strong>not</strong> be called on the main
* If you need to use the result of these operations on the main server thread, please register a callback using * server thread. If you need to use the result of these operations on the main server thread, please register a
* {@link CompletableFuture#thenAcceptAsync(Consumer, Executor)} and {@link #getSyncExecutor()}. * callback using {@link CompletableFuture#thenAcceptAsync(Consumer, Executor)} and {@link #getSyncExecutor()}.
* *
* @since 2.14 * @since 2.14
*/ */
@ -44,30 +45,36 @@ public interface Storage {
/** /**
* Get the name of the storage implementation. * Get the name of the storage implementation.
*
* @return the name of the implementation * @return the name of the implementation
*/ */
String getName(); String getName();
/** /**
* Return whether the storage instance is allowing logins on the platform. * Return whether the storage instance is allowing logins on the platform.
*
* @return true if logins are enabled * @return true if logins are enabled
*/ */
boolean isAcceptingLogins(); boolean isAcceptingLogins();
/** /**
* Returns an executor which will run all passed runnables on the main server thread. * Returns an executor which will run all passed runnables on the main server thread.
*
* @return an executor instance * @return an executor instance
*/ */
Executor getSyncExecutor(); Executor getSyncExecutor();
/** /**
* Returns an executor which will run all passed runnables asynchronously using the platforms scheduler and thread pools. * Returns an executor which will run all passed runnables asynchronously using the platforms scheduler and thread
* pools.
*
* @return an executor instance * @return an executor instance
*/ */
Executor getAsyncExecutor(); Executor getAsyncExecutor();
/** /**
* Saves an action to storage * Saves an action to storage
*
* @param entry the log entry to be saved * @param entry the log entry to be saved
* @return true if the operation completed successfully. * @return true if the operation completed successfully.
* @throws NullPointerException if entry is null * @throws NullPointerException if entry is null
@ -76,14 +83,17 @@ public interface Storage {
/** /**
* Loads and returns the entire log from storage * Loads and returns the entire log from storage
*
* @return a log instance, could be null if loading failed * @return a log instance, could be null if loading failed
*/ */
CompletableFuture<Log> getLog(); CompletableFuture<Log> getLog();
/** /**
* Loads a user's data from the main storage into the plugins local storage. * Loads a user's data from the main storage into the plugins local storage.
*
* @param uuid the uuid of the user to load * @param uuid the uuid of the user to load
* @param username the users username. (if you want to specify <code>null</code> here, just input "null" as a string.) * @param username the users username. (if you want to specify <code>null</code> here, just input "null" as a
* string.)
* @return if the operation completed successfully * @return if the operation completed successfully
* @throws NullPointerException if uuid or username is null * @throws NullPointerException if uuid or username is null
*/ */
@ -91,6 +101,7 @@ public interface Storage {
/** /**
* Saves a user object back to storage. You should call this after you make any changes to a user. * Saves a user object back to storage. You should call this after you make any changes to a user.
*
* @param user the user to save * @param user the user to save
* @return true if the operation completed successfully. * @return true if the operation completed successfully.
* @throws NullPointerException if user is null * @throws NullPointerException if user is null
@ -100,6 +111,7 @@ public interface Storage {
/** /**
* Removes users from the main storage who are "default". This is called every time the plugin loads. * Removes users from the main storage who are "default". This is called every time the plugin loads.
*
* @return true if the operation completed successfully * @return true if the operation completed successfully
*/ */
CompletableFuture<Boolean> cleanupUsers(); CompletableFuture<Boolean> cleanupUsers();
@ -107,12 +119,14 @@ public interface Storage {
/** /**
* Gets a set all "unique" user UUIDs. * Gets a set all "unique" user UUIDs.
* "Unique" meaning the user isn't just a member of the "default" group. * "Unique" meaning the user isn't just a member of the "default" group.
*
* @return a set of uuids, or null if the operation failed. * @return a set of uuids, or null if the operation failed.
*/ */
CompletableFuture<Set<UUID>> getUniqueUsers(); CompletableFuture<Set<UUID>> getUniqueUsers();
/** /**
* Creates and loads a group into the plugins local storage * Creates and loads a group into the plugins local storage
*
* @param name the name of the group * @param name the name of the group
* @return true if the operation completed successfully * @return true if the operation completed successfully
* @throws NullPointerException if name is null * @throws NullPointerException if name is null
@ -122,6 +136,7 @@ public interface Storage {
/** /**
* Loads a group into the plugins local storage. * Loads a group into the plugins local storage.
*
* @param name the name of the group * @param name the name of the group
* @return true if the operation completed successfully * @return true if the operation completed successfully
* @throws NullPointerException if name is null * @throws NullPointerException if name is null
@ -131,12 +146,14 @@ public interface Storage {
/** /**
* Loads all groups from the storage into memory * Loads all groups from the storage into memory
*
* @return true if the operation completed successfully. * @return true if the operation completed successfully.
*/ */
CompletableFuture<Boolean> loadAllGroups(); CompletableFuture<Boolean> loadAllGroups();
/** /**
* Saves a group back to storage. You should call this after you make any changes to a group. * Saves a group back to storage. You should call this after you make any changes to a group.
*
* @param group the group to save * @param group the group to save
* @return true if the operation completed successfully. * @return true if the operation completed successfully.
* @throws NullPointerException if group is null * @throws NullPointerException if group is null
@ -146,6 +163,7 @@ public interface Storage {
/** /**
* Permanently deletes a group from storage. * Permanently deletes a group from storage.
*
* @param group the group to delete * @param group the group to delete
* @return true if the operation completed successfully. * @return true if the operation completed successfully.
* @throws NullPointerException if group is null * @throws NullPointerException if group is null
@ -155,6 +173,7 @@ public interface Storage {
/** /**
* Creates and loads a track into the plugins local storage * Creates and loads a track into the plugins local storage
*
* @param name the name of the track * @param name the name of the track
* @return true if the operation completed successfully * @return true if the operation completed successfully
* @throws NullPointerException if name is null * @throws NullPointerException if name is null
@ -164,6 +183,7 @@ public interface Storage {
/** /**
* Loads a track into the plugins local storage. * Loads a track into the plugins local storage.
*
* @param name the name of the track * @param name the name of the track
* @return true if the operation completed successfully * @return true if the operation completed successfully
* @throws NullPointerException if name is null * @throws NullPointerException if name is null
@ -173,12 +193,14 @@ public interface Storage {
/** /**
* Loads all tracks from the storage into memory * Loads all tracks from the storage into memory
*
* @return true if the operation completed successfully. * @return true if the operation completed successfully.
*/ */
CompletableFuture<Boolean> loadAllTracks(); CompletableFuture<Boolean> loadAllTracks();
/** /**
* Saves a track back to storage. You should call this after you make any changes to a track. * Saves a track back to storage. You should call this after you make any changes to a track.
*
* @param track the track to save * @param track the track to save
* @return true if the operation completed successfully. * @return true if the operation completed successfully.
* @throws NullPointerException if track is null * @throws NullPointerException if track is null
@ -188,6 +210,7 @@ public interface Storage {
/** /**
* Permanently deletes a track from storage * Permanently deletes a track from storage
*
* @param track the track to delete * @param track the track to delete
* @return true if the operation completed successfully. * @return true if the operation completed successfully.
* @throws NullPointerException if track is null * @throws NullPointerException if track is null
@ -197,6 +220,7 @@ public interface Storage {
/** /**
* Saves UUID caching data to the global cache * Saves UUID caching data to the global cache
*
* @param username the users username * @param username the users username
* @param uuid the users mojang unique id * @param uuid the users mojang unique id
* @return true if the operation completed successfully. * @return true if the operation completed successfully.
@ -207,6 +231,7 @@ public interface Storage {
/** /**
* Gets a UUID from a username * Gets a UUID from a username
*
* @param username the corresponding username * @param username the corresponding username
* @return a uuid object, could be null * @return a uuid object, could be null
* @throws NullPointerException if either parameters are null * @throws NullPointerException if either parameters are null

View File

@ -41,18 +41,21 @@ public interface Track {
/** /**
* 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 * 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
*/ */
List<String> getGroups(); List<String> getGroups();
/** /**
* Gets the number of groups on this track * Gets the number of groups on this track
*
* @return the number of groups on this track * @return the number of groups on this track
*/ */
int getSize(); int getSize();
/** /**
* Gets the next group on the track, after the one provided * Gets the next group on the track, after the one provided
*
* @param current the group before the group being requested * @param current the group before the group being requested
* @return the group name, or null if the end of the track has been reached * @return the group name, or null if the end of the track has been reached
* @throws ObjectLacksException if the track does not contain the group given * @throws ObjectLacksException if the track does not contain the group given
@ -63,6 +66,7 @@ public interface Track {
/** /**
* Gets the previous group on the track, before the one provided * Gets the previous group on the track, before the one provided
*
* @param current the group after the group being requested * @param current the group after the group being requested
* @return the group name, or null if the start of the track has been reached * @return the group name, or null if the start of the track has been reached
* @throws ObjectLacksException if the track does not contain the group given * @throws ObjectLacksException if the track does not contain the group given
@ -73,6 +77,7 @@ public interface Track {
/** /**
* Appends a group to the end of this track * Appends a group to the end of this track
*
* @param group the group to append * @param group the group to append
* @throws ObjectAlreadyHasException if the group is already on this track somewhere * @throws ObjectAlreadyHasException if the group is already on this track somewhere
* @throws NullPointerException if the group is null * @throws NullPointerException if the group is null
@ -82,6 +87,7 @@ public interface Track {
/** /**
* Inserts a group at a certain position on this track * Inserts a group at a certain position on this track
*
* @param group the group to be inserted * @param group the group to be inserted
* @param position the index position (a value of 0 inserts at the start) * @param position the index position (a value of 0 inserts at the start)
* @throws ObjectAlreadyHasException if the group is already on this track somewhere * @throws ObjectAlreadyHasException if the group is already on this track somewhere
@ -93,6 +99,7 @@ public interface Track {
/** /**
* Removes a group from this track * Removes a group from this track
*
* @param group the group to remove * @param group the group to remove
* @throws ObjectLacksException if the group is not on this track * @throws ObjectLacksException if the group is not on this track
* @throws NullPointerException if the group is null * @throws NullPointerException if the group is null
@ -102,6 +109,7 @@ public interface Track {
/** /**
* Removes a group from this track * Removes a group from this track
*
* @param group the group to remove * @param group the group to remove
* @throws ObjectLacksException if the group is not on this track * @throws ObjectLacksException if the group is not on this track
* @throws NullPointerException if the group is null * @throws NullPointerException if the group is null
@ -110,6 +118,7 @@ public interface Track {
/** /**
* Checks if a group features on this track * Checks if a group features on this track
*
* @param group the group to check * @param group the group to check
* @return true if the group is on this track * @return true if the group is on this track
* @throws NullPointerException if the group is null * @throws NullPointerException if the group is null
@ -119,6 +128,7 @@ public interface Track {
/** /**
* Checks if a group features on this track * Checks if a group features on this track
*
* @param group the group to check * @param group the group to check
* @return true if the group is on this track * @return true if the group is on this track
* @throws NullPointerException if the group is null * @throws NullPointerException if the group is null

View File

@ -31,6 +31,10 @@ public enum Tristate {
FALSE(false), FALSE(false),
UNDEFINED(false); UNDEFINED(false);
public static Tristate fromBoolean(boolean b) {
return b ? TRUE : FALSE;
}
private final boolean booleanValue; private final boolean booleanValue;
Tristate(boolean booleanValue) { Tristate(boolean booleanValue) {
@ -40,8 +44,4 @@ public enum Tristate {
public boolean asBoolean() { public boolean asBoolean() {
return booleanValue; return booleanValue;
} }
public static Tristate fromBoolean(boolean b) {
return b ? TRUE : FALSE;
}
} }

View File

@ -48,12 +48,14 @@ public interface User extends PermissionHolder {
/** /**
* Gets the users primary group * Gets the users primary group
*
* @return the users primary group * @return the users primary group
*/ */
String getPrimaryGroup(); String getPrimaryGroup();
/** /**
* Sets a users primary group * Sets a users primary group
*
* @param group the new primary group * @param group the new primary group
* @throws ObjectAlreadyHasException if the user already has this set as their primary group * @throws ObjectAlreadyHasException if the user already has this set as their primary group
* @throws IllegalStateException if the user is not a member of that group * @throws IllegalStateException if the user is not a member of that group
@ -68,6 +70,7 @@ public interface User extends PermissionHolder {
/** /**
* Gets the user's {@link UserData} cache, if they have one setup. * Gets the user's {@link UserData} cache, if they have one setup.
*
* @return an optional, possibly containing the user's cached lookup data. * @return an optional, possibly containing the user's cached lookup data.
* @since 2.13 * @since 2.13
*/ */
@ -75,6 +78,7 @@ public interface User extends PermissionHolder {
/** /**
* Check to see if the user is a member of a group * Check to see if the user is a member of a group
*
* @param group The group to check membership of * @param group The group to check membership of
* @return true if the user is a member of the group * @return true if the user is a member of the group
* @throws NullPointerException if the group is null * @throws NullPointerException if the group is null
@ -83,6 +87,7 @@ public interface User extends PermissionHolder {
/** /**
* Check to see if a user is a member of a group on a specific server * Check to see if a user is a member of a group on a specific server
*
* @param group The group to check membership of * @param group The group to check membership of
* @param server The server to check on * @param server The server to check on
* @return true if the user is a member of the group * @return true if the user is a member of the group
@ -93,6 +98,7 @@ public interface User extends PermissionHolder {
/** /**
* Check to see if a user is a member of a group on a specific server and world * Check to see if a user is a member of a group on a specific server and world
*
* @param group The group to check membership of * @param group The group to check membership of
* @param server The server to check on * @param server The server to check on
* @param world The world to check on * @param world The world to check on
@ -104,6 +110,7 @@ public interface User extends PermissionHolder {
/** /**
* Add a user to a group * Add a user to a group
*
* @param group The group to add the user to * @param group The group to add the user to
* @throws ObjectAlreadyHasException if the user is already a member of the group * @throws ObjectAlreadyHasException if the user is already a member of the group
* @throws NullPointerException if the group is null * @throws NullPointerException if the group is null
@ -113,6 +120,7 @@ public interface User extends PermissionHolder {
/** /**
* Add a user to a group on a specific server * Add a user to a group on a specific server
*
* @param group The group to add the user to * @param group The group to add the user to
* @param server The server to add the group on * @param server The server to add the group on
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server * @throws ObjectAlreadyHasException if the user is already a member of the group on that server
@ -124,6 +132,7 @@ public interface User extends PermissionHolder {
/** /**
* Add a user to a group on a specific server and world * Add a user to a group on a specific server and world
*
* @param group The group to add the user to * @param group The group to add the user to
* @param server The server to add the group on * @param server The server to add the group on
* @param world The world to add the group on * @param world The world to add the group on
@ -136,6 +145,7 @@ public interface User extends PermissionHolder {
/** /**
* Add a user to a group temporarily on a specific server * Add a user to a group temporarily on a specific server
*
* @param group The group to add the user to * @param group The group to add the user to
* @param expireAt when the group should expire * @param expireAt when the group should expire
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server * @throws ObjectAlreadyHasException if the user is already a member of the group on that server
@ -147,6 +157,7 @@ public interface User extends PermissionHolder {
/** /**
* Add a user to a group temporarily on a specific server * Add a user to a group temporarily on a specific server
*
* @param group The group to add the user to * @param group The group to add the user to
* @param server The server to add the group on * @param server The server to add the group on
* @param expireAt when the group should expire * @param expireAt when the group should expire
@ -159,6 +170,7 @@ public interface User extends PermissionHolder {
/** /**
* Add a user to a group temporarily on a specific server and world * Add a user to a group temporarily on a specific server and world
*
* @param group The group to add the user to * @param group The group to add the user to
* @param server The server to add the group on * @param server The server to add the group on
* @param world The world to add the group on * @param world The world to add the group on
@ -172,6 +184,7 @@ public interface User extends PermissionHolder {
/** /**
* Remove the user from a group * Remove the user from a group
*
* @param group the group to remove the user from * @param group the group to remove the user from
* @throws ObjectLacksException if the user isn't a member of the group * @throws ObjectLacksException if the user isn't a member of the group
* @throws NullPointerException if the group is null * @throws NullPointerException if the group is null
@ -181,6 +194,7 @@ public interface User extends PermissionHolder {
/** /**
* Remove the user from a group * Remove the user from a group
*
* @param group the group to remove the user from * @param group the group to remove the user from
* @param temporary if the group being removed is temporary * @param temporary if the group being removed is temporary
* @throws ObjectLacksException if the user isn't a member of the group * @throws ObjectLacksException if the user isn't a member of the group
@ -191,6 +205,7 @@ public interface User extends PermissionHolder {
/** /**
* Remove the user from a group on a specific server * Remove the user from a group on a specific server
*
* @param group The group to remove the user from * @param group The group to remove the user from
* @param server The server to remove the group on * @param server The server to remove the group on
* @throws ObjectLacksException if the user isn't a member of the group * @throws ObjectLacksException if the user isn't a member of the group
@ -202,6 +217,7 @@ public interface User extends PermissionHolder {
/** /**
* Remove the user from a group on a specific server and world * Remove the user from a group on a specific server and world
*
* @param group The group to remove the user from * @param group The group to remove the user from
* @param server The server to remove the group on * @param server The server to remove the group on
* @param world The world to remove the group on * @param world The world to remove the group on
@ -214,6 +230,7 @@ public interface User extends PermissionHolder {
/** /**
* Remove the user from a group on a specific server * Remove the user from a group on a specific server
*
* @param group The group to remove the user from * @param group The group to remove the user from
* @param server The server to remove the group on * @param server The server to remove the group on
* @param temporary if the group being removed is temporary * @param temporary if the group being removed is temporary
@ -226,6 +243,7 @@ public interface User extends PermissionHolder {
/** /**
* Remove the user from a group on a specific server and world * Remove the user from a group on a specific server and world
*
* @param group The group to remove the user from * @param group The group to remove the user from
* @param server The server to remove the group on * @param server The server to remove the group on
* @param world The world to remove the group on * @param world The world to remove the group on
@ -244,12 +262,14 @@ public interface User extends PermissionHolder {
/** /**
* 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
*
* @return a {@link List} of group names * @return a {@link List} of group names
*/ */
List<String> getGroupNames(); List<String> getGroupNames();
/** /**
* Get a {@link List} of the groups the user is a member of on a specific server * Get a {@link List} of the groups the user is a member of on a specific server
*
* @param server the server to check * @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
@ -260,6 +280,7 @@ public interface User extends PermissionHolder {
/** /**
* Get a {@link List} of the groups the user is a member of on a specific server * Get a {@link List} of the groups the user is a member of on a specific server
*
* @param server the server to check * @param server the server to check
* @return a {@link List} of group names * @return a {@link List} of group names
* @throws NullPointerException if the server is null * @throws NullPointerException if the server is null

View File

@ -27,13 +27,13 @@ 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 servers * <p> This UuidCache is a means of allowing users to have the same internal UUID across a network of offline mode
* or mixed offline mode and online mode servers. Platforms running in offline mode generate a random UUID for a user when * servers or mixed offline mode and online mode servers. Platforms running in offline mode generate a random UUID for a
* they first join the server, but this UUID will then not be consistent across the network. LuckPerms will instead check * user when they first join the server, but this UUID will then not be consistent across the network. LuckPerms will
* 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 this cache, * <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
* 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> WARNING: THIS IS ONLY EFFECTIVE FOR ONLINE PLAYERS. USE THE DATASTORE METHODS FOR OFFLINE PLAYERS.
*/ */
@ -42,6 +42,7 @@ public interface UuidCache {
/** /**
* Gets a users internal "LuckPerms" UUID, from the one given by the server. * Gets a users internal "LuckPerms" UUID, from the one given by the server.
*
* @param external the UUID assigned by the server, through Player#getUniqueId or ProxiedPlayer#getUniqueId * @param external the UUID assigned by the server, through Player#getUniqueId or ProxiedPlayer#getUniqueId
* @return the corresponding internal UUID * @return the corresponding internal UUID
*/ */
@ -49,6 +50,7 @@ public interface UuidCache {
/** /**
* Gets a users external, server assigned or Mojang assigned unique id, from the internal one used within LuckPerms. * Gets a users external, server assigned or Mojang assigned unique id, from the internal one used within LuckPerms.
*
* @param internal the UUID used within LuckPerms, through User#getUuid * @param internal the UUID used within LuckPerms, through User#getUuid
* @return the corresponding external UUID * @return the corresponding external UUID
*/ */

View File

@ -27,36 +27,44 @@ import java.util.SortedMap;
/** /**
* Holds cached Meta lookup data for a specific set of contexts * Holds cached Meta lookup data for a specific set of contexts
*
* @since 2.13 * @since 2.13
*/ */
public interface MetaData { public interface MetaData {
/** /**
* Gets an immutable copy of the meta this user has * Gets an immutable copy of the meta this user has
*
* @return an immutable map of meta * @return an immutable map of meta
*/ */
Map<String, String> getMeta(); Map<String, String> getMeta();
/** /**
* Gets an immutable sorted map of all of the prefixes the user has, whereby the first value is the highest priority prefix. * Gets an immutable sorted map of all of the prefixes the user has, whereby the first value is the highest priority
* prefix.
*
* @return a sorted map of prefixes * @return a sorted map of prefixes
*/ */
SortedMap<Integer, String> getPrefixes(); SortedMap<Integer, String> getPrefixes();
/** /**
* Gets an immutable sorted map of all of the suffixes the user has, whereby the first value is the highest priority suffix. * Gets an immutable sorted map of all of the suffixes the user has, whereby the first value is the highest priority
* suffix.
*
* @return a sorted map of suffixes * @return a sorted map of suffixes
*/ */
SortedMap<Integer, String> getSuffixes(); SortedMap<Integer, String> getSuffixes();
/** /**
* Gets the user's highest priority prefix, or null if the user has no prefixes * Gets the user's highest priority prefix, or null if the user has no prefixes
*
* @return a prefix string, or null * @return a prefix string, or null
*/ */
String getPrefix(); String getPrefix();
/** /**
* Gets the user's highest priority suffix, or null if the user has no suffixes * Gets the user's highest priority suffix, or null if the user has no suffixes
*
* @return a suffix string, or null * @return a suffix string, or null
*/ */
String getSuffix(); String getSuffix();

View File

@ -28,12 +28,14 @@ import java.util.Map;
/** /**
* Holds cached Permission lookup data for a specific set of contexts * Holds cached Permission lookup data for a specific set of contexts
*
* @since 2.13 * @since 2.13
*/ */
public interface PermissionData { public interface PermissionData {
/** /**
* Gets a permission value for the given permission node * Gets a permission value for the given permission node
*
* @param permission the permission node * @param permission the permission node
* @return a tristate result * @return a tristate result
* @throws NullPointerException if permission is null * @throws NullPointerException if permission is null
@ -48,6 +50,7 @@ public interface PermissionData {
/** /**
* Gets an immutable copy of the permission map backing the permission calculator * Gets an immutable copy of the permission map backing the permission calculator
*
* @return an immutable set of permissions * @return an immutable set of permissions
*/ */
Map<String, Boolean> getImmutableBacking(); Map<String, Boolean> getImmutableBacking();

View File

@ -28,7 +28,8 @@ import java.util.Set;
/** /**
* Holds cached permission and meta lookup data for a {@link me.lucko.luckperms.api.User}. * Holds cached permission and meta lookup data for a {@link me.lucko.luckperms.api.User}.
* Data is only likely to be available for online users. All calls will account for inheritance, as well as any *
* <p>Data is only likely to be available for online users. All calls will account for inheritance, as well as any
* default data provided by the platform. This calls are heavily cached and are therefore fast. * default data provided by the platform. This calls are heavily cached and are therefore fast.
* *
* @since 2.13 * @since 2.13
@ -38,6 +39,7 @@ 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. * 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
* @throws NullPointerException if contexts is null * @throws NullPointerException if contexts is null
@ -47,6 +49,7 @@ 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. * 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
* @throws NullPointerException if contexts is null * @throws NullPointerException if contexts is null
@ -55,6 +58,7 @@ public interface UserData {
/** /**
* Calculates permission data, bypassing the cache. * Calculates permission data, bypassing the cache.
*
* @param contexts the contexts to get permission data in * @param contexts the contexts to get permission data in
* @return a permission data instance * @return a permission data instance
* @throws NullPointerException if contexts is null * @throws NullPointerException if contexts is null
@ -63,6 +67,7 @@ public interface UserData {
/** /**
* Calculates meta data, bypassing the cache. * Calculates meta data, bypassing the cache.
*
* @param contexts the contexts to get meta data in * @param contexts the contexts to get meta data in
* @return a meta data instance * @return a meta data instance
* @throws NullPointerException if contexts is null * @throws NullPointerException if contexts is null
@ -72,6 +77,7 @@ public interface UserData {
/** /**
* 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. If there is already data cached for the given contexts,
* and if the resultant output is different, the cached value is updated. * 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
*/ */
@ -80,6 +86,7 @@ public interface UserData {
/** /**
* 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. If there is already data cached for the given contexts,
* and if the resultant output is different, the cached value is updated. * 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
*/ */
@ -97,6 +104,7 @@ public interface UserData {
/** /**
* Calls {@link #preCalculate(Contexts)} for the given contexts * Calls {@link #preCalculate(Contexts)} for the given contexts
*
* @param contexts a set of contexts * @param contexts a set of contexts
* @throws NullPointerException if contexts is null * @throws NullPointerException if contexts is null
*/ */
@ -105,6 +113,7 @@ public interface UserData {
/** /**
* 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. If the cache does not contain any data for the
* context, it will be calculated and saved. * 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

@ -28,6 +28,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
/** /**
* A simple implementation of the listener aspects of {@link IContextCalculator} * A simple implementation of the listener aspects of {@link IContextCalculator}
*
* @param <T> the subject type * @param <T> the subject type
*/ */
public abstract class ContextCalculator<T> implements IContextCalculator<T> { public abstract class ContextCalculator<T> implements IContextCalculator<T> {
@ -36,6 +37,7 @@ public abstract class ContextCalculator<T> implements IContextCalculator<T> {
/** /**
* Pushes an update to all registered {@link ContextListener}s. * Pushes an update to all registered {@link ContextListener}s.
* Make sure any changes are applied internally before this method is called. * Make sure any changes are applied internally before this method is called.
*
* @param subject the subject that changed * @param subject the subject that changed
* @param before the context state before the change * @param before the context state before the change
* @param current the context state after the change (now) * @param current the context state after the change (now)

View File

@ -26,12 +26,14 @@ import java.util.Map;
/** /**
* Listens to context changes * Listens to context changes
*
* @param <T> the subject type, Is ALWAYS the player class of the platform. * @param <T> the subject type, Is ALWAYS the player class of the platform.
*/ */
public interface ContextListener<T> { public interface ContextListener<T> {
/** /**
* Called whenever a context changes on the * Called whenever a context changes on the
*
* @param subject the subject that had context changed * @param subject the subject that had context changed
* @param before the context state before the change * @param before the context state before the change
* @param current the context state after the change (now) * @param current the context state after the change (now)

View File

@ -22,135 +22,114 @@
package me.lucko.luckperms.api.context; package me.lucko.luckperms.api.context;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableSet;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
/** /**
* Holds contexts. * Holds contexts.
* All contained contexts are immutable, and unlike {@link MutableContextSet}, contexts cannot be added or removed. * Implementations may be either mutable or immutable.
* *
* @since 2.13 * @since 2.13
*/ */
public class ContextSet { public interface ContextSet {
private static final ContextSet EMPTY = new ContextSet();
/** /**
* Make a singleton ContextSet from a context pair * Make a singleton ImmutableContextSet from a context pair
*
* @param key the key * @param key the key
* @param value the value * @param value the value
* @return a new ContextSet containing one KV pair * @return a new ImmutableContextSet containing one KV pair
* @throws NullPointerException if key or value is null * @throws NullPointerException if key or value is null
*/ */
public static ContextSet singleton(String key, String value) { static ImmutableContextSet singleton(String key, String value) {
if (key == null) { return ImmutableContextSet.singleton(key, value);
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
MutableContextSet set = new MutableContextSet();
set.add(key, value);
return set.immutableCopy();
} }
/** /**
* Creates a ContextSet from an existing map * Creates a ImmutableContextSet from an existing map
*
* @param map the map to copy from * @param map the map to copy from
* @return a new ContextSet representing the pairs from the map * @return a new ImmutableContextSet representing the pairs from the map
* @throws NullPointerException if the map is null * @throws NullPointerException if the map is null
*/ */
public static ContextSet fromMap(Map<String, String> map) { static ImmutableContextSet fromMap(Map<String, String> map) {
if (map == null) { return ImmutableContextSet.fromMap(map);
throw new NullPointerException("map");
}
MutableContextSet set = new MutableContextSet();
set.addAll(map);
return set.immutableCopy();
} }
/** /**
* Creates a ContextSet from an existing iterable of Map Entries * Creates a ImmutableContextSet from an existing iterable of Map Entries
*
* @param iterable the iterable to copy from * @param iterable the iterable to copy from
* @return a new ContextSet representing the pairs in the iterable * @return a new ImmutableContextSet representing the pairs in the iterable
* @throws NullPointerException if the iterable is null * @throws NullPointerException if the iterable is null
*/ */
public static ContextSet fromEntries(Iterable<Map.Entry<String, String>> iterable) { static ImmutableContextSet fromEntries(Iterable<Map.Entry<String, String>> iterable) {
if (iterable == null) { return ImmutableContextSet.fromEntries(iterable);
throw new NullPointerException("iterable");
}
MutableContextSet set = new MutableContextSet();
set.addAll(iterable);
return set.immutableCopy();
} }
/** /**
* Creates a new ContextSet from an existing set. * Creates a ImmutableContextSet from an existing multimap
*
* @param multimap the multimap to copy from
* @return a new ImmutableContextSet representing the pairs in the multimap
* @throws NullPointerException if the multimap is null
* @since 2.16
*/
static ImmutableContextSet fromMultimap(Multimap<String, String> multimap) {
return ImmutableContextSet.fromMultimap(multimap);
}
/**
* Creates a new ImmutableContextSet from an existing set.
* Only really useful for converting between mutable and immutable types. * Only really useful for converting between mutable and immutable types.
*
* @param contextSet the context set to copy from * @param contextSet the context set to copy from
* @return a new ContextSet with the same content and the one provided * @return a new ImmutableContextSet with the same content and the one provided
* @throws NullPointerException if contextSet is null * @throws NullPointerException if contextSet is null
*/ */
public static ContextSet fromSet(ContextSet contextSet) { static ImmutableContextSet fromSet(ContextSet contextSet) {
if (contextSet == null) { return ImmutableContextSet.fromSet(contextSet);
throw new NullPointerException("contextSet");
}
MutableContextSet set = new MutableContextSet();
set.addAll(contextSet.toSet());
return set.immutableCopy();
} }
/** /**
* Creates a new empty ContextSet. * Creates a new empty ImmutableContextSet.
* @return a new ContextSet *
* @return a new ImmutableContextSet
*/ */
public static ContextSet empty() { static ImmutableContextSet empty() {
return EMPTY; return ImmutableContextSet.empty();
}
final Set<Map.Entry<String, String>> contexts;
public ContextSet() {
this.contexts = new HashSet<>();
}
protected ContextSet(Set<Map.Entry<String, String>> contexts) {
this.contexts = contexts;
} }
/** /**
* Check to see if this set is in an immutable form * Check to see if this set is in an immutable form
*
* @return true if the set is immutable * @return true if the set is immutable
*/ */
public boolean isImmutable() { boolean isImmutable();
return true;
}
/** /**
* If the set is mutable, this method will return an immutable copy. Otherwise just returns itself. * If the set is mutable, this method will return an immutable copy. Otherwise just returns itself.
*
* @return an immutable ContextSet * @return an immutable ContextSet
*/ */
public ContextSet makeImmutable() { ImmutableContextSet makeImmutable();
return this;
} /**
* Creates a mutable copy of this set.
*
* @return a mutable ContextSet
* @since 2.16
*/
MutableContextSet mutableCopy();
/** /**
* Converts this ContextSet to an immutable {@link Set} of {@link Map.Entry}s. * Converts this ContextSet to an immutable {@link Set} of {@link Map.Entry}s.
*
* @return an immutable set * @return an immutable set
*/ */
public Set<Map.Entry<String, String>> toSet() { Set<Map.Entry<String, String>> toSet();
synchronized (contexts) {
return ImmutableSet.copyOf(contexts);
}
}
/** /**
* Converts this ContextSet to an immutable {@link Map} * Converts this ContextSet to an immutable {@link Map}
@ -160,153 +139,66 @@ public class ContextSet {
* *
* @return an immutable map * @return an immutable map
*/ */
public Map<String, String> toMap() { Map<String, String> toMap();
synchronized (contexts) {
return ImmutableMap.copyOf(contexts.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); /**
} * Converts this ContextSet to an immutable {@link Multimap}
} *
* @return a multimap
* @since 2.16
*/
Multimap<String, String> toMultimap();
/** /**
* Check if the set contains at least one value for the given key. * Check if the set contains at least one value for the given key.
*
* @param key the key to check for * @param key the key to check for
* @return true if the set contains a value for the key * @return true if the set contains a value for the key
* @throws NullPointerException if the key is null * @throws NullPointerException if the key is null
*/ */
public boolean containsKey(String key) { boolean containsKey(String key);
if (key == null) {
throw new NullPointerException("key");
}
synchronized (contexts) {
for (Map.Entry<String, String> e : contexts) {
if (e.getKey().equalsIgnoreCase(key)) {
return true;
}
}
}
return false;
}
/** /**
* Gets a set of all of the values mapped to the given key * Gets a set of all of the values mapped to the given key
*
* @param key the key to find values for * @param key the key to find values for
* @return a set of values * @return a set of values
* @throws NullPointerException if the key is null * @throws NullPointerException if the key is null
*/ */
public Set<String> getValues(String key) { Set<String> getValues(String key);
if (key == null) {
throw new NullPointerException("key");
}
synchronized (contexts) {
return ImmutableSet.copyOf(contexts.stream()
.filter(e -> e.getKey().equalsIgnoreCase(key))
.map(Map.Entry::getValue)
.collect(Collectors.toSet())
);
}
}
/** /**
* Check if thr set contains a given key mapped to a given value * Check if thr set contains a given key mapped to a given value
*
* @param key the key to look for * @param key the key to look for
* @param value the value to look for (case sensitive) * @param value the value to look for (case sensitive)
* @return true if the set contains the KV pair * @return true if the set contains the KV pair
* @throws NullPointerException if the key or value is null * @throws NullPointerException if the key or value is null
*/ */
public boolean has(String key, String value) { boolean has(String key, String value);
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
synchronized (contexts) {
for (Map.Entry<String, String> e : contexts) {
if (!e.getKey().equalsIgnoreCase(key)) {
continue;
}
if (!e.getValue().equals(value)) {
continue;
}
return true;
}
}
return false;
}
/** /**
* Same as {@link #has(String, String)}, except ignores the case of the value. * Same as {@link #has(String, String)}, except ignores the case of the value.
*
* @param key the key to look for * @param key the key to look for
* @param value the value to look for * @param value the value to look for
* @return true if the set contains the KV pair * @return true if the set contains the KV pair
* @throws NullPointerException if the key or value is null * @throws NullPointerException if the key or value is null
*/ */
public boolean hasIgnoreCase(String key, String value) { boolean hasIgnoreCase(String key, String value);
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
synchronized (contexts) {
for (Map.Entry<String, String> e : contexts) {
if (!e.getKey().equalsIgnoreCase(key)) {
continue;
}
if (!e.getValue().equalsIgnoreCase(value)) {
continue;
}
return true;
}
}
return false;
}
/** /**
* Check if the set is empty * Check if the set is empty
*
* @return true if the set is empty * @return true if the set is empty
*/ */
public boolean isEmpty() { boolean isEmpty();
synchronized (contexts) {
return contexts.isEmpty();
}
}
/** /**
* Gets the number of key-value context pairs in the set * Gets the number of key-value context pairs in the set
*
* @return the size of the set * @return the size of the set
*/ */
public int size() { int size();
synchronized (contexts) {
return contexts.size();
}
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof ContextSet)) return false;
final ContextSet other = (ContextSet) o;
final Object thisContexts = this.contexts;
final Object otherContexts = other.contexts;
return thisContexts == null ? otherContexts == null : thisContexts.equals(otherContexts);
}
@Override
public int hashCode() {
return 59 + (this.contexts == null ? 43 : this.contexts.hashCode());
}
@Override
public String toString() {
return "ContextSet(contexts=" + this.contexts + ")";
}
} }

View File

@ -29,17 +29,19 @@ import java.util.Map;
* Calculates whether contexts are applicable to {@link T} * Calculates whether contexts are applicable to {@link T}
* *
* <p>Somewhat inspired by the system used on Sponge. * <p>Somewhat inspired by the system used on Sponge.
*
* @param <T> the subject type. Is ALWAYS the player class of the platform. * @param <T> the subject type. Is ALWAYS the player class of the platform.
*/ */
public interface IContextCalculator<T> { public interface IContextCalculator<T> {
/** /**
* Gives the subject all of the applicable contexts they meet * Gives the subject all of the applicable contexts they meet
*
* @param subject the subject to add contexts to * @param subject the subject to add contexts to
* @param accumulator a map of contexts to add to * @param accumulator a map of contexts to add to
* @return the map * @return the map
* @deprecated in favour of {@link #giveApplicableContext(Object, MutableContextSet)}. Older implementations of this interface * @deprecated in favour of {@link #giveApplicableContext(Object, MutableContextSet)}. Older implementations of this
* will still work, as the replacement method is given as a default, and falls back to using this method. * interface will still work, as the replacement method is given as a default, and falls back to using this method.
*/ */
@Deprecated @Deprecated
default Map<String, String> giveApplicableContext(T subject, Map<String, String> accumulator) { default Map<String, String> giveApplicableContext(T subject, Map<String, String> accumulator) {
@ -72,6 +74,7 @@ public interface IContextCalculator<T> {
/** /**
* Checks to see if a context is applicable to a subject * Checks to see if a context is applicable to a subject
*
* @param subject the subject to check against * @param subject the subject to check against
* @param context the context to check for * @param context the context to check for
* @return true if met, or false if not. If this calculator does not calculate the given context, return false. * @return true if met, or false if not. If this calculator does not calculate the given context, return false.
@ -80,6 +83,7 @@ public interface IContextCalculator<T> {
/** /**
* Adds a listener to be called whenever a context handled by this calculator changes * Adds a listener to be called whenever a context handled by this calculator changes
*
* @param listener the listener instance * @param listener the listener instance
* @throws NullPointerException if listener is null * @throws NullPointerException if listener is null
*/ */

View File

@ -0,0 +1,254 @@
/*
* 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.context;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* An immutable implementation of {@link ContextSet}.
*
* @since 2.16
*/
public final class ImmutableContextSet implements ContextSet {
private static final ImmutableContextSet EMPTY = new ImmutableContextSet(ImmutableMultimap.of());
/**
* Make a singleton ImmutableContextSet from a context pair
*
* @param key the key
* @param value the value
* @return a new ImmutableContextSet containing one KV pair
* @throws NullPointerException if key or value is null
*/
public static ImmutableContextSet singleton(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
return new ImmutableContextSet(ImmutableMultimap.of(key.toLowerCase(), value));
}
/**
* Creates a ImmutableContextSet from an existing map
*
* @param map the map to copy from
* @return a new ImmutableContextSet representing the pairs from the map
* @throws NullPointerException if the map is null
*/
public static ImmutableContextSet fromMap(Map<String, String> map) {
if (map == null) {
throw new NullPointerException("map");
}
return new ImmutableContextSet(ImmutableMultimap.copyOf(
map.entrySet().stream()
.collect(Collectors.toMap(
e -> e.getKey().toLowerCase(),
Map.Entry::getValue
)).entrySet()
));
}
/**
* Creates a ImmutableContextSet from an existing iterable of Map Entries
*
* @param iterable the iterable to copy from
* @return a new ImmutableContextSet representing the pairs in the iterable
* @throws NullPointerException if the iterable is null
*/
public static ImmutableContextSet fromEntries(Iterable<Map.Entry<String, String>> iterable) {
if (iterable == null) {
throw new NullPointerException("iterable");
}
return MutableContextSet.fromEntries(iterable).makeImmutable();
}
/**
* Creates a ImmutableContextSet from an existing multimap
*
* @param multimap the multimap to copy from
* @return a new ImmutableContextSet representing the pairs in the multimap
* @throws NullPointerException if the multimap is null
*/
public static ImmutableContextSet fromMultimap(Multimap<String, String> multimap) {
if (multimap == null) {
throw new NullPointerException("multimap");
}
return MutableContextSet.fromMultimap(multimap).makeImmutable();
}
/**
* Creates a new ImmutableContextSet from an existing set.
* Only really useful for converting between mutable and immutable types.
*
* @param contextSet the context set to copy from
* @return a new ImmutableContextSet with the same content and the one provided
* @throws NullPointerException if contextSet is null
*/
public static ImmutableContextSet fromSet(ContextSet contextSet) {
return contextSet.makeImmutable();
}
/**
* Creates a new empty ContextSet.
*
* @return a new ContextSet
*/
public static ImmutableContextSet empty() {
return EMPTY;
}
private final Multimap<String, String> map;
ImmutableContextSet(Multimap<String, String> contexts) {
this.map = ImmutableMultimap.copyOf(contexts);
}
@Override
public boolean isImmutable() {
return true;
}
@Override
@Deprecated // This set is already immutable!
public ImmutableContextSet makeImmutable() {
return this;
}
@Override
public MutableContextSet mutableCopy() {
return MutableContextSet.fromSet(this);
}
@Override
public Set<Map.Entry<String, String>> toSet() {
return ImmutableSet.copyOf(map.entries());
}
@Override
public Map<String, String> toMap() {
return ImmutableMap.copyOf(map.entries());
}
@Override
public Multimap<String, String> toMultimap() {
return map;
}
@Override
public boolean containsKey(String key) {
if (key == null) {
throw new NullPointerException("key");
}
return map.containsKey(key);
}
@Override
public Set<String> getValues(String key) {
if (key == null) {
throw new NullPointerException("key");
}
Collection<String> c = map.get(key);
return c != null && !c.isEmpty() ? ImmutableSet.copyOf(c) : ImmutableSet.of();
}
@Override
public boolean has(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
return map.containsEntry(key, value);
}
@Override
public boolean hasIgnoreCase(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
Collection<String> c = map.get(key);
if (c == null || c.isEmpty()) {
return false;
}
for (String val : c) {
if (val.equalsIgnoreCase(value)) {
return true;
}
}
return false;
}
@Override
public boolean isEmpty() {
return map.isEmpty();
}
@Override
public int size() {
return map.size();
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof ContextSet)) return false;
final ContextSet other = (ContextSet) o;
final Multimap<String, String> thisContexts = this.toMultimap();
final Multimap<String, String> otherContexts = other.toMultimap();
return thisContexts == null ? otherContexts == null : thisContexts.equals(otherContexts);
}
@Override
public int hashCode() {
return 59 + (this.map == null ? 43 : this.map.hashCode());
}
@Override
public String toString() {
return "ImmutableContextSet(contexts=" + this.map + ")";
}
}

View File

@ -22,27 +22,39 @@
package me.lucko.luckperms.api.context; package me.lucko.luckperms.api.context;
import com.google.common.collect.Maps; import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import java.util.HashSet; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* Holds contexts * A mutable implementation of {@link ContextSet}.
* All contained contexts are immutable, but contexts can be added or removed from the set.
* *
* @since 2.13 * @since 2.16
*/ */
public class MutableContextSet extends ContextSet { public final class MutableContextSet implements ContextSet {
/** /**
* Make a singleton MutableContextSet from a context pair * Make a singleton MutableContextSet from a context pair
*
* @param key the key * @param key the key
* @param value the value * @param value the value
* @return a new MutableContextSet containing one KV pair * @return a new MutableContextSet containing one KV pair
* @throws NullPointerException if key or value is null * @throws NullPointerException if key or value is null
*/ */
public static MutableContextSet singleton(String key, String value) { public static MutableContextSet singleton(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
MutableContextSet set = new MutableContextSet(); MutableContextSet set = new MutableContextSet();
set.add(key, value); set.add(key, value);
return set; return set;
@ -50,11 +62,16 @@ public class MutableContextSet extends ContextSet {
/** /**
* Creates a MutableContextSet from an existing map * Creates a MutableContextSet from an existing map
*
* @param map the map to copy from * @param map the map to copy from
* @return a new MutableContextSet representing the pairs from the map * @return a new MutableContextSet representing the pairs from the map
* @throws NullPointerException if the map is null * @throws NullPointerException if the map is null
*/ */
public static MutableContextSet fromMap(Map<String, String> map) { public static MutableContextSet fromMap(Map<String, String> map) {
if (map == null) {
throw new NullPointerException("map");
}
MutableContextSet set = new MutableContextSet(); MutableContextSet set = new MutableContextSet();
set.addAll(map); set.addAll(map);
return set; return set;
@ -62,24 +79,49 @@ public class MutableContextSet extends ContextSet {
/** /**
* Creates a MutableContextSet from an existing iterable of Map Entries * Creates a MutableContextSet from an existing iterable of Map Entries
*
* @param iterable the iterable to copy from * @param iterable the iterable to copy from
* @return a new MutableContextSet representing the pairs in the iterable * @return a new MutableContextSet representing the pairs in the iterable
* @throws NullPointerException if the iterable is null * @throws NullPointerException if the iterable is null
*/ */
public static MutableContextSet fromEntries(Iterable<Map.Entry<String, String>> iterable) { public static MutableContextSet fromEntries(Iterable<Map.Entry<String, String>> iterable) {
if (iterable == null) {
throw new NullPointerException("iterable");
}
MutableContextSet set = new MutableContextSet(); MutableContextSet set = new MutableContextSet();
set.addAll(iterable); set.addAll(iterable);
return set; return set;
} }
/**
* Creates a MutableContextSet from an existing multimap
*
* @param multimap the multimap to copy from
* @return a new MutableContextSet representing the pairs in the multimap
* @throws NullPointerException if the multimap is null
*/
public static MutableContextSet fromMultimap(Multimap<String, String> multimap) {
if (multimap == null) {
throw new NullPointerException("multimap");
}
return fromEntries(multimap.entries());
}
/** /**
* Creates a new MutableContextSet from an existing set. * Creates a new MutableContextSet from an existing set.
* Only really useful for converting between mutable and immutable types. * Only really useful for converting between mutable and immutable types.
*
* @param contextSet the context set to copy from * @param contextSet the context set to copy from
* @return a new MutableContextSet with the same content and the one provided * @return a new MutableContextSet with the same content and the one provided
* @throws NullPointerException if contextSet is null * @throws NullPointerException if contextSet is null
*/ */
public static MutableContextSet fromSet(ContextSet contextSet) { public static MutableContextSet fromSet(ContextSet contextSet) {
if (contextSet == null) {
throw new NullPointerException("contextSet");
}
MutableContextSet set = new MutableContextSet(); MutableContextSet set = new MutableContextSet();
set.addAll(contextSet.toSet()); set.addAll(contextSet.toSet());
return set; return set;
@ -87,34 +129,119 @@ public class MutableContextSet extends ContextSet {
/** /**
* Creates a new empty MutableContextSet. * Creates a new empty MutableContextSet.
*
* @return a new MutableContextSet * @return a new MutableContextSet
*/ */
public static MutableContextSet empty() { public static MutableContextSet create() {
return new MutableContextSet(); return new MutableContextSet();
} }
private final Multimap<String, String> map;
public MutableContextSet() {
this.map = Multimaps.synchronizedMultimap(HashMultimap.create());
}
private MutableContextSet(Multimap<String, String> contexts) {
this.map = Multimaps.synchronizedMultimap(HashMultimap.create(contexts));
}
@Override @Override
public boolean isImmutable() { public boolean isImmutable() {
return false; return false;
} }
@Override @Override
public ContextSet makeImmutable() { public ImmutableContextSet makeImmutable() {
return immutableCopy(); return new ImmutableContextSet(map);
} }
/** @Override
* Returns an immutable copy of this set. public MutableContextSet mutableCopy() {
* @return an immutable copy of this set return new MutableContextSet(map);
*/
public ContextSet immutableCopy() {
synchronized (contexts) {
return new ContextSet(new HashSet<>(contexts));
} }
@Override
public Set<Map.Entry<String, String>> toSet() {
return ImmutableSet.copyOf(map.entries());
}
@Override
public Map<String, String> toMap() {
return ImmutableMap.copyOf(map.entries());
}
@Override
public Multimap<String, String> toMultimap() {
return map;
}
@Override
public boolean containsKey(String key) {
if (key == null) {
throw new NullPointerException("key");
}
return map.containsKey(key);
}
@Override
public Set<String> getValues(String key) {
if (key == null) {
throw new NullPointerException("key");
}
Collection<String> c = map.get(key);
return c != null && !c.isEmpty() ? ImmutableSet.copyOf(c) : ImmutableSet.of();
}
@Override
public boolean has(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
return map.containsEntry(key, value);
}
@Override
public boolean hasIgnoreCase(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
Collection<String> c = map.get(key);
if (c == null || c.isEmpty()) {
return false;
}
for (String val : c) {
if (val.equalsIgnoreCase(value)) {
return true;
}
}
return false;
}
@Override
public boolean isEmpty() {
return map.isEmpty();
}
@Override
public int size() {
return map.size();
} }
/** /**
* Adds a new key value pair to the set * Adds a new key value pair to the set
*
* @param key the key to add * @param key the key to add
* @param value the value to add * @param value the value to add
* @throws NullPointerException if the key or value is null * @throws NullPointerException if the key or value is null
@ -127,13 +254,12 @@ public class MutableContextSet extends ContextSet {
throw new NullPointerException("value"); throw new NullPointerException("value");
} }
synchronized (contexts) { map.put(key.toLowerCase(), value);
contexts.add(Maps.immutableEntry(key, value));
}
} }
/** /**
* Adds a new key value pair to the set * Adds a new key value pair to the set
*
* @param entry the entry to add * @param entry the entry to add
* @throws NullPointerException if the entry is null * @throws NullPointerException if the entry is null
*/ */
@ -142,13 +268,12 @@ public class MutableContextSet extends ContextSet {
throw new NullPointerException("context"); throw new NullPointerException("context");
} }
synchronized (contexts) { map.put(entry.getKey().toLowerCase(), entry.getValue());
contexts.add(Maps.immutableEntry(entry.getKey(), entry.getValue()));
}
} }
/** /**
* Adds an iterable containing contexts to the set * Adds an iterable containing contexts to the set
*
* @param iterable an iterable of key value context pairs * @param iterable an iterable of key value context pairs
* @throws NullPointerException if iterable is null * @throws NullPointerException if iterable is null
*/ */
@ -157,15 +282,14 @@ public class MutableContextSet extends ContextSet {
throw new NullPointerException("contexts"); throw new NullPointerException("contexts");
} }
synchronized (this.contexts) {
for (Map.Entry<String, String> e : iterable) { for (Map.Entry<String, String> e : iterable) {
this.contexts.add(Maps.immutableEntry(e.getKey(), e.getValue())); this.map.put(e.getKey().toLowerCase(), e.getValue());
}
} }
} }
/** /**
* Adds the entry set of a map to the set * Adds the entry set of a map to the set
*
* @param map the map to add from * @param map the map to add from
* @throws NullPointerException if the map is null * @throws NullPointerException if the map is null
*/ */
@ -178,6 +302,7 @@ public class MutableContextSet extends ContextSet {
/** /**
* Adds of of the values in another ContextSet to this set * Adds of of the values in another ContextSet to this set
*
* @param contextSet the set to add from * @param contextSet the set to add from
* @throws NullPointerException if the contextSet is null * @throws NullPointerException if the contextSet is null
*/ */
@ -186,13 +311,12 @@ public class MutableContextSet extends ContextSet {
throw new NullPointerException("contextSet"); throw new NullPointerException("contextSet");
} }
synchronized (this.contexts) { this.map.putAll(contextSet.toMultimap());
this.contexts.addAll(contextSet.toSet());
}
} }
/** /**
* Remove a key value pair from this set * Remove a key value pair from this set
*
* @param key the key to remove * @param key the key to remove
* @param value the value to remove (case sensitive) * @param value the value to remove (case sensitive)
* @throws NullPointerException if the key or value is null * @throws NullPointerException if the key or value is null
@ -205,13 +329,12 @@ public class MutableContextSet extends ContextSet {
throw new NullPointerException("value"); throw new NullPointerException("value");
} }
synchronized (contexts) { map.entries().removeIf(entry -> entry.getKey().equalsIgnoreCase(key) && entry.getValue().equals(value));
contexts.removeIf(e -> e.getKey().equalsIgnoreCase(key) && e.getValue().equals(value));
}
} }
/** /**
* Same as {@link #remove(String, String)}, except ignores the case of the value * Same as {@link #remove(String, String)}, except ignores the case of the value
*
* @param key the key to remove * @param key the key to remove
* @param value the value to remove * @param value the value to remove
* @throws NullPointerException if the key or value is null * @throws NullPointerException if the key or value is null
@ -224,13 +347,12 @@ public class MutableContextSet extends ContextSet {
throw new NullPointerException("value"); throw new NullPointerException("value");
} }
synchronized (contexts) { map.entries().removeIf(e -> e.getKey().equalsIgnoreCase(key) && e.getValue().equalsIgnoreCase(value));
contexts.removeIf(e -> e.getKey().equalsIgnoreCase(key) && e.getValue().equalsIgnoreCase(value));
}
} }
/** /**
* Removes all pairs with the given key * Removes all pairs with the given key
*
* @param key the key to remove * @param key the key to remove
* @throws NullPointerException if the key is null * @throws NullPointerException if the key is null
*/ */
@ -239,18 +361,14 @@ public class MutableContextSet extends ContextSet {
throw new NullPointerException("key"); throw new NullPointerException("key");
} }
synchronized (contexts) { map.removeAll(key.toLowerCase());
contexts.removeIf(e -> e.getKey().equalsIgnoreCase(key));
}
} }
/** /**
* Clears the set * Clears the set
*/ */
public void clear() { public void clear() {
synchronized (contexts) { map.clear();
contexts.clear();
}
} }
@Override @Override
@ -259,14 +377,18 @@ public class MutableContextSet extends ContextSet {
if (!(o instanceof ContextSet)) return false; if (!(o instanceof ContextSet)) return false;
final ContextSet other = (ContextSet) o; final ContextSet other = (ContextSet) o;
final Object thisContexts = this.contexts; final Multimap<String, String> thisContexts = this.toMultimap();
final Object otherContexts = other.contexts; final Multimap<String, String> otherContexts = other.toMultimap();
return thisContexts == null ? otherContexts == null : thisContexts.equals(otherContexts); return thisContexts == null ? otherContexts == null : thisContexts.equals(otherContexts);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return 59 + (this.contexts == null ? 43 : this.contexts.hashCode()); return 59 + (this.map == null ? 43 : this.map.hashCode());
} }
@Override
public String toString() {
return "MutableContextSet(contexts=" + this.map + ")";
}
} }

View File

@ -27,20 +27,16 @@ import java.util.function.Consumer;
/** /**
* A callback used to wait for the completion of asynchronous operations. * A callback used to wait for the completion of asynchronous operations.
* All callbacks are ran on the main server thread. * All callbacks are ran on the main server thread.
*
* @param <T> the return type * @param <T> the return type
* @deprecated in favour of {@link Consumer} * @deprecated in favour of {@link Consumer}
*/ */
@Deprecated @Deprecated
public interface Callback<T> { public interface Callback<T> {
/**
* Called when the operation completes.
* @param t the return value, may be null
*/
void onComplete(T t);
static <T> Callback<T> empty() { static <T> Callback<T> empty() {
return t -> {}; return t -> {
};
} }
static <T> Callback<T> of(Runnable runnable) { static <T> Callback<T> of(Runnable runnable) {
@ -58,7 +54,9 @@ public interface Callback<T> {
} }
/** /**
* Helper method for converting old {@link Callback}s to use the new {@link me.lucko.luckperms.api.Storage} interface. * Helper method for converting old {@link Callback}s to use the new {@link me.lucko.luckperms.api.Storage}
* interface.
*
* @param callback the callback to convert * @param callback the callback to convert
* @param <T> the return type * @param <T> the return type
* @return a consumer instance * @return a consumer instance
@ -70,4 +68,11 @@ public interface Callback<T> {
return callback::onComplete; return callback::onComplete;
} }
/**
* Called when the operation completes.
*
* @param t the return value, may be null
*/
void onComplete(T t);
} }

View File

@ -30,8 +30,11 @@ package me.lucko.luckperms.api.data;
public interface DatastoreConfiguration extends MySQLConfiguration { public interface DatastoreConfiguration extends MySQLConfiguration {
String getAddress(); String getAddress();
String getDatabase(); String getDatabase();
String getUsername(); String getUsername();
String getPassword(); String getPassword();
} }

View File

@ -29,7 +29,10 @@ package me.lucko.luckperms.api.data;
public interface MySQLConfiguration { public interface MySQLConfiguration {
String getAddress(); String getAddress();
String getDatabase(); String getDatabase();
String getUsername(); String getUsername();
String getPassword(); String getPassword();
} }

View File

@ -29,15 +29,14 @@ import me.lucko.luckperms.api.LuckPermsApi;
*/ */
public abstract class LPEvent { public abstract class LPEvent {
/**
* A link to the API instance provided for convenience.
*/
private LuckPermsApi api = null;
/** /**
* A friendly name of the event * A friendly name of the event
*/ */
private final String eventName; private final String eventName;
/**
* A link to the API instance provided for convenience.
*/
private LuckPermsApi api = null;
protected LPEvent(String eventName) { protected LPEvent(String eventName) {
this.eventName = eventName; this.eventName = eventName;

View File

@ -24,6 +24,7 @@ package me.lucko.luckperms.api.event;
/** /**
* Represents an event acting upon a target * Represents an event acting upon a target
*
* @param <T> the target type * @param <T> the target type
*/ */
public class TargetedEvent<T> extends LPEvent { public class TargetedEvent<T> extends LPEvent {

View File

@ -27,6 +27,7 @@ import me.lucko.luckperms.api.event.TargetedEvent;
/** /**
* Called when a permission expires for an object. * Called when a permission expires for an object.
*
* @deprecated in favour of {@link PermissionNodeExpireEvent} * @deprecated in favour of {@link PermissionNodeExpireEvent}
*/ */
@Deprecated @Deprecated

View File

@ -28,6 +28,7 @@ import me.lucko.luckperms.api.event.AbstractPermissionEvent;
/** /**
* Called when a temporary permission node expires * Called when a temporary permission node expires
*
* @since 2.6 * @since 2.6
*/ */
public class PermissionNodeExpireEvent extends AbstractPermissionEvent { public class PermissionNodeExpireEvent extends AbstractPermissionEvent {

View File

@ -28,6 +28,7 @@ import me.lucko.luckperms.api.event.AbstractPermissionEvent;
/** /**
* Called when a permission node is set on a holder * Called when a permission node is set on a holder
*
* @since 2.6 * @since 2.6
*/ */
public class PermissionNodeSetEvent extends AbstractPermissionEvent { public class PermissionNodeSetEvent extends AbstractPermissionEvent {

View File

@ -28,6 +28,7 @@ import me.lucko.luckperms.api.event.AbstractPermissionEvent;
/** /**
* Called when a permission node is unset from a holder * Called when a permission node is unset from a holder
*
* @since 2.6 * @since 2.6
*/ */
public class PermissionNodeUnsetEvent extends AbstractPermissionEvent { public class PermissionNodeUnsetEvent extends AbstractPermissionEvent {

View File

@ -30,6 +30,7 @@ import java.util.Map;
/** /**
* Called whenever a user or group has a permission set. * Called whenever a user or group has a permission set.
*
* @deprecated in favour of {@link PermissionNodeSetEvent} * @deprecated in favour of {@link PermissionNodeSetEvent}
*/ */
@Deprecated @Deprecated

View File

@ -27,6 +27,7 @@ import me.lucko.luckperms.api.event.AbstractPermissionRemoveEvent;
/** /**
* Called whenever a user or group has a permission unset. * Called whenever a user or group has a permission unset.
*
* @deprecated in favour of {@link PermissionNodeUnsetEvent} * @deprecated in favour of {@link PermissionNodeUnsetEvent}
*/ */
@Deprecated @Deprecated

View File

@ -27,11 +27,11 @@ import me.lucko.luckperms.api.event.LPEvent;
import java.util.UUID; import java.util.UUID;
/** /**
* Called when the user logs into the network for the first time. * Called when the user logs into the network for the first time. Particularly useful for networks with multiple
* Particularly useful for networks with multiple lobbies, who want to welcome a user when they join for the first time. * lobbies, who want to welcome a user when they join for the first time.
* *
* <p>This event is fired before the player has actually joined the game on the async login / auth event. * <p>This event is fired before the player has actually joined the game on the async login / auth event. If you want to
* If you want to do something with the user, store the UUID in a set, and then check the set in the PlayerJoinEvent o.e. * do something with the user, store the UUID in a set, and then check the set in the PlayerJoinEvent o.e.
*/ */
public class UserFirstLoginEvent extends LPEvent { public class UserFirstLoginEvent extends LPEvent {

View File

@ -26,8 +26,8 @@ import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.event.UserEvent; import me.lucko.luckperms.api.event.UserEvent;
/** /**
* Called after a user has their permissions refreshed. * Called after a user has their permissions refreshed. If you cache user permissions within your own plugin, it's a
* If you cache user permissions within your own plugin, it's a good idea to update said cache whenever this event is called. * good idea to update said cache whenever this event is called.
*/ */
public class UserPermissionRefreshEvent extends UserEvent { public class UserPermissionRefreshEvent extends UserEvent {

View File

@ -23,7 +23,9 @@
package me.lucko.luckperms.exceptions; package me.lucko.luckperms.exceptions;
/** /**
* Thrown when a permission holding object doesn't / already has a permission or isn't / is already is a member of a group * Thrown when a permission holding object doesn't / already has a permission or isn't / is already is a member of a
* group
*
* @since 2.7 * @since 2.7
*/ */
public abstract class MembershipException extends Exception { public abstract class MembershipException extends Exception {

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.15-SNAPSHOT</version> <version>2.16-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.15-SNAPSHOT</version> <version>2.16-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -25,9 +25,14 @@ package me.lucko.luckperms.api.placeholders;
import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.util.TimeUtil; import me.clip.placeholderapi.util.TimeUtil;
import me.lucko.luckperms.api.*; import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.LuckPermsApi;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.caching.UserData; import me.lucko.luckperms.api.caching.UserData;
import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.context.MutableContextSet;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -56,6 +61,10 @@ public class LuckPermsPlaceholderExpansion extends PlaceholderExpansion {
private static final String PLUGIN_NAME = "LuckPerms"; private static final String PLUGIN_NAME = "LuckPerms";
private static final String AUTHOR = "Luck"; private static final String AUTHOR = "Luck";
private static String formatBoolean(boolean b) {
return b ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
}
private LuckPermsApi api = null; private LuckPermsApi api = null;
@Override @Override
@ -208,8 +217,4 @@ public class LuckPermsPlaceholderExpansion extends PlaceholderExpansion {
public String getAuthor() { public String getAuthor() {
return AUTHOR; return AUTHOR;
} }
private static String formatBoolean(boolean b) {
return b ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
}
} }

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.15-SNAPSHOT</version> <version>2.16-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -22,8 +22,10 @@
package me.lucko.luckperms.bukkit; package me.lucko.luckperms.bukkit;
import com.google.common.collect.ImmutableList;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import com.google.common.collect.ImmutableList;
import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.bukkit.calculators.AttachmentProcessor; import me.lucko.luckperms.bukkit.calculators.AttachmentProcessor;
import me.lucko.luckperms.bukkit.calculators.ChildProcessor; import me.lucko.luckperms.bukkit.calculators.ChildProcessor;

View File

@ -24,9 +24,11 @@ package me.lucko.luckperms.bukkit;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import me.lucko.luckperms.common.commands.CommandManager; import me.lucko.luckperms.common.commands.CommandManager;
import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.constants.Patterns; import me.lucko.luckperms.common.constants.Patterns;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -23,6 +23,7 @@
package me.lucko.luckperms.bukkit; package me.lucko.luckperms.bukkit;
import me.lucko.luckperms.common.config.AbstractConfiguration; import me.lucko.luckperms.common.config.AbstractConfiguration;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;

View File

@ -27,6 +27,7 @@ import me.lucko.luckperms.bukkit.model.LPPermissible;
import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.utils.AbstractListener; import me.lucko.luckperms.common.utils.AbstractListener;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;

View File

@ -25,6 +25,7 @@ package me.lucko.luckperms.bukkit;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.commands.sender.SenderFactory; import me.lucko.luckperms.common.commands.sender.SenderFactory;
import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.constants.Constants;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -22,8 +22,10 @@
package me.lucko.luckperms.bukkit; package me.lucko.luckperms.bukkit;
import com.google.common.collect.ImmutableMap;
import lombok.Getter; import lombok.Getter;
import com.google.common.collect.ImmutableMap;
import me.lucko.luckperms.ApiHandler; import me.lucko.luckperms.ApiHandler;
import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.Logger; import me.lucko.luckperms.api.Logger;
@ -58,7 +60,12 @@ import me.lucko.luckperms.common.storage.Storage;
import me.lucko.luckperms.common.storage.StorageFactory; import me.lucko.luckperms.common.storage.StorageFactory;
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask; import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
import me.lucko.luckperms.common.tasks.UpdateTask; import me.lucko.luckperms.common.tasks.UpdateTask;
import me.lucko.luckperms.common.utils.*; import me.lucko.luckperms.common.utils.BufferedRequest;
import me.lucko.luckperms.common.utils.DebugHandler;
import me.lucko.luckperms.common.utils.LocaleManager;
import me.lucko.luckperms.common.utils.LogFactory;
import me.lucko.luckperms.common.utils.PermissionCache;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -68,7 +75,13 @@ import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.io.File; import java.io.File;
import java.util.*; import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -76,11 +89,10 @@ import java.util.stream.Collectors;
@Getter @Getter
public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin { public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
private final Set<UUID> ignoringLogs = ConcurrentHashMap.newKeySet();
private Executor syncExecutor; private Executor syncExecutor;
private Executor asyncExecutor; private Executor asyncExecutor;
private VaultHook vaultHook = null; private VaultHook vaultHook = null;
private final Set<UUID> ignoringLogs = ConcurrentHashMap.newKeySet();
private LPConfiguration configuration; private LPConfiguration configuration;
private UserManager userManager; private UserManager userManager;
private GroupManager groupManager; private GroupManager groupManager;
@ -392,7 +404,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
c.addAll(getServer().getWorlds().stream() c.addAll(getServer().getWorlds().stream()
.map(World::getName) .map(World::getName)
.map(s -> { .map(s -> {
MutableContextSet set = new MutableContextSet(); MutableContextSet set = MutableContextSet.create();
set.add("server", getConfiguration().getServer()); set.add("server", getConfiguration().getServer());
set.add("world", s); set.add("world", s);
return set.makeImmutable(); return set.makeImmutable();
@ -406,7 +418,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
c.addAll(getServer().getWorlds().stream() c.addAll(getServer().getWorlds().stream()
.map(World::getName) .map(World::getName)
.map(s -> { .map(s -> {
MutableContextSet set = new MutableContextSet(); MutableContextSet set = MutableContextSet.create();
set.add("server", getConfiguration().getVaultServer()); set.add("server", getConfiguration().getVaultServer());
set.add("world", s); set.add("world", s);
return set.makeImmutable(); return set.makeImmutable();

View File

@ -22,12 +22,15 @@
package me.lucko.luckperms.bukkit; package me.lucko.luckperms.bukkit;
import com.google.common.collect.Maps;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import com.google.common.collect.Maps;
import me.lucko.luckperms.api.context.ContextCalculator; import me.lucko.luckperms.api.context.ContextCalculator;
import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.context.MutableContextSet;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;

View File

@ -24,8 +24,10 @@ package me.lucko.luckperms.bukkit.calculators;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.common.calculators.PermissionProcessor; import me.lucko.luckperms.common.calculators.PermissionProcessor;
import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.permissions.PermissionAttachmentInfo;
import java.util.Map; import java.util.Map;

View File

@ -25,6 +25,7 @@ package me.lucko.luckperms.bukkit.calculators;
import me.lucko.luckperms.api.context.ContextListener; import me.lucko.luckperms.api.context.ContextListener;
import me.lucko.luckperms.bukkit.inject.Injector; import me.lucko.luckperms.bukkit.inject.Injector;
import me.lucko.luckperms.bukkit.model.LPPermissible; import me.lucko.luckperms.bukkit.model.LPPermissible;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Map; import java.util.Map;

View File

@ -23,6 +23,7 @@
package me.lucko.luckperms.bukkit.calculators; package me.lucko.luckperms.bukkit.calculators;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.bukkit.model.ChildPermissionProvider; import me.lucko.luckperms.bukkit.model.ChildPermissionProvider;
import me.lucko.luckperms.common.calculators.PermissionProcessor; import me.lucko.luckperms.common.calculators.PermissionProcessor;

View File

@ -23,9 +23,11 @@
package me.lucko.luckperms.bukkit.calculators; package me.lucko.luckperms.bukkit.calculators;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.bukkit.model.DefaultsProvider; import me.lucko.luckperms.bukkit.model.DefaultsProvider;
import me.lucko.luckperms.common.calculators.PermissionProcessor; import me.lucko.luckperms.common.calculators.PermissionProcessor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;

View File

@ -23,7 +23,9 @@
package me.lucko.luckperms.bukkit.inject; package me.lucko.luckperms.bukkit.inject;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import me.lucko.luckperms.bukkit.model.LPPermissible; import me.lucko.luckperms.bukkit.model.LPPermissible;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permissible;

View File

@ -22,7 +22,13 @@
package me.lucko.luckperms.bukkit.migration; package me.lucko.luckperms.bukkit.migration;
import de.bananaco.bpermissions.api.*; import de.bananaco.bpermissions.api.Calculable;
import de.bananaco.bpermissions.api.CalculableType;
import de.bananaco.bpermissions.api.Group;
import de.bananaco.bpermissions.api.Permission;
import de.bananaco.bpermissions.api.World;
import de.bananaco.bpermissions.api.WorldManager;
import me.lucko.luckperms.api.Logger; import me.lucko.luckperms.api.Logger;
import me.lucko.luckperms.api.MetaUtils; import me.lucko.luckperms.api.MetaUtils;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
@ -39,7 +45,11 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import static me.lucko.luckperms.common.constants.Permission.MIGRATION; import static me.lucko.luckperms.common.constants.Permission.MIGRATION;
@ -83,6 +93,84 @@ public class MigrationBPermissions extends SubCommand<Object> {
} }
} }
private static void migrateHolder(LuckPermsPlugin plugin, World world, Calculable c, PermissionHolder holder) {
// Migrate the groups permissions in this world
for (Permission p : c.getPermissions()) {
try {
holder.setPermission(p.name(), p.isTrue(), "global", world.getName());
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("set " + p.name() + " " + p.isTrue() + " global " + world.getName())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
// Include any child permissions
for (Map.Entry<String, Boolean> child : p.getChildren().entrySet()) {
try {
holder.setPermission(child.getKey(), child.getValue(), "global", world.getName());
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("set " + child.getKey() + " " + child.getValue() + " global " + world.getName())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
// Migrate any inherited groups
for (Group parent : c.getGroups()) {
try {
holder.setPermission("group." + parent.getName(), true, "global", world.getName());
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("setinherit " + parent.getName() + " global " + world.getName())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
// Migrate existing meta
for (Map.Entry<String, String> meta : c.getMeta().entrySet()) {
if (meta.getKey().equalsIgnoreCase("prefix") || meta.getKey().equalsIgnoreCase("suffix")) {
String chatMeta = MetaUtils.escapeCharacters(meta.getValue());
try {
holder.setPermission(meta.getKey().toLowerCase() + "." + c.getPriority() + "." + chatMeta, true);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("set " + meta.getKey().toLowerCase() + "." + c.getPriority() + "." + chatMeta + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
continue;
}
try {
holder.setPermission("meta." + meta.getKey() + "." + meta.getValue(), true, "global", world.getName());
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("set meta." + meta.getKey() + "." + meta.getValue() + " true global " + world.getName())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
public MigrationBPermissions() { public MigrationBPermissions() {
super("bpermissions", "Migration from bPermissions", MIGRATION, Predicates.alwaysFalse(), null); super("bpermissions", "Migration from bPermissions", MIGRATION, Predicates.alwaysFalse(), null);
} }
@ -174,82 +262,4 @@ public class MigrationBPermissions extends SubCommand<Object> {
log.info("bPermissions Migration: Success! Completed without any errors."); log.info("bPermissions Migration: Success! Completed without any errors.");
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }
private static void migrateHolder(LuckPermsPlugin plugin, World world, Calculable c, PermissionHolder holder) {
// Migrate the groups permissions in this world
for (Permission p : c.getPermissions()) {
try {
holder.setPermission(p.name(), p.isTrue(), "global", world.getName());
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("set " + p.name() + " " + p.isTrue() + " global " + world.getName())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
// Include any child permissions
for (Map.Entry<String, Boolean> child : p.getChildren().entrySet()) {
try {
holder.setPermission(child.getKey(), child.getValue(), "global", world.getName());
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("set " + child.getKey() + " " + child.getValue() + " global " + world.getName())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
// Migrate any inherited groups
for (Group parent : c.getGroups()) {
try {
holder.setPermission("group." + parent.getName(), true, "global", world.getName());
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("setinherit " + parent.getName() + " global " + world.getName())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
// Migrate existing meta
for (Map.Entry<String, String> meta : c.getMeta().entrySet()) {
if (meta.getKey().equalsIgnoreCase("prefix") || meta.getKey().equalsIgnoreCase("suffix")) {
String chatMeta = MetaUtils.escapeCharacters(meta.getValue());
try {
holder.setPermission(meta.getKey().toLowerCase() + "." + c.getPriority() + "." + chatMeta, true);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("set " + meta.getKey().toLowerCase() + "." + c.getPriority() + "." + chatMeta + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
continue;
}
try {
holder.setPermission("meta." + meta.getKey() + "." + meta.getValue(), true, "global", world.getName());
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("set meta." + meta.getKey() + "." + meta.getValue() + " true global " + world.getName())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
} }

View File

@ -36,6 +36,7 @@ import me.lucko.luckperms.common.data.LogEntry;
import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.Predicates;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException; import me.lucko.luckperms.exceptions.ObjectLacksException;
import org.anjocaido.groupmanager.GlobalGroups; import org.anjocaido.groupmanager.GlobalGroups;
import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.data.Group; import org.anjocaido.groupmanager.data.Group;
@ -43,7 +44,11 @@ import org.anjocaido.groupmanager.data.User;
import org.anjocaido.groupmanager.dataholder.WorldDataHolder; import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder; import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
import java.util.*; import java.util.AbstractMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class MigrationGroupManager extends SubCommand<Object> { public class MigrationGroupManager extends SubCommand<Object> {
@ -161,7 +166,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
UUID uuid; UUID uuid;
try { try {
uuid = UUID.fromString(user.getUUID()); uuid = UUID.fromString(user.getUUID());
} catch (IllegalArgumentException e){ } catch (IllegalArgumentException e) {
continue; continue;
} }
@ -272,11 +277,13 @@ public class MigrationGroupManager extends SubCommand<Object> {
if (primaryGroup != null) { if (primaryGroup != null) {
try { try {
user.setPermission("group." + primaryGroup, true); user.setPermission("group." + primaryGroup, true);
} catch (ObjectAlreadyHasException ignored) {} } catch (ObjectAlreadyHasException ignored) {
}
user.setPrimaryGroup(primaryGroup); user.setPrimaryGroup(primaryGroup);
try { try {
user.unsetPermission("group.default"); user.unsetPermission("group.default");
} catch (ObjectLacksException ignored) {} } catch (ObjectLacksException ignored) {
}
} }
plugin.getStorage().saveUser(user); plugin.getStorage().saveUser(user);

View File

@ -38,17 +38,18 @@ import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.data.LogEntry;
import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.Predicates;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import ru.tehkode.permissions.NativeInterface;
import ru.tehkode.permissions.PermissionGroup;
import ru.tehkode.permissions.PermissionManager;
import ru.tehkode.permissions.PermissionUser;
import ru.tehkode.permissions.bukkit.PermissionsEx;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import ru.tehkode.permissions.NativeInterface;
import ru.tehkode.permissions.PermissionGroup;
import ru.tehkode.permissions.PermissionManager;
import ru.tehkode.permissions.PermissionUser;
import ru.tehkode.permissions.bukkit.PermissionsEx;
public class MigrationPermissionsEx extends SubCommand<Object> { public class MigrationPermissionsEx extends SubCommand<Object> {
public MigrationPermissionsEx() { public MigrationPermissionsEx() {
super("permissionsex", "Migration from PermissionsEx", Permission.MIGRATION, Predicates.alwaysFalse(), super("permissionsex", "Migration from PermissionsEx", Permission.MIGRATION, Predicates.alwaysFalse(),
@ -96,7 +97,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
for (PermissionGroup group : manager.getGroupList()) { for (PermissionGroup group : manager.getGroupList()) {
int groupWeight = group.getWeight() * -1; int groupWeight = group.getWeight() * -1;
groupCount ++; groupCount++;
maxGroupWeight = Math.max(maxGroupWeight, groupWeight); maxGroupWeight = Math.max(maxGroupWeight, groupWeight);
final String name = group.getName().toLowerCase(); final String name = group.getName().toLowerCase();
@ -380,7 +381,8 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
if (primary != null) { if (primary != null) {
try { try {
lpUser.setPermission("group." + primary.toLowerCase(), true); lpUser.setPermission("group." + primary.toLowerCase(), true);
} catch (ObjectAlreadyHasException ignored) {} } catch (ObjectAlreadyHasException ignored) {
}
lpUser.setPrimaryGroup(primary); lpUser.setPrimaryGroup(primary);
} }

View File

@ -22,10 +22,17 @@
package me.lucko.luckperms.bukkit.migration; package me.lucko.luckperms.bukkit.migration;
import com.github.cheesesoftware.PowerfulPermsAPI.*; import lombok.Cleanup;
import com.github.cheesesoftware.PowerfulPermsAPI.CachedGroup;
import com.github.cheesesoftware.PowerfulPermsAPI.Group;
import com.github.cheesesoftware.PowerfulPermsAPI.Permission;
import com.github.cheesesoftware.PowerfulPermsAPI.PermissionManager;
import com.github.cheesesoftware.PowerfulPermsAPI.PowerfulPermsPlugin;
import com.github.cheesesoftware.PowerfulPermsAPI.ResultRunnable;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.zaxxer.hikari.HikariDataSource; import com.zaxxer.hikari.HikariDataSource;
import lombok.Cleanup;
import me.lucko.luckperms.api.Logger; import me.lucko.luckperms.api.Logger;
import me.lucko.luckperms.api.data.Callback; import me.lucko.luckperms.api.data.Callback;
import me.lucko.luckperms.bukkit.migration.utils.LPResultRunnable; import me.lucko.luckperms.bukkit.migration.utils.LPResultRunnable;
@ -48,7 +55,13 @@ import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.*; import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@ -77,25 +90,29 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
try { try {
Class.forName("com.github.cheesesoftware.PowerfulPermsAPI.ResponseRunnable"); Class.forName("com.github.cheesesoftware.PowerfulPermsAPI.ResponseRunnable");
legacy = true; legacy = true;
} catch (ClassNotFoundException ignored) {} } catch (ClassNotFoundException ignored) {
}
if (legacy) { if (legacy) {
try { try {
getPlayerPermissionsMethod = PermissionManager.class.getMethod("getPlayerOwnPermissions", UUID.class, ResultRunnable.class); getPlayerPermissionsMethod = PermissionManager.class.getMethod("getPlayerOwnPermissions", UUID.class, ResultRunnable.class);
getPlayerPermissionsMethod.setAccessible(true); getPlayerPermissionsMethod.setAccessible(true);
} catch (NoSuchMethodException ignored) {} } catch (NoSuchMethodException ignored) {
}
} else { } else {
try { try {
getPlayerPermissionsMethod = PermissionManager.class.getMethod("getPlayerOwnPermissions", UUID.class); getPlayerPermissionsMethod = PermissionManager.class.getMethod("getPlayerOwnPermissions", UUID.class);
getPlayerPermissionsMethod.setAccessible(true); getPlayerPermissionsMethod.setAccessible(true);
} catch (NoSuchMethodException ignored) {} } catch (NoSuchMethodException ignored) {
}
} }
try { try {
getGroupMethod = CachedGroup.class.getMethod("getGroup"); getGroupMethod = CachedGroup.class.getMethod("getGroup");
getGroupMethod.setAccessible(true); getGroupMethod.setAccessible(true);
superLegacy = true; superLegacy = true;
} catch (NoSuchMethodException ignored) {} } catch (NoSuchMethodException ignored) {
}
if (!legacy) { if (!legacy) {
try { try {
@ -119,29 +136,6 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
} }
} }
public MigrationPowerfulPerms() {
super("powerfulperms", "Migration from PowerfulPerms", MIGRATION, Predicates.not(5),
Arg.list(
Arg.create("address", true, "the address of the PP database"),
Arg.create("database", true, "the name of the PP database"),
Arg.create("username", true, "the username to log into the DB"),
Arg.create("password", true, "the password to log into the DB"),
Arg.create("db table", true, "the name of the PP table where player data is stored")
)
);
}
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
try {
return run(plugin, args);
} catch (Throwable t) {
t.printStackTrace();
return CommandResult.FAILURE;
}
}
private static void getPlayerPermissions(PermissionManager manager, UUID uuid, Callback<List<Permission>> callback) { private static void getPlayerPermissions(PermissionManager manager, UUID uuid, Callback<List<Permission>> callback) {
if (legacy) { if (legacy) {
try { try {
@ -178,6 +172,28 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
} }
} }
public MigrationPowerfulPerms() {
super("powerfulperms", "Migration from PowerfulPerms", MIGRATION, Predicates.not(5),
Arg.list(
Arg.create("address", true, "the address of the PP database"),
Arg.create("database", true, "the name of the PP database"),
Arg.create("username", true, "the username to log into the DB"),
Arg.create("password", true, "the password to log into the DB"),
Arg.create("db table", true, "the name of the PP table where player data is stored")
)
);
}
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
try {
return run(plugin, args);
} catch (Throwable t) {
t.printStackTrace();
return CommandResult.FAILURE;
}
}
private CommandResult run(LuckPermsPlugin plugin, List<String> args) { private CommandResult run(LuckPermsPlugin plugin, List<String> args) {
final Logger log = plugin.getLog(); final Logger log = plugin.getLog();
if (!plugin.isPluginLoaded("PowerfulPerms")) { if (!plugin.isPluginLoaded("PowerfulPerms")) {

View File

@ -36,6 +36,7 @@ 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.utils.Predicates; import me.lucko.luckperms.common.utils.Predicates;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService; import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService;
import org.tyrannyofheaven.bukkit.zPermissions.dao.PermissionService; import org.tyrannyofheaven.bukkit.zPermissions.dao.PermissionService;
import org.tyrannyofheaven.bukkit.zPermissions.model.EntityMetadata; import org.tyrannyofheaven.bukkit.zPermissions.model.EntityMetadata;
@ -122,11 +123,13 @@ public class MigrationZPermissions extends SubCommand<Object> {
if (e.getWorld() != null) { if (e.getWorld() != null) {
try { try {
group.setPermission(e.getPermission(), true, "global", e.getWorld().getName()); group.setPermission(e.getPermission(), true, "global", e.getWorld().getName());
} catch (ObjectAlreadyHasException ignored) {} } catch (ObjectAlreadyHasException ignored) {
}
} else { } else {
try { try {
group.setPermission(e.getPermission(), true); // TODO handle negated. group.setPermission(e.getPermission(), true); // TODO handle negated.
} catch (ObjectAlreadyHasException ignored) {} } catch (ObjectAlreadyHasException ignored) {
}
} }
} }
@ -138,7 +141,8 @@ public class MigrationZPermissions extends SubCommand<Object> {
try { try {
group.setPermission("group." + inheritance.getParent(), true); group.setPermission("group." + inheritance.getParent(), true);
} catch (ObjectAlreadyHasException ignored) {} } catch (ObjectAlreadyHasException ignored) {
}
} }
for (EntityMetadata metadata : entity.getMetadata()) { for (EntityMetadata metadata : entity.getMetadata()) {

View File

@ -26,6 +26,7 @@ import com.github.cheesesoftware.PowerfulPermsAPI.ResultRunnable;
/** /**
* Overrides the default ResultRunnable, callbacks will always run in the same thread. (an async one, hopefully.) * Overrides the default ResultRunnable, callbacks will always run in the same thread. (an async one, hopefully.)
*
* @param <T> type * @param <T> type
*/ */
public abstract class LPResultRunnable<T> extends ResultRunnable<T> { public abstract class LPResultRunnable<T> extends ResultRunnable<T> {

View File

@ -22,9 +22,11 @@
package me.lucko.luckperms.bukkit.model; package me.lucko.luckperms.bukkit.model;
import lombok.Getter;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
@ -34,6 +36,24 @@ import java.util.Map;
public class ChildPermissionProvider { public class ChildPermissionProvider {
private static void resolveChildren(Map<String, Boolean> accumulator, Map<String, Boolean> children, boolean invert) {
for (Map.Entry<String, Boolean> e : children.entrySet()) {
if (accumulator.containsKey(e.getKey())) {
continue; // Prevent infinite loops
}
Permission perm = Bukkit.getServer().getPluginManager().getPermission(e.getKey());
boolean value = e.getValue() ^ invert;
String lName = e.getKey().toLowerCase();
accumulator.put(lName, value);
if (perm != null) {
resolveChildren(accumulator, perm.getChildren(), !value);
}
}
}
@Getter @Getter
private ImmutableMap<Map.Entry<String, Boolean>, ImmutableMap<String, Boolean>> permissions = ImmutableMap.of(); private ImmutableMap<Map.Entry<String, Boolean>, ImmutableMap<String, Boolean>> permissions = ImmutableMap.of();
@ -54,22 +74,4 @@ public class ChildPermissionProvider {
this.permissions = ImmutableMap.copyOf(permissions); this.permissions = ImmutableMap.copyOf(permissions);
} }
private static void resolveChildren(Map<String, Boolean> accumulator, Map<String, Boolean> children, boolean invert) {
for (Map.Entry<String, Boolean> e : children.entrySet()) {
if (accumulator.containsKey(e.getKey())) {
continue; // Prevent infinite loops
}
Permission perm = Bukkit.getServer().getPluginManager().getPermission(e.getKey());
boolean value = e.getValue() ^ invert;
String lName = e.getKey().toLowerCase();
accumulator.put(lName, value);
if (perm != null) {
resolveChildren(accumulator, perm.getChildren(), !value);
}
}
}
} }

View File

@ -22,10 +22,13 @@
package me.lucko.luckperms.bukkit.model; package me.lucko.luckperms.bukkit.model;
import com.google.common.collect.ImmutableMap;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import com.google.common.collect.ImmutableMap;
import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.Tristate;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permissible;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
@ -40,38 +43,6 @@ import java.util.Set;
public class DefaultsProvider { public class DefaultsProvider {
private final DummyPermissible opDummy = new DummyPermissible(this::refreshOp);
private final DummyPermissible nonOpDummy = new DummyPermissible(this::refreshNonOp);
@Getter
private Map<String, Boolean> opDefaults = ImmutableMap.of();
@Getter
private Map<String, Boolean> nonOpDefaults = ImmutableMap.of();
public void refresh() {
refreshOp();
refreshNonOp();
}
private void refreshOp() {
unregisterDefaults(opDefaults, opDummy);
Map<String, Boolean> builder = new HashMap<>();
calculateDefaults(builder, opDummy, true);
opDefaults = ImmutableMap.copyOf(builder);
}
private void refreshNonOp() {
unregisterDefaults(nonOpDefaults, nonOpDummy);
Map<String, Boolean> builder = new HashMap<>();
calculateDefaults(builder, nonOpDummy, false);
nonOpDefaults = ImmutableMap.copyOf(builder);
}
private static void unregisterDefaults(Map<String, Boolean> map, DummyPermissible p) { private static void unregisterDefaults(Map<String, Boolean> map, DummyPermissible p) {
Set<String> perms = map.keySet(); Set<String> perms = map.keySet();
@ -110,6 +81,36 @@ public class DefaultsProvider {
} }
} }
@Getter
private Map<String, Boolean> opDefaults = ImmutableMap.of();
private final DummyPermissible opDummy = new DummyPermissible(this::refreshOp);
@Getter
private Map<String, Boolean> nonOpDefaults = ImmutableMap.of();
private final DummyPermissible nonOpDummy = new DummyPermissible(this::refreshNonOp);
public void refresh() {
refreshOp();
refreshNonOp();
}
private void refreshOp() {
unregisterDefaults(opDefaults, opDummy);
Map<String, Boolean> builder = new HashMap<>();
calculateDefaults(builder, opDummy, true);
opDefaults = ImmutableMap.copyOf(builder);
}
private void refreshNonOp() {
unregisterDefaults(nonOpDefaults, nonOpDummy);
Map<String, Boolean> builder = new HashMap<>();
calculateDefaults(builder, nonOpDummy, false);
nonOpDefaults = ImmutableMap.copyOf(builder);
}
public Tristate hasDefault(String permission, boolean isOp) { public Tristate hasDefault(String permission, boolean isOp) {
Map<String, Boolean> map = isOp ? opDefaults : nonOpDefaults; Map<String, Boolean> map = isOp ? opDefaults : nonOpDefaults;

View File

@ -24,16 +24,27 @@ package me.lucko.luckperms.bukkit.model;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.bukkit.LPBukkitPlugin; import me.lucko.luckperms.bukkit.LPBukkitPlugin;
import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.core.model.User;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.*; import org.bukkit.permissions.PermissibleBase;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.permissions.PermissionRemovedExecutor;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.util.*; import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;

View File

@ -23,6 +23,7 @@
package me.lucko.luckperms.bukkit.vault; package me.lucko.luckperms.bukkit.vault;
import lombok.NonNull; import lombok.NonNull;
import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.caching.MetaData; import me.lucko.luckperms.api.caching.MetaData;
@ -35,6 +36,7 @@ import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.utils.ExtractedContexts; import me.lucko.luckperms.common.utils.ExtractedContexts;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException; import me.lucko.luckperms.exceptions.ObjectLacksException;
import net.milkbowl.vault.chat.Chat; import net.milkbowl.vault.chat.Chat;
import java.util.HashMap; import java.util.HashMap;
@ -92,7 +94,8 @@ public class VaultChatHook extends Chat {
toRemove.forEach(n -> { toRemove.forEach(n -> {
try { try {
holder.unsetPermission(n); holder.unsetPermission(n);
} catch (ObjectLacksException ignored) {} } catch (ObjectLacksException ignored) {
}
}); });
Node.Builder metaNode = NodeFactory.makeMetaNode(node, value).setValue(true); Node.Builder metaNode = NodeFactory.makeMetaNode(node, value).setValue(true);
@ -105,7 +108,8 @@ public class VaultChatHook extends Chat {
try { try {
holder.setPermission(metaNode.build()); holder.setPermission(metaNode.build());
} catch (ObjectAlreadyHasException ignored) {} } catch (ObjectAlreadyHasException ignored) {
}
perms.save(holder); perms.save(holder);
}); });
@ -131,7 +135,8 @@ public class VaultChatHook extends Chat {
try { try {
holder.setPermission(node.build()); holder.setPermission(node.build());
} catch (ObjectAlreadyHasException ignored) {} } catch (ObjectAlreadyHasException ignored) {
}
perms.save(holder); perms.save(holder);
}); });

View File

@ -23,9 +23,12 @@
package me.lucko.luckperms.bukkit.vault; package me.lucko.luckperms.bukkit.vault;
import lombok.Getter; import lombok.Getter;
import me.lucko.luckperms.bukkit.LPBukkitPlugin; import me.lucko.luckperms.bukkit.LPBukkitPlugin;
import net.milkbowl.vault.chat.Chat; import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import org.bukkit.plugin.ServicePriority; import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.ServicesManager; import org.bukkit.plugin.ServicesManager;

View File

@ -26,6 +26,7 @@ import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import lombok.Setter; import lombok.Setter;
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;
@ -38,6 +39,7 @@ 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.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException; import me.lucko.luckperms.exceptions.ObjectLacksException;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import java.util.HashMap; import java.util.HashMap;
@ -92,6 +94,7 @@ public class VaultPermissionHook extends Permission {
/** /**
* Generic method to add a permission to a holder * Generic method to add a permission to a holder
*
* @param world the world to add in * @param world the world to add in
* @param holder the holder to add the permission to * @param holder the holder to add the permission to
* @param permission the permission to add * @param permission the permission to add
@ -103,13 +106,15 @@ public class VaultPermissionHook extends Permission {
} else { } else {
holder.setPermission(permission, true, server); holder.setPermission(permission, true, server);
} }
} catch (ObjectAlreadyHasException ignored) {} } catch (ObjectAlreadyHasException ignored) {
}
save(holder); save(holder);
} }
/** /**
* Generic method to remove a permission from a holder * Generic method to remove a permission from a holder
*
* @param world the world to remove in * @param world the world to remove in
* @param holder the holder to remove the permission from * @param holder the holder to remove the permission from
* @param permission the permission to remove * @param permission the permission to remove
@ -121,13 +126,15 @@ public class VaultPermissionHook extends Permission {
} else { } else {
holder.unsetPermission(permission, server); holder.unsetPermission(permission, server);
} }
} catch (ObjectLacksException ignored) {} } catch (ObjectLacksException ignored) {
}
save(holder); save(holder);
} }
/** /**
* Utility method for saving a user or group * Utility method for saving a user or group
*
* @param holder the holder instance * @param holder the holder instance
*/ */
void save(PermissionHolder holder) { void save(PermissionHolder holder) {
@ -263,7 +270,8 @@ public class VaultPermissionHook extends Permission {
} else { } else {
user.setInheritGroup(group, server); user.setInheritGroup(group, server);
} }
} catch (ObjectAlreadyHasException ignored) {} } catch (ObjectAlreadyHasException ignored) {
}
save(user); save(user);
}); });
return true; return true;
@ -287,7 +295,8 @@ public class VaultPermissionHook extends Permission {
} else { } else {
user.unsetInheritGroup(group, server); user.unsetInheritGroup(group, server);
} }
} catch (ObjectLacksException ignored) {} } catch (ObjectLacksException ignored) {
}
save(user); save(user);
}); });
return true; return true;

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.15-SNAPSHOT</version> <version>2.16-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -23,8 +23,10 @@
package me.lucko.luckperms.bungee; package me.lucko.luckperms.bungee;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import me.lucko.luckperms.api.context.ContextCalculator; import me.lucko.luckperms.api.context.ContextCalculator;
import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.context.MutableContextSet;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.ServerSwitchEvent; import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Listener;
@ -35,6 +37,10 @@ import java.util.Map;
public class BackendServerCalculator extends ContextCalculator<ProxiedPlayer> implements Listener { public class BackendServerCalculator extends ContextCalculator<ProxiedPlayer> implements Listener {
private static final String WORLD_KEY = "world"; private static final String WORLD_KEY = "world";
private static String getServer(ProxiedPlayer player) {
return player.getServer() == null ? null : (player.getServer().getInfo() == null ? null : player.getServer().getInfo().getName());
}
@Override @Override
public MutableContextSet giveApplicableContext(ProxiedPlayer subject, MutableContextSet accumulator) { public MutableContextSet giveApplicableContext(ProxiedPlayer subject, MutableContextSet accumulator) {
String server = getServer(subject); String server = getServer(subject);
@ -60,8 +66,4 @@ public class BackendServerCalculator extends ContextCalculator<ProxiedPlayer> im
public void onPlayerServerSwitch(ServerSwitchEvent e) { public void onPlayerServerSwitch(ServerSwitchEvent e) {
pushUpdate(e.getPlayer(), Maps.immutableEntry("null", "null"), Maps.immutableEntry(WORLD_KEY, getServer(e.getPlayer()))); pushUpdate(e.getPlayer(), Maps.immutableEntry("null", "null"), Maps.immutableEntry(WORLD_KEY, getServer(e.getPlayer())));
} }
private static String getServer(ProxiedPlayer player) {
return player.getServer() == null ? null : (player.getServer().getInfo() == null ? null : player.getServer().getInfo().getName());
}
} }

View File

@ -22,8 +22,10 @@
package me.lucko.luckperms.bungee; package me.lucko.luckperms.bungee;
import com.google.common.collect.ImmutableList;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import com.google.common.collect.ImmutableList;
import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.common.calculators.AbstractCalculatorFactory; import me.lucko.luckperms.common.calculators.AbstractCalculatorFactory;
import me.lucko.luckperms.common.calculators.PermissionCalculator; import me.lucko.luckperms.common.calculators.PermissionCalculator;

View File

@ -24,9 +24,11 @@ package me.lucko.luckperms.bungee;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import me.lucko.luckperms.common.commands.CommandManager; import me.lucko.luckperms.common.commands.CommandManager;
import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.constants.Patterns; import me.lucko.luckperms.common.constants.Patterns;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.TabExecutor; import net.md_5.bungee.api.plugin.TabExecutor;

View File

@ -23,6 +23,7 @@
package me.lucko.luckperms.bungee; package me.lucko.luckperms.bungee;
import me.lucko.luckperms.common.config.AbstractConfiguration; import me.lucko.luckperms.common.config.AbstractConfiguration;
import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration; import net.md_5.bungee.config.YamlConfiguration;

View File

@ -29,6 +29,7 @@ import me.lucko.luckperms.common.core.UuidCache;
import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.defaults.Rule; import me.lucko.luckperms.common.defaults.Rule;
import me.lucko.luckperms.common.utils.AbstractListener; import me.lucko.luckperms.common.utils.AbstractListener;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;

View File

@ -25,6 +25,7 @@ package me.lucko.luckperms.bungee;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.commands.sender.SenderFactory; import me.lucko.luckperms.common.commands.sender.SenderFactory;
import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.constants.Constants;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;

View File

@ -23,6 +23,7 @@
package me.lucko.luckperms.bungee; package me.lucko.luckperms.bungee;
import lombok.Getter; import lombok.Getter;
import me.lucko.luckperms.ApiHandler; import me.lucko.luckperms.ApiHandler;
import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.Logger; import me.lucko.luckperms.api.Logger;
@ -52,7 +53,12 @@ import me.lucko.luckperms.common.storage.Storage;
import me.lucko.luckperms.common.storage.StorageFactory; import me.lucko.luckperms.common.storage.StorageFactory;
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask; import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
import me.lucko.luckperms.common.tasks.UpdateTask; import me.lucko.luckperms.common.tasks.UpdateTask;
import me.lucko.luckperms.common.utils.*; import me.lucko.luckperms.common.utils.BufferedRequest;
import me.lucko.luckperms.common.utils.DebugHandler;
import me.lucko.luckperms.common.utils.LocaleManager;
import me.lucko.luckperms.common.utils.LogFactory;
import me.lucko.luckperms.common.utils.PermissionCache;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
@ -69,9 +75,8 @@ import java.util.stream.Collectors;
@Getter @Getter
public class LPBungeePlugin extends Plugin implements LuckPermsPlugin { public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
private Executor executor;
private final Set<UUID> ignoringLogs = ConcurrentHashMap.newKeySet(); private final Set<UUID> ignoringLogs = ConcurrentHashMap.newKeySet();
private Executor executor;
private LPConfiguration configuration; private LPConfiguration configuration;
private UserManager userManager; private UserManager userManager;
private GroupManager groupManager; private GroupManager groupManager;
@ -278,7 +283,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
c.addAll(getProxy().getServers().values().stream() c.addAll(getProxy().getServers().values().stream()
.map(ServerInfo::getName) .map(ServerInfo::getName)
.map(s -> { .map(s -> {
MutableContextSet set = new MutableContextSet(); MutableContextSet set = MutableContextSet.create();
set.add("server", getConfiguration().getServer()); set.add("server", getConfiguration().getServer());
set.add("world", s); set.add("world", s);
return set.makeImmutable(); return set.makeImmutable();

View File

@ -34,7 +34,12 @@ import me.lucko.luckperms.common.constants.Permission;
import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.data.LogEntry;
import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.Predicates;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import net.alpenblock.bungeeperms.*;
import net.alpenblock.bungeeperms.BungeePerms;
import net.alpenblock.bungeeperms.Group;
import net.alpenblock.bungeeperms.Server;
import net.alpenblock.bungeeperms.User;
import net.alpenblock.bungeeperms.World;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId> <groupId>me.lucko.luckperms</groupId>
<version>2.15-SNAPSHOT</version> <version>2.16-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -47,7 +47,11 @@ import me.lucko.luckperms.common.utils.LocaleManager;
import me.lucko.luckperms.common.utils.PermissionCache; import me.lucko.luckperms.common.utils.PermissionCache;
import java.io.File; import java.io.File;
import java.util.*; import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
/** /**
@ -59,72 +63,84 @@ public interface LuckPermsPlugin {
/** /**
* Gets the user manager instance for the platform * Gets the user manager instance for the platform
*
* @return the user manager * @return the user manager
*/ */
UserManager getUserManager(); UserManager getUserManager();
/** /**
* Gets the group manager instance for the platform * Gets the group manager instance for the platform
*
* @return the group manager * @return the group manager
*/ */
GroupManager getGroupManager(); GroupManager getGroupManager();
/** /**
* Gets the track manager instance for the platform * Gets the track manager instance for the platform
*
* @return the track manager * @return the track manager
*/ */
TrackManager getTrackManager(); TrackManager getTrackManager();
/** /**
* Gets the plugin's configuration * Gets the plugin's configuration
*
* @return the plugin config * @return the plugin config
*/ */
LPConfiguration getConfiguration(); LPConfiguration getConfiguration();
/** /**
* Gets the primary data storage instance. This is likely to be wrapped with extra layers for caching, etc. * Gets the primary data storage instance. This is likely to be wrapped with extra layers for caching, etc.
*
* @return the storage handler instance * @return the storage handler instance
*/ */
Storage getStorage(); Storage getStorage();
/** /**
* Gets the redis messaging instance if present. Could return null if redis is not enabled. * Gets the redis messaging instance if present. Could return null if redis is not enabled.
*
* @return the redis messaging service * @return the redis messaging service
*/ */
RedisMessaging getRedisMessaging(); RedisMessaging getRedisMessaging();
/** /**
* Gets a wrapped logger instance for the platform. * Gets a wrapped logger instance for the platform.
*
* @return the plugin's logger * @return the plugin's logger
*/ */
Logger getLog(); Logger getLog();
/** /**
* Gets the UUID caching store for the platform * Gets the UUID caching store for the platform
*
* @return the uuid cache * @return the uuid cache
*/ */
UuidCache getUuidCache(); UuidCache getUuidCache();
/** /**
* Returns the class implementing the LuckPermsAPI on this platform. * Returns the class implementing the LuckPermsAPI on this platform.
*
* @return the api * @return the api
*/ */
ApiProvider getApiProvider(); ApiProvider getApiProvider();
/** /**
* Gets the importer instance * Gets the importer instance
*
* @return the importer * @return the importer
*/ */
Importer getImporter(); Importer getImporter();
/** /**
* Gets the consecutive command executor instance * Gets the consecutive command executor instance
*
* @return the consecutive executor * @return the consecutive executor
*/ */
ConsecutiveExecutor getConsecutiveExecutor(); ConsecutiveExecutor getConsecutiveExecutor();
/** /**
* Gets the instance providing locale translations for the plugin * Gets the instance providing locale translations for the plugin
*
* @return the locale manager * @return the locale manager
*/ */
LocaleManager getLocaleManager(); LocaleManager getLocaleManager();
@ -132,45 +148,53 @@ public interface LuckPermsPlugin {
/** /**
* Gets the context manager. * Gets the context manager.
* This object handles context accumulation for all players on the platform. * This object handles context accumulation for all players on the platform.
*
* @return the context manager * @return the context manager
*/ */
ContextManager getContextManager(); ContextManager getContextManager();
/** /**
* Gets the class responsible for constructing PermissionCalculators on this platform. * Gets the class responsible for constructing PermissionCalculators on this platform.
*
* @return the permission calculator factory * @return the permission calculator factory
*/ */
CalculatorFactory getCalculatorFactory(); CalculatorFactory getCalculatorFactory();
/** /**
* Gets the verbose debug handler instance. * Gets the verbose debug handler instance.
*
* @return the debug handler instance * @return the debug handler instance
*/ */
DebugHandler getDebugHandler(); DebugHandler getDebugHandler();
/** /**
* Gets the permission caching instance for the platform. * Gets the permission caching instance for the platform.
*
* @return the permission cache instance * @return the permission cache instance
*/ */
PermissionCache getPermissionCache(); PermissionCache getPermissionCache();
/** /**
* Execute a runnable asynchronously * Execute a runnable asynchronously
*
* @param r the task to run * @param r the task to run
*/ */
void doAsync(Runnable r); void doAsync(Runnable r);
/** /**
* Execute a runnable synchronously * Execute a runnable synchronously
*
* @param r the task to run * @param r the task to run
*/ */
void doSync(Runnable r); void doSync(Runnable r);
Executor getSyncExecutor(); Executor getSyncExecutor();
Executor getAsyncExecutor(); Executor getAsyncExecutor();
/** /**
* Execute a runnable asynchronously on a loop * Execute a runnable asynchronously on a loop
*
* @param r the task to run * @param r the task to run
* @param interval the time between runs in ticks * @param interval the time between runs in ticks
*/ */
@ -178,30 +202,35 @@ public interface LuckPermsPlugin {
/** /**
* Gets a string of the plugin's version * Gets a string of the plugin's version
*
* @return the version of the plugin * @return the version of the plugin
*/ */
String getVersion(); String getVersion();
/** /**
* Gets the platform type this instance of LuckPerms is running on. * Gets the platform type this instance of LuckPerms is running on.
*
* @return the platform type * @return the platform type
*/ */
PlatformType getType(); PlatformType getType();
/** /**
* Gets the plugins main directory * Gets the plugins main directory
*
* @return the main plugin directory * @return the main plugin directory
*/ */
File getMainDir(); File getMainDir();
/** /**
* Gets the plugins main data storage directory * Gets the plugins main data storage directory
*
* @return the platforms data folder * @return the platforms data folder
*/ */
File getDataFolder(); File getDataFolder();
/** /**
* Returns a colored string indicating the status of a player * Returns a colored string indicating the status of a player
*
* @param uuid The player's uuid * @param uuid The player's uuid
* @return a formatted status string * @return a formatted status string
*/ */
@ -213,6 +242,7 @@ public interface LuckPermsPlugin {
/** /**
* Gets a player object linked to this User. The returned object must be the same type * Gets a player object linked to this User. The returned object must be the same type
* as the instance used in the platforms {@link ContextManager} * as the instance used in the platforms {@link ContextManager}
*
* @param user the user instance * @param user the user instance
* @return a player object, or null, if one couldn't be found. * @return a player object, or null, if one couldn't be found.
*/ */
@ -220,6 +250,7 @@ public interface LuckPermsPlugin {
/** /**
* 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.
*
* @param user the user instance * @param user the user instance
* @return a contexts object, or null if one couldn't be generated * @return a contexts object, or null if one couldn't be generated
*/ */
@ -227,24 +258,28 @@ public interface LuckPermsPlugin {
/** /**
* Gets the number of users online on the platform * Gets the number of users online on the platform
*
* @return the number of users * @return the number of users
*/ */
int getPlayerCount(); int getPlayerCount();
/** /**
* Gets the usernames of the users online on the platform * Gets the usernames of the users online on the platform
*
* @return a {@link List} of usernames * @return a {@link List} of usernames
*/ */
List<String> getPlayerList(); List<String> getPlayerList();
/** /**
* Gets the UUIDs of the users online on the platform * Gets the UUIDs of the users online on the platform
*
* @return a {@link Set} of UUIDs * @return a {@link Set} of UUIDs
*/ */
Set<UUID> getOnlinePlayers(); Set<UUID> getOnlinePlayers();
/** /**
* Checks if a user is online * Checks if a user is online
*
* @param external the users external uuid * @param external the users external uuid
* @return true if the user is online * @return true if the user is online
*/ */
@ -252,18 +287,21 @@ public interface LuckPermsPlugin {
/** /**
* Gets a list of online Senders on the platform * Gets a list of online Senders on the platform
*
* @return a {@link List} of senders online on the platform * @return a {@link List} of senders online on the platform
*/ */
List<Sender> getSenders(); List<Sender> getSenders();
/** /**
* Gets the console. * Gets the console.
*
* @return the console sender of the instance * @return the console sender of the instance
*/ */
Sender getConsoleSender(); Sender getConsoleSender();
/** /**
* Gets a set of Contexts that should be pre-processed in advance * Gets a set of Contexts that should be pre-processed in advance
*
* @param op if the user being processed is op * @param op if the user being processed is op
* @return a set of contexts * @return a set of contexts
*/ */
@ -275,6 +313,7 @@ public interface LuckPermsPlugin {
/** /**
* Gets a map of extra information to be shown in the info command * Gets a map of extra information to be shown in the info command
*
* @return a map of options, or null * @return a map of options, or null
*/ */
default LinkedHashMap<String, Object> getExtraInfo() { default LinkedHashMap<String, Object> getExtraInfo() {
@ -283,12 +322,14 @@ public interface LuckPermsPlugin {
/** /**
* Gets a set of players ignoring logging output * Gets a set of players ignoring logging output
*
* @return a {@link Set} of {@link UUID}s * @return a {@link Set} of {@link UUID}s
*/ */
Set<UUID> getIgnoringLogs(); Set<UUID> getIgnoringLogs();
/** /**
* Gets a loaded plugins instance from the platform * Gets a loaded plugins instance from the platform
*
* @param name the name of the plugin * @param name the name of the plugin
* @return a plugin instance * @return a plugin instance
*/ */
@ -296,6 +337,7 @@ public interface LuckPermsPlugin {
/** /**
* Gets a provided service from the platform. * Gets a provided service from the platform.
*
* @param clazz the class of the service * @param clazz the class of the service
* @return the service instance, if it is provided for * @return the service instance, if it is provided for
*/ */
@ -303,6 +345,7 @@ public interface LuckPermsPlugin {
/** /**
* Gets the UUID of a player. Used as a backup for migration * Gets the UUID of a player. Used as a backup for migration
*
* @param playerName the players name * @param playerName the players name
* @return a uuid if found, or null if not * @return a uuid if found, or null if not
*/ */
@ -310,6 +353,7 @@ public interface LuckPermsPlugin {
/** /**
* Checks if a plugin is loaded on the platform * Checks if a plugin is loaded on the platform
*
* @param name the name of the plugin * @param name the name of the plugin
* @return true if the plugin is loaded * @return true if the plugin is loaded
*/ */
@ -317,6 +361,7 @@ public interface LuckPermsPlugin {
/** /**
* Gets the update task buffer of the platform, used for scheduling and running update tasks. * Gets the update task buffer of the platform, used for scheduling and running update tasks.
*
* @return the update task buffer instance * @return the update task buffer instance
*/ */
BufferedRequest<Void> getUpdateTaskBuffer(); BufferedRequest<Void> getUpdateTaskBuffer();

View File

@ -22,16 +22,37 @@
package me.lucko.luckperms.common.api; package me.lucko.luckperms.common.api;
import com.google.common.eventbus.EventBus;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
import me.lucko.luckperms.api.*;
import com.google.common.eventbus.EventBus;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.Datastore;
import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.LPConfiguration;
import me.lucko.luckperms.api.Logger;
import me.lucko.luckperms.api.LuckPermsApi;
import me.lucko.luckperms.api.MessagingService;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.PlatformType;
import me.lucko.luckperms.api.Storage;
import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.User;
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.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.*; import me.lucko.luckperms.common.api.internal.DatastoreLink;
import me.lucko.luckperms.common.api.internal.GroupLink;
import me.lucko.luckperms.common.api.internal.LPConfigurationLink;
import me.lucko.luckperms.common.api.internal.StorageLink;
import me.lucko.luckperms.common.api.internal.TrackLink;
import me.lucko.luckperms.common.api.internal.UserLink;
import me.lucko.luckperms.common.api.internal.Utils;
import me.lucko.luckperms.common.api.internal.UuidCacheLink;
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;
@ -71,7 +92,7 @@ public class ApiProvider implements LuckPermsApi {
@Override @Override
public double getApiVersion() { public double getApiVersion() {
return 2.15; return 2.16;
} }
@Override @Override

View File

@ -24,7 +24,13 @@ package me.lucko.luckperms.common.api.internal;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
import me.lucko.luckperms.api.*;
import me.lucko.luckperms.api.Datastore;
import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.Log;
import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.data.Callback; import me.lucko.luckperms.api.data.Callback;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.storage.Storage; import me.lucko.luckperms.common.storage.Storage;
@ -33,7 +39,11 @@ 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.*; import static me.lucko.luckperms.common.api.internal.Utils.checkGroup;
import static me.lucko.luckperms.common.api.internal.Utils.checkName;
import static me.lucko.luckperms.common.api.internal.Utils.checkTrack;
import static me.lucko.luckperms.common.api.internal.Utils.checkUser;
import static me.lucko.luckperms.common.api.internal.Utils.checkUsername;
/** /**
* Provides a link between {@link Datastore} and {@link Storage} * Provides a link between {@link Datastore} and {@link Storage}
@ -104,7 +114,7 @@ public class DatastoreLink implements Datastore {
@Override @Override
public void loadOrCreateUser(@NonNull UUID uuid, @NonNull String username, Callback<Boolean> callback) { public void loadOrCreateUser(@NonNull UUID uuid, @NonNull String username, Callback<Boolean> callback) {
registerCallback(master.force().loadUser(uuid, checkUsername(username)) , callback); registerCallback(master.force().loadUser(uuid, checkUsername(username)), callback);
} }
@Override @Override

View File

@ -26,13 +26,16 @@ import lombok.AccessLevel;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import me.lucko.luckperms.api.Group; import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; 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 static me.lucko.luckperms.common.api.internal.Utils.*; import static me.lucko.luckperms.common.api.internal.Utils.checkGroup;
import static me.lucko.luckperms.common.api.internal.Utils.checkServer;
import static me.lucko.luckperms.common.api.internal.Utils.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}

View File

@ -23,6 +23,7 @@
package me.lucko.luckperms.common.api.internal; package me.lucko.luckperms.common.api.internal;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import me.lucko.luckperms.api.LPConfiguration; import me.lucko.luckperms.api.LPConfiguration;
import me.lucko.luckperms.api.data.DatastoreConfiguration; import me.lucko.luckperms.api.data.DatastoreConfiguration;
import me.lucko.luckperms.api.data.MySQLConfiguration; import me.lucko.luckperms.api.data.MySQLConfiguration;

View File

@ -24,6 +24,7 @@ package me.lucko.luckperms.common.api.internal;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
import me.lucko.luckperms.api.Log; import me.lucko.luckperms.api.Log;
import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.LogEntry;

View File

@ -24,15 +24,28 @@ package me.lucko.luckperms.common.api.internal;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
import me.lucko.luckperms.api.*;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.LocalizedNode;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.PermissionHolder;
import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.ContextSet;
import me.lucko.luckperms.common.utils.ExtractedContexts; import me.lucko.luckperms.common.utils.ExtractedContexts;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException; import me.lucko.luckperms.exceptions.ObjectLacksException;
import java.util.*; import java.util.AbstractMap;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import static me.lucko.luckperms.common.api.internal.Utils.*; import static me.lucko.luckperms.common.api.internal.Utils.checkNode;
import static me.lucko.luckperms.common.api.internal.Utils.checkServer;
import static me.lucko.luckperms.common.api.internal.Utils.checkTime;
import static me.lucko.luckperms.common.core.model.PermissionHolder.exportToLegacy; import static me.lucko.luckperms.common.core.model.PermissionHolder.exportToLegacy;
/** /**

View File

@ -24,7 +24,13 @@ package me.lucko.luckperms.common.api.internal;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
import me.lucko.luckperms.api.*;
import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.Log;
import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.api.Storage;
import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.User;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;
import java.util.Set; import java.util.Set;
@ -32,7 +38,11 @@ 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.*; import static me.lucko.luckperms.common.api.internal.Utils.checkGroup;
import static me.lucko.luckperms.common.api.internal.Utils.checkName;
import static me.lucko.luckperms.common.api.internal.Utils.checkTrack;
import static me.lucko.luckperms.common.api.internal.Utils.checkUser;
import static me.lucko.luckperms.common.api.internal.Utils.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}

View File

@ -26,6 +26,7 @@ import lombok.AccessLevel;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
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.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;

View File

@ -25,6 +25,7 @@ package me.lucko.luckperms.common.api.internal;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import me.lucko.luckperms.api.Group; import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.User; import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.caching.UserData; import me.lucko.luckperms.api.caching.UserData;
@ -35,7 +36,9 @@ 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.*; import static me.lucko.luckperms.common.api.internal.Utils.checkGroup;
import static me.lucko.luckperms.common.api.internal.Utils.checkServer;
import static me.lucko.luckperms.common.api.internal.Utils.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}

View File

@ -22,8 +22,10 @@
package me.lucko.luckperms.common.api.internal; package me.lucko.luckperms.common.api.internal;
import com.google.common.base.Preconditions;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
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;

View File

@ -24,6 +24,7 @@ package me.lucko.luckperms.common.api.internal;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
import me.lucko.luckperms.api.UuidCache; import me.lucko.luckperms.api.UuidCache;
import java.util.UUID; import java.util.UUID;

View File

@ -22,10 +22,12 @@
package me.lucko.luckperms.common.caching; package me.lucko.luckperms.common.caching;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap;
import me.lucko.luckperms.api.caching.MetaData; import me.lucko.luckperms.api.caching.MetaData;
import java.util.Map; import java.util.Map;

View File

@ -24,9 +24,14 @@ package me.lucko.luckperms.common.caching;
import lombok.Getter; import lombok.Getter;
import lombok.ToString; import lombok.ToString;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import java.util.*; import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
/** /**
* Holds temporary mutable meta whilst this object is passed up the inheritance tree to accumulate meta from parents * Holds temporary mutable meta whilst this object is passed up the inheritance tree to accumulate meta from parents

View File

@ -22,8 +22,10 @@
package me.lucko.luckperms.common.caching; package me.lucko.luckperms.common.caching;
import com.google.common.collect.ImmutableMap;
import lombok.NonNull; import lombok.NonNull;
import com.google.common.collect.ImmutableMap;
import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.api.caching.PermissionData; import me.lucko.luckperms.api.caching.PermissionData;

View File

@ -22,14 +22,16 @@
package me.lucko.luckperms.common.caching; package me.lucko.luckperms.common.caching;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.caching.MetaData; import me.lucko.luckperms.api.caching.MetaData;
import me.lucko.luckperms.api.caching.PermissionData; import me.lucko.luckperms.api.caching.PermissionData;

View File

@ -32,6 +32,7 @@ public interface CalculatorFactory {
/** /**
* Builds a PermissionCalculator for the user in the given context * Builds a PermissionCalculator for the user in the given context
*
* @param contexts the contexts to build the calculator in * @param contexts the contexts to build the calculator in
* @param user the user to build for * @param user the user to build for
* @return a permission calculator instance * @return a permission calculator instance

View File

@ -22,10 +22,12 @@
package me.lucko.luckperms.common.calculators; package me.lucko.luckperms.common.calculators;
import lombok.RequiredArgsConstructor;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import lombok.RequiredArgsConstructor;
import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.LuckPermsPlugin;

Some files were not shown because too many files have changed in this diff Show More