diff --git a/api/pom.xml b/api/pom.xml
index fed2c6af..046db07b 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -5,7 +5,7 @@
luckpermsme.lucko.luckperms
- 2.13-SNAPSHOT
+ 2.14-SNAPSHOT4.0.0
diff --git a/api/src/main/java/me/lucko/luckperms/api/Datastore.java b/api/src/main/java/me/lucko/luckperms/api/Datastore.java
index 92ff2cff..bed07544 100644
--- a/api/src/main/java/me/lucko/luckperms/api/Datastore.java
+++ b/api/src/main/java/me/lucko/luckperms/api/Datastore.java
@@ -29,226 +29,50 @@ import java.util.UUID;
/**
* Interface for the internal Datastore instance
+ * @deprecated as of version 2.14 in favour of {@link Storage}.
*/
-@SuppressWarnings("unused")
+@Deprecated
public interface Datastore {
String getName();
boolean isAcceptingLogins();
- /**
- * Gets the {@link Sync} interface.
- *
- * All operations through this interface are called immediately and in the same thread as they are called.
- * Datastore operations are thread blocking, and Sync operations should not be called on the main server thread.
- * @return the sync interface
- */
+ @Deprecated
Sync sync();
- /**
- * Gets the {@link Async} interface.
- *
- * All operations through this interface are called in a new, separate asynchronous thread.
- * When the operation is complete, the provided callback method is called, in applicable, in the main server thread.
- * @return the async interface
- */
+ @Deprecated
Async async();
- /**
- * Gets the {@link Future} interface.
- *
- * All operations through this interface are called in a new, separate asynchronous thread, similar to {@link Async}.
- * The only difference is that instead of providing a callback, a {@link java.util.concurrent.Future} is returned.
- * See the Oracle JavaDocs for usage of the Future class.
- * @return the future interface
- */
+ @Deprecated
Future future();
- /**
- * All operations through this interface are called immediately and in the same thread as they are called.
- * Datastore operations are thread blocking, and Sync operations should not be called on the main server thread.
- */
+ @Deprecated
interface Sync {
-
- /**
- * Saves an action to the datastore
- * @param entry the log entry to be saved
- * @return true if the operation completed successfully.
- * @throws NullPointerException if entry is null
- */
boolean logAction(LogEntry entry);
-
- /**
- * Loads and returns the log from the datastore
- * @return a log instance, could be null
- */
Log getLog();
-
- /**
- * Either loads or creates a user object, and loads it into the plugins internal storage
- * @param uuid the uuid of the user
- * @param username the users username. (if you want to specify null here, just input "null" as a string.)
- * @return true if the operation completed successfully.
- * @throws NullPointerException if uuid or username is null
- * @throws IllegalArgumentException if either of the parameters are invalid
- * @deprecated functionality of this method is taken on by {@link #loadUser(UUID, String)}
- */
@Deprecated
boolean loadOrCreateUser(UUID uuid, String username);
-
- /**
- * Loads a user from the datastore into the plugins internal storage.
- * @param uuid the uuid of the user to load
- * @return true if the user exists, and was loaded correctly.
- * @throws NullPointerException if uuid is null
- * @deprecated replaced by {@link #loadUser(UUID, String)}
- */
@Deprecated
boolean loadUser(UUID uuid);
-
- /**
- * Loads a user's data into the plugins internal storage.
- * @param uuid the uuid of the user to load
- * @param username the users username. (if you want to specify null here, just input "null" as a string.)
- * @return if the operation was performed successfully
- * @throws NullPointerException if uuid or username is null
- * @since 2.6
- */
boolean loadUser(UUID uuid, String username);
-
- /**
- * Saves a user object into the datastore. You should call this after you make any changes to a user.
- * @param user the user to save
- * @return true if the operation completed successfully.
- * @throws NullPointerException if user is null
- * @throws IllegalStateException if the user instance was not obtained from LuckPerms.
- */
boolean saveUser(User user);
-
- /**
- * Removes users from the datastore who are "default". This is called every time the plugin loads.
- * @return true if the operation completed successfully
- * @since 2.6
- */
boolean cleanupUsers();
-
- /**
- * Gets a set all user's UUIDs who are "unique", and aren't just a member of the "default" group.
- * @return a set of uuids, or null if the operation failed.
- * @since 2.6
- */
Set getUniqueUsers();
-
- /**
- * Creates and loads a group into the plugins internal storage
- * @param name the name of the group
- * @return true if the operation completed successfully
- * @throws NullPointerException if name is null
- * @throws IllegalArgumentException if the name is invalid
- */
boolean createAndLoadGroup(String name);
-
- /**
- * Loads a group into the plugins internal storage.
- * @param name the name of the group
- * @return true if the operation completed successfully
- * @throws NullPointerException if name is null
- * @throws IllegalArgumentException if the name is invalid
- */
boolean loadGroup(String name);
-
- /**
- * Loads all groups from the datastore into the plugins internal storage
- * @return true if the operation completed successfully.
- */
boolean loadAllGroups();
-
- /**
- * Saves a group back to the datastore. You should call this after you make any changes to a group.
- * @param group the group to save
- * @return true if the operation completed successfully.
- * @throws NullPointerException if group is null
- * @throws IllegalStateException if the group instance was not obtained from LuckPerms.
- */
boolean saveGroup(Group group);
-
- /**
- * Permanently deletes a group from the datastore
- * @param group the group to delete
- * @return true if the operation completed successfully.
- * @throws NullPointerException if group is null
- * @throws IllegalStateException if the group instance was not obtained from LuckPerms.
- */
boolean deleteGroup(Group group);
-
- /**
- * Creates and loads a track into the plugins internal storage
- * @param name the name of the track
- * @return true if the operation completed successfully
- * @throws NullPointerException if name is null
- * @throws IllegalArgumentException if the name is invalid
- */
boolean createAndLoadTrack(String name);
-
- /**
- * Loads a track into the plugins internal storage.
- * @param name the name of the track
- * @return true if the operation completed successfully
- * @throws NullPointerException if name is null
- * @throws IllegalArgumentException if the name is invalid
- */
boolean loadTrack(String name);
-
- /**
- * Loads all tracks from the datastore into the plugins internal storage
- * @return true if the operation completed successfully.
- */
boolean loadAllTracks();
-
- /**
- * Saves a track back to the datastore. You should call this after you make any changes to a track.
- * @param track the track to save
- * @return true if the operation completed successfully.
- * @throws NullPointerException if track is null
- * @throws IllegalStateException if the track instance was not obtained from LuckPerms.
- */
boolean saveTrack(Track track);
-
- /**
- * Permanently deletes a track from the datastore
- * @param track the track to delete
- * @return true if the operation completed successfully.
- * @throws NullPointerException if track is null
- * @throws IllegalStateException if the track instance was not obtained from LuckPerms.
- */
boolean deleteTrack(Track track);
-
- /**
- * Saves UUID caching data to the datastore
- * @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
- */
boolean saveUUIDData(String username, 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
- */
UUID getUUID(String username);
}
- /**
- * All operations through this interface are called in a new, separate asynchronous thread.
- * When the operation is complete, the provided callback method is called, in applicable, in the main server thread.
- *
- * See {@link Sync} for method documentation.
- */
+ @Deprecated
interface Async {
void logAction(LogEntry entry, Callback callback);
void getLog(Callback callback);
@@ -274,13 +98,7 @@ public interface Datastore {
void getUUID(String username, Callback callback);
}
- /**
- * All operations through this interface are called in a new, separate asynchronous thread, similar to {@link Async}.
- * The only difference is that instead of providing a callback, a {@link java.util.concurrent.Future} is returned.
- * See the Oracle JavaDocs for usage of the Future class.
- *
- * See {@link Sync} for method documentation.
- */
+ @Deprecated
interface Future {
java.util.concurrent.Future logAction(LogEntry entry);
java.util.concurrent.Future getLog();
diff --git a/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java b/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java
index f73b584f..74737019 100644
--- a/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java
+++ b/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java
@@ -109,7 +109,9 @@ public interface LPConfiguration {
/**
* @return true if permission checks are being recorded / debugged
* @since 2.9
+ * @deprecated as this value is now always false. Functionality was replaced by the verbose command.
*/
+ @Deprecated
boolean getDebugPermissionChecks();
/**
diff --git a/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java b/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java
index 10692175..521dc12a 100644
--- a/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java
+++ b/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java
@@ -79,11 +79,27 @@ public interface LuckPermsApi {
LPConfiguration getConfiguration();
/**
- * Gets a wrapped {@link Datastore} instance, with somewhat limited access
- * @return a datastore instance
+ * Gets a wrapped {@link Storage} instance.
+ * @return a storage instance
+ * @since 2.14
*/
+ Storage getStorage();
+
+ /**
+ * Gets a wrapped Datastore instance.
+ * @return a datastore instance
+ * @deprecated in favour of {@link #getStorage()}
+ */
+ @SuppressWarnings("deprecation")
+ @Deprecated
Datastore getDatastore();
+ /**
+ * Gets the messaging service in use on the platform, if present.
+ * @return an optional that may contain a messaging service instance.
+ */
+ Optional getMessagingService();
+
/**
* Gets the {@link Logger} wrapping used by the platform
* @return the logger instance
@@ -92,7 +108,7 @@ public interface LuckPermsApi {
/**
* Gets a wrapped {@link UuidCache} instance, providing read access to the LuckPerms internal uuid caching system
- * @return a uuidcache instance
+ * @return a uuid cache instance
*/
UuidCache getUuidCache();
diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/LPFuture.java b/api/src/main/java/me/lucko/luckperms/api/MessagingService.java
similarity index 75%
rename from common/src/main/java/me/lucko/luckperms/common/utils/LPFuture.java
rename to api/src/main/java/me/lucko/luckperms/api/MessagingService.java
index d658486c..7ab870ab 100644
--- a/common/src/main/java/me/lucko/luckperms/common/utils/LPFuture.java
+++ b/api/src/main/java/me/lucko/luckperms/api/MessagingService.java
@@ -20,16 +20,18 @@
* SOFTWARE.
*/
-package me.lucko.luckperms.common.utils;
+package me.lucko.luckperms.api;
-import com.google.common.util.concurrent.Futures;
+/**
+ * Exposes any networking provider being used on the platform. e.g. Redis
+ * @since 2.14
+ */
+public interface MessagingService {
-import java.util.concurrent.Future;
-
-public interface LPFuture extends Future {
-
- default T getUnchecked() {
- return Futures.getUnchecked(this);
- }
+ /**
+ * Uses the messaging service to inform other servers about changes.
+ * This will push the update asynchronously, and this method will return almost immediately.
+ */
+ void pushUpdate();
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/Storage.java b/api/src/main/java/me/lucko/luckperms/api/Storage.java
new file mode 100644
index 00000000..d9b0978c
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/Storage.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * 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 java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor;
+import java.util.function.Consumer;
+
+/**
+ * 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
+ * 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 not be called on the main server thread.
+ * If you need to use the result of these operations on the main server thread, please register a callback using
+ * {@link CompletableFuture#thenAcceptAsync(Consumer, Executor)} and {@link #getSyncExecutor()}.
+ *
+ * @since 2.14
+ */
+public interface Storage {
+
+ /**
+ * Get the name of the storage implementation.
+ * @return the name of the implementation
+ */
+ String getName();
+
+ /**
+ * Return whether the storage instance is allowing logins on the platform.
+ * @return true if logins are enabled
+ */
+ boolean isAcceptingLogins();
+
+ /**
+ * Returns an executor which will run all passed runnables on the main server thread.
+ * @return an executor instance
+ */
+ Executor getSyncExecutor();
+
+ /**
+ * Returns an executor which will run all passed runnables asynchronously using the platforms scheduler & thread pools.
+ * @return an executor instance
+ */
+ Executor getAsyncExecutor();
+
+ /**
+ * Saves an action to storage
+ * @param entry the log entry to be saved
+ * @return true if the operation completed successfully.
+ * @throws NullPointerException if entry is null
+ */
+ CompletableFuture logAction(LogEntry entry);
+
+ /**
+ * Loads and returns the entire log from storage
+ * @return a log instance, could be null if loading failed
+ */
+ CompletableFuture getLog();
+
+ /**
+ * Loads a user's data from the main storage into the plugins local storage.
+ * @param uuid the uuid of the user to load
+ * @param username the users username. (if you want to specify null here, just input "null" as a string.)
+ * @return if the operation completed successfully
+ * @throws NullPointerException if uuid or username is null
+ */
+ CompletableFuture loadUser(UUID uuid, String username);
+
+ /**
+ * 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
+ * @return true if the operation completed successfully.
+ * @throws NullPointerException if user is null
+ * @throws IllegalStateException if the user instance was not obtained from LuckPerms.
+ */
+ CompletableFuture saveUser(User user);
+
+ /**
+ * Removes users from the main storage who are "default". This is called every time the plugin loads.
+ * @return true if the operation completed successfully
+ */
+ CompletableFuture cleanupUsers();
+
+ /**
+ * Gets a set all "unique" user UUIDs.
+ * "Unique" meaning the user isn't just a member of the "default" group.
+ * @return a set of uuids, or null if the operation failed.
+ */
+ CompletableFuture> getUniqueUsers();
+
+ /**
+ * Creates and loads a group into the plugins local storage
+ * @param name the name of the group
+ * @return true if the operation completed successfully
+ * @throws NullPointerException if name is null
+ * @throws IllegalArgumentException if the name is invalid
+ */
+ CompletableFuture createAndLoadGroup(String name);
+
+ /**
+ * Loads a group into the plugins local storage.
+ * @param name the name of the group
+ * @return true if the operation completed successfully
+ * @throws NullPointerException if name is null
+ * @throws IllegalArgumentException if the name is invalid
+ */
+ CompletableFuture loadGroup(String name);
+
+ /**
+ * Loads all groups from the storage into memory
+ * @return true if the operation completed successfully.
+ */
+ CompletableFuture loadAllGroups();
+
+ /**
+ * Saves a group back to storage. You should call this after you make any changes to a group.
+ * @param group the group to save
+ * @return true if the operation completed successfully.
+ * @throws NullPointerException if group is null
+ * @throws IllegalStateException if the group instance was not obtained from LuckPerms.
+ */
+ CompletableFuture saveGroup(Group group);
+
+ /**
+ * Permanently deletes a group from storage.
+ * @param group the group to delete
+ * @return true if the operation completed successfully.
+ * @throws NullPointerException if group is null
+ * @throws IllegalStateException if the group instance was not obtained from LuckPerms.
+ */
+ CompletableFuture deleteGroup(Group group);
+
+ /**
+ * Creates and loads a track into the plugins local storage
+ * @param name the name of the track
+ * @return true if the operation completed successfully
+ * @throws NullPointerException if name is null
+ * @throws IllegalArgumentException if the name is invalid
+ */
+ CompletableFuture createAndLoadTrack(String name);
+
+ /**
+ * Loads a track into the plugins local storage.
+ * @param name the name of the track
+ * @return true if the operation completed successfully
+ * @throws NullPointerException if name is null
+ * @throws IllegalArgumentException if the name is invalid
+ */
+ CompletableFuture loadTrack(String name);
+
+ /**
+ * Loads all tracks from the storage into memory
+ * @return true if the operation completed successfully.
+ */
+ CompletableFuture loadAllTracks();
+
+ /**
+ * Saves a track back to storage. You should call this after you make any changes to a track.
+ * @param track the track to save
+ * @return true if the operation completed successfully.
+ * @throws NullPointerException if track is null
+ * @throws IllegalStateException if the track instance was not obtained from LuckPerms.
+ */
+ CompletableFuture saveTrack(Track track);
+
+ /**
+ * Permanently deletes a track from storage
+ * @param track the track to delete
+ * @return true if the operation completed successfully.
+ * @throws NullPointerException if track is null
+ * @throws IllegalStateException if the track instance was not obtained from LuckPerms.
+ */
+ CompletableFuture deleteTrack(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
+ */
+ CompletableFuture saveUUIDData(String username, 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
+ */
+ CompletableFuture getUUID(String username);
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/UuidCache.java b/api/src/main/java/me/lucko/luckperms/api/UuidCache.java
index 9b6756cf..e093837e 100644
--- a/api/src/main/java/me/lucko/luckperms/api/UuidCache.java
+++ b/api/src/main/java/me/lucko/luckperms/api/UuidCache.java
@@ -32,8 +32,8 @@ import java.util.UUID;
* they first join the server, but this UUID will then not be consistent across the network. LuckPerms will instead check
* the datastore cache, to get a UUID for a user that is consistent across an entire network.
*
- *
If you want to get a user object from the datastore using the api on a server in offline mode, you will need to use this cache,
- * OR use Datastore#getUUID, for users that are not online.
+ *
If you want to get a user object from the Storage using the api on a server in offline mode, you will need to use this cache,
+ * OR use Storage#getUUID, for users that are not online.
*
*
WARNING: THIS IS ONLY EFFECTIVE FOR ONLINE PLAYERS. USE THE DATASTORE METHODS FOR OFFLINE PLAYERS.
*/
diff --git a/api/src/main/java/me/lucko/luckperms/api/data/Callback.java b/api/src/main/java/me/lucko/luckperms/api/data/Callback.java
index 5a4f5dcd..6e0dac63 100644
--- a/api/src/main/java/me/lucko/luckperms/api/data/Callback.java
+++ b/api/src/main/java/me/lucko/luckperms/api/data/Callback.java
@@ -28,7 +28,9 @@ import java.util.function.Consumer;
* A callback used to wait for the completion of asynchronous operations.
* All callbacks are ran on the main server thread.
* @param the return type
+ * @deprecated in favour of {@link Consumer}
*/
+@Deprecated
public interface Callback {
/**
@@ -55,4 +57,17 @@ public interface Callback {
return consumer::accept;
}
+ /**
+ * 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 the return type
+ * @return a consumer instance
+ * @since 2.14
+ * @deprecated in favour of just using {@link Consumer}s.
+ */
+ @Deprecated
+ static Consumer convertToConsumer(Callback callback) {
+ return callback::onComplete;
+ }
+
}
diff --git a/bukkit-legacy/pom.xml b/bukkit-legacy/pom.xml
index 6bc6e8c9..a34b02d2 100644
--- a/bukkit-legacy/pom.xml
+++ b/bukkit-legacy/pom.xml
@@ -5,7 +5,7 @@
luckpermsme.lucko.luckperms
- 2.13-SNAPSHOT
+ 2.14-SNAPSHOT4.0.0
diff --git a/bukkit-placeholders/pom.xml b/bukkit-placeholders/pom.xml
index 722a1a66..27a0133e 100644
--- a/bukkit-placeholders/pom.xml
+++ b/bukkit-placeholders/pom.xml
@@ -5,7 +5,7 @@
luckpermsme.lucko.luckperms
- 2.13-SNAPSHOT
+ 2.14-SNAPSHOT4.0.0
diff --git a/bukkit/pom.xml b/bukkit/pom.xml
index 14a8cbc4..e18b8ace 100644
--- a/bukkit/pom.xml
+++ b/bukkit/pom.xml
@@ -5,7 +5,7 @@
luckpermsme.lucko.luckperms
- 2.13-SNAPSHOT
+ 2.14-SNAPSHOT4.0.0
diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitListener.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitListener.java
index c6879548..bf5f1b72 100644
--- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitListener.java
+++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitListener.java
@@ -48,7 +48,7 @@ class BukkitListener extends AbstractListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent e) {
- if (!plugin.isStarted() || !plugin.getDatastore().isAcceptingLogins()) {
+ if (!plugin.isStarted() || !plugin.getStorage().isAcceptingLogins()) {
// The datastore is disabled, prevent players from joining the server
e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, Message.LOADING_ERROR.toString());
@@ -61,7 +61,7 @@ class BukkitListener extends AbstractListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerPreLoginMonitor(AsyncPlayerPreLoginEvent e) {
- if (plugin.isStarted() && plugin.getDatastore().isAcceptingLogins() && e.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
+ if (plugin.isStarted() && plugin.getStorage().isAcceptingLogins() && e.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
// Login event was cancelled by another plugin
onLeave(e.getUniqueId());
diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java
index e6419b08..3ec569c1 100644
--- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java
+++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java
@@ -49,7 +49,7 @@ import me.lucko.luckperms.common.groups.GroupManager;
import me.lucko.luckperms.common.messaging.RedisMessaging;
import me.lucko.luckperms.common.runnables.ExpireTemporaryTask;
import me.lucko.luckperms.common.runnables.UpdateTask;
-import me.lucko.luckperms.common.storage.Datastore;
+import me.lucko.luckperms.common.storage.Storage;
import me.lucko.luckperms.common.storage.StorageFactory;
import me.lucko.luckperms.common.tracks.TrackManager;
import me.lucko.luckperms.common.users.UserManager;
@@ -68,12 +68,16 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
@Getter
public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
+ private ExecutorService executorService;
+ private Executor syncExecutor;
+ private Executor asyncExecutor;
private VaultHook vaultHook = null;
private final Set ignoringLogs = ConcurrentHashMap.newKeySet();
@@ -81,7 +85,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
private UserManager userManager;
private GroupManager groupManager;
private TrackManager trackManager;
- private Datastore datastore;
+ private Storage storage;
private RedisMessaging redisMessaging = null;
private UuidCache uuidCache;
private ApiProvider apiProvider;
@@ -99,13 +103,12 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
private DebugHandler debugHandler;
private BukkitSenderFactory senderFactory;
- private ExecutorService executorService;
- private boolean schedulerAvailable = false;
-
@Override
public void onEnable() {
// Used whilst the server is still starting
executorService = Executors.newCachedThreadPool();
+ asyncExecutor = executorService;
+ syncExecutor = r -> getServer().getScheduler().runTask(this, r);
log = LogFactory.wrap(getLogger());
debugHandler = new DebugHandler();
@@ -129,7 +132,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
pm.registerEvents(new BukkitListener(this), this);
// initialise datastore
- datastore = StorageFactory.getDatastore(this, "h2");
+ storage = StorageFactory.getInstance(this, "h2");
// initialise redis
if (getConfiguration().isRedisEnabled()) {
@@ -236,10 +239,9 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
getServer().getOperators().forEach(o -> o.setOp(false));
}
- // shutdown the temporary executor when the Bukkit one starts
+ // replace the temporary executor when the Bukkit one starts
getServer().getScheduler().runTaskAsynchronously(this, () -> {
- schedulerAvailable = true;
- executorService.shutdown();
+ asyncExecutor = r -> getServer().getScheduler().runTaskAsynchronously(this, r);
});
started = true;
@@ -250,7 +252,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
public void onDisable() {
started = false;
getLog().info("Closing datastore...");
- datastore.shutdown();
+ storage.shutdown();
if (redisMessaging != null) {
getLog().info("Closing redis...");
@@ -268,16 +270,12 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
@Override
public void doAsync(Runnable r) {
- if (!schedulerAvailable) {
- executorService.submit(r);
- } else {
- getServer().getScheduler().runTaskAsynchronously(this, r);
- }
+ asyncExecutor.execute(r);
}
@Override
public void doSync(Runnable r) {
- getServer().getScheduler().runTask(this, r);
+ syncExecutor.execute(r);
}
@Override
diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java
index c0ac3bcc..47aeb360 100644
--- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java
+++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java
@@ -122,7 +122,7 @@ public class MigrationBPermissions extends SubCommand