Release version 4.2.0

blaze it
This commit is contained in:
Luck
2018-05-06 17:16:36 +01:00
Unverified
parent 91b7af52ac
commit 64838708ab
38 changed files with 487 additions and 280 deletions
@@ -47,8 +47,6 @@ public interface ActionLogger {
/**
* Gets a {@link Log} instance from the plugin storage.
*
* <p>Returns the same result as {@link Storage#getLog()}.</p>
*
* @return a log instance
* @see Storage#getLog()
*/
@@ -0,0 +1,112 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Encapsulates the result of an operation to save uuid data about a player.
*
* @since 4.2
*/
public interface PlayerSaveResult {
/**
* Gets the status returned by the operation
*
* @return the status
*/
@Nonnull
Set<Status> getStatus();
/**
* Gets if the result includes a certain status code.
*
* @param status the status to check for
* @return if the result includes the status
*/
boolean includes(@Nonnull Status status);
/**
* Gets the old username involved in the result
*
* @return the old username
* @see Status#USERNAME_UPDATED
*/
@Nullable
String getOldUsername();
/**
* Gets the other uuids involved in the result
*
* @return the other uuids
* @see Status#OTHER_UUIDS_PRESENT_FOR_USERNAME
*/
@Nullable
Set<UUID> getOtherUuids();
/**
* The various states the result can take
*/
enum Status {
/**
* There was no existing data saved for either the uuid or username
*/
CLEAN_INSERT,
/**
* There was existing data for the player, no change was needed.
*/
NO_CHANGE,
/**
* There was already a record for the UUID saved, but it was for a different username.
*
* <p>This is normal, players are able to change their usernames.</p>
*/
USERNAME_UPDATED,
/**
* There was already a record for the username saved, but it was under a different uuid.
*
* <p>This is a bit of a cause for concern. It's possible that "player1" has changed
* their username to "player2", and "player3" has changed their username to "player1".
* If the original "player1" doesn't join after changing their name, this conflict could
* occur.</p>
*
* <p>However, what's more likely is that the server is not setup to authenticate
* correctly. Usually this is a problem with BungeeCord "ip-forwarding", but could be
* that the user of the plugin is running a network off a shared database with one
* server in online mode and another in offline mode.</p>
*/
OTHER_UUIDS_PRESENT_FOR_USERNAME,
}
}
@@ -34,7 +34,6 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -42,16 +41,6 @@ import javax.annotation.Nullable;
/**
* A means of loading and saving permission data to/from the backend.
*
* <p>All blocking methods return {@link CompletableFuture}s, which will be
* populated with the result once the data has been loaded/saved asynchronously.
* Care should be taken when using such methods to ensure that the main server
* thread is not blocked.</p>
*
* <p>Methods such as {@link CompletableFuture#get()} and equivalent should
* <strong>not</strong> be called on the main server thread. If you need to use
* the result of these operations on the main server thread, register a
* callback using {@link CompletableFuture#thenAcceptAsync(Consumer, Executor)}.</p>
*
* @since 2.14
*/
public interface Storage {
@@ -64,80 +53,6 @@ public interface Storage {
@Nonnull
String getName();
/**
* Loads and returns the entire log from storage
*
* @return a log instance, could be null if loading failed
*/
@Nonnull
CompletableFuture<Log> getLog();
/**
* Gets a set all "unique" user UUIDs.
*
* <p>"Unique" meaning the user isn't just a member of the "default" group.</p>
*
* @return a set of uuids, or null if the operation failed.
*/
@Nonnull
CompletableFuture<Set<UUID>> getUniqueUsers();
/**
* Searches for a list of users with a given permission.
*
* @param permission the permission to search for
* @return a list of held permissions, or null if the operation failed
* @throws NullPointerException if the permission is null
* @since 2.17
*/
@Nonnull
CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@Nonnull String permission);
/**
* Searches for a list of groups with a given permission.
*
* @param permission the permission to search for
* @return a list of held permissions, or null if the operation failed
* @throws NullPointerException if the permission is null
* @since 2.17
*/
@Nonnull
CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@Nonnull String permission);
/**
* Saves UUID caching data to the global cache
*
* @param username the users username
* @param uuid the users mojang unique id
* @return true if the operation completed successfully.
* @throws NullPointerException if either parameters are null
* @throws IllegalArgumentException if the username is invalid
*/
@Nonnull
CompletableFuture<Boolean> saveUUIDData(@Nonnull String username, @Nonnull UUID uuid);
/**
* Gets a UUID from a username
*
* @param username the corresponding username
* @return a uuid object, could be null
* @throws NullPointerException if either parameters are null
* @throws IllegalArgumentException if the username is invalid
*/
@Nonnull
CompletableFuture<UUID> getUUID(@Nonnull String username);
/**
* Gets a username from a UUID
*
* @param uuid the corresponding uuid
* @return a name string, could be null
* @throws NullPointerException if either parameters are null
* @since 2.17
*/
@Nonnull
CompletableFuture<String> getName(@Nonnull UUID uuid);
/**
* Gets whether the storage instance is allowing logins on the platform.
*
@@ -147,34 +62,6 @@ public interface Storage {
@Deprecated
boolean isAcceptingLogins();
/**
* Returns an executor which will run all passed runnables on the
* main server thread.
*
* <p>This method is deprecated as plugins should create and use their own
* executor instances.</p>
*
* @return an executor instance
* @deprecated as plugins should create their own executors
*/
@Nonnull
@Deprecated
Executor getSyncExecutor();
/**
* Returns an executor which will run all passed runnables asynchronously
* using the platforms scheduler and thread pools.
*
* <p>This method is deprecated as plugins should create and use their own
* executor instances.</p>
*
* @return an executor instance
* @deprecated as plugins should create their own executors
*/
@Nonnull
@Deprecated
Executor getAsyncExecutor();
/**
* Saves an action to storage
*
@@ -187,6 +74,16 @@ public interface Storage {
@Deprecated
CompletableFuture<Boolean> logAction(@Nonnull LogEntry entry);
/**
* Loads and returns the entire log from storage
*
* @return a log instance, could be null if loading failed
* @deprecated in favour of {@link ActionLogger#getLog()}
*/
@Nonnull
@Deprecated
CompletableFuture<Log> getLog();
/**
* Loads a user's data from the main storage into the plugins local storage.
*
@@ -229,6 +126,31 @@ public interface Storage {
@Deprecated
CompletableFuture<Boolean> saveUser(@Nonnull User user);
/**
* Gets a set all "unique" user UUIDs.
*
* <p>"Unique" meaning the user isn't just a member of the "default" group.</p>
*
* @return a set of uuids, or null if the operation failed.
* @deprecated in favour of {@link UserManager#getUniqueUsers()}
*/
@Nonnull
@Deprecated
CompletableFuture<Set<UUID>> getUniqueUsers();
/**
* Searches for a list of users with a given permission.
*
* @param permission the permission to search for
* @return a list of held permissions, or null if the operation failed
* @throws NullPointerException if the permission is null
* @since 2.17
* @deprecated in favour of {@link UserManager#getWithPermission(String)}
*/
@Nonnull
@Deprecated
CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@Nonnull String permission);
/**
* Creates and loads a group into the plugins local storage
*
@@ -293,6 +215,19 @@ public interface Storage {
@Deprecated
CompletableFuture<Boolean> deleteGroup(@Nonnull Group group);
/**
* Searches for a list of groups with a given permission.
*
* @param permission the permission to search for
* @return a list of held permissions, or null if the operation failed
* @throws NullPointerException if the permission is null
* @since 2.17
* @deprecated in favour of {@link GroupManager#getWithPermission(String)}
*/
@Nonnull
@Deprecated
CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@Nonnull String permission);
/**
* Creates and loads a track into the plugins local storage
*
@@ -355,4 +290,70 @@ public interface Storage {
@Deprecated
CompletableFuture<Boolean> deleteTrack(@Nonnull Track track);
/**
* Saves UUID caching data to the global cache
*
* @param username the users username
* @param uuid the users mojang unique id
* @return true if the operation completed successfully.
* @throws NullPointerException if either parameters are null
* @throws IllegalArgumentException if the username is invalid
* @deprecated in favour of {@link UserManager#savePlayerData(UUID, String)}
*/
@Nonnull
CompletableFuture<Boolean> saveUUIDData(@Nonnull String username, @Nonnull UUID uuid);
/**
* Gets a UUID from a username
*
* @param username the corresponding username
* @return a uuid object, could be null
* @throws NullPointerException if either parameters are null
* @throws IllegalArgumentException if the username is invalid
* @deprecated in favour of {@link UserManager#lookupUuid(String)}
*/
@Nonnull
CompletableFuture<UUID> getUUID(@Nonnull String username);
/**
* Gets a username from a UUID
*
* @param uuid the corresponding uuid
* @return a name string, could be null
* @throws NullPointerException if either parameters are null
* @since 2.17
* @deprecated in favour of {@link UserManager#lookupUsername(UUID)}
*/
@Nonnull
@Deprecated
CompletableFuture<String> getName(@Nonnull UUID uuid);
/**
* Returns an executor which will run all passed runnables on the
* main server thread.
*
* <p>This method is deprecated as plugins should create and use their own
* executor instances.</p>
*
* @return an executor instance
* @deprecated as plugins should create their own executors
*/
@Nonnull
@Deprecated
Executor getSyncExecutor();
/**
* Returns an executor which will run all passed runnables asynchronously
* using the platforms scheduler and thread pools.
*
* <p>This method is deprecated as plugins should create and use their own
* executor instances.</p>
*
* @return an executor instance
* @deprecated as plugins should create their own executors
*/
@Nonnull
@Deprecated
Executor getAsyncExecutor();
}
@@ -401,6 +401,20 @@ public interface CachedData {
*/
void invalidateMeta(@Nonnull Contexts contexts);
/**
* Invalidates all cached {@link PermissionData} instances.
*
* @since 4.2
*/
void invalidatePermissions();
/**
* Invalidates all cached {@link MetaData} instances.
*
* @since 4.2
*/
void invalidateMeta();
/**
* Invalidates all of the underlying Permission calculators.
*
@@ -26,11 +26,15 @@
package me.lucko.luckperms.api.manager;
import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.Storage;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -38,6 +42,16 @@ import javax.annotation.Nullable;
/**
* Represents the object responsible for managing {@link Group} instances.
*
* <p>All blocking methods return {@link CompletableFuture}s, which will be
* populated with the result once the data has been loaded/saved asynchronously.
* Care should be taken when using such methods to ensure that the main server
* thread is not blocked.</p>
*
* <p>Methods such as {@link CompletableFuture#get()} and equivalent should
* <strong>not</strong> be called on the main server thread. If you need to use
* the result of these operations on the main server thread, register a
* callback using {@link CompletableFuture#thenAcceptAsync(Consumer, Executor)}.</p>
*
* @since 4.0
*/
public interface GroupManager {
@@ -138,6 +152,17 @@ public interface GroupManager {
@Nonnull
CompletableFuture<Void> loadAllGroups();
/**
* Searches for a list of groups with a given permission.
*
* @param permission the permission to search for
* @return a list of held permissions, or null if the operation failed
* @throws NullPointerException if the permission is null
* @since 4.2
*/
@Nonnull
CompletableFuture<List<HeldPermission<String>>> getWithPermission(@Nonnull String permission);
/**
* Gets a loaded group.
*
@@ -31,6 +31,8 @@ import me.lucko.luckperms.api.Track;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -38,6 +40,16 @@ import javax.annotation.Nullable;
/**
* Represents the object responsible for managing {@link Track} instances.
*
* <p>All blocking methods return {@link CompletableFuture}s, which will be
* populated with the result once the data has been loaded/saved asynchronously.
* Care should be taken when using such methods to ensure that the main server
* thread is not blocked.</p>
*
* <p>Methods such as {@link CompletableFuture#get()} and equivalent should
* <strong>not</strong> be called on the main server thread. If you need to use
* the result of these operations on the main server thread, register a
* callback using {@link CompletableFuture#thenAcceptAsync(Consumer, Executor)}.</p>
*
* @since 4.0
*/
public interface TrackManager {
@@ -25,13 +25,18 @@
package me.lucko.luckperms.api.manager;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.PlayerSaveResult;
import me.lucko.luckperms.api.Storage;
import me.lucko.luckperms.api.User;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -42,6 +47,16 @@ import javax.annotation.Nullable;
* <p>Note that User instances are automatically loaded for online players.
* It's likely that offline players will not have an instance pre-loaded.</p>
*
* <p>All blocking methods return {@link CompletableFuture}s, which will be
* populated with the result once the data has been loaded/saved asynchronously.
* Care should be taken when using such methods to ensure that the main server
* thread is not blocked.</p>
*
* <p>Methods such as {@link CompletableFuture#get()} and equivalent should
* <strong>not</strong> be called on the main server thread. If you need to use
* the result of these operations on the main server thread, register a
* callback using {@link CompletableFuture#thenAcceptAsync(Consumer, Executor)}.</p>
*
* @since 4.0
*/
public interface UserManager {
@@ -85,6 +100,32 @@ public interface UserManager {
return loadUser(uuid, null);
}
/**
* Uses the LuckPerms cache to find a uuid for the given username.
*
* <p>This lookup is case insensitive.</p>
*
* @param username the username
* @return a uuid, could be null
* @throws NullPointerException if either parameters are null
* @throws IllegalArgumentException if the username is invalid
* @since 4.2
*/
@Nonnull
CompletableFuture<UUID> lookupUuid(@Nonnull String username);
/**
* Uses the LuckPerms cache to find a username for the given uuid.
*
* @param uuid the uuid
* @return a username, could be null
* @throws NullPointerException if either parameters are null
* @throws IllegalArgumentException if the username is invalid
* @since 4.2
*/
@Nonnull
CompletableFuture<String> lookupUsername(@Nonnull UUID uuid);
/**
* Saves a user's data back to the plugin's storage provider.
*
@@ -105,6 +146,41 @@ public interface UserManager {
@Nonnull
CompletableFuture<Void> saveUser(@Nonnull User user);
/**
* Saves data about a player to the uuid caching system.
*
* @param uuid the users mojang unique id
* @param username the users username
* @return the result of the operation.
* @throws NullPointerException if either parameters are null
* @throws IllegalArgumentException if the username is invalid
* @since 4.2
*/
@Nonnull
CompletableFuture<PlayerSaveResult> savePlayerData(@Nonnull UUID uuid, @Nonnull String username);
/**
* Gets a set all "unique" user UUIDs.
*
* <p>"Unique" meaning the user isn't just a member of the "default" group.</p>
*
* @return a set of uuids
* @since 4.2
*/
@Nonnull
CompletableFuture<Set<UUID>> getUniqueUsers();
/**
* Searches for a list of users with a given permission.
*
* @param permission the permission to search for
* @return a list of held permissions
* @throws NullPointerException if the permission is null
* @since 4.2
*/
@Nonnull
CompletableFuture<List<HeldPermission<UUID>>> getWithPermission(@Nonnull String permission);
/**
* Gets a loaded user.
*