mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-08-30 07:59:34 +02:00
Return the loaded objects from storage methods as opposed to success flags
This commit is contained in:
parent
765f140121
commit
a415a2705f
|
@ -44,17 +44,18 @@ public enum ChatMetaType {
|
|||
*/
|
||||
PREFIX {
|
||||
@Override
|
||||
public boolean matches(Node node) {
|
||||
public boolean matches(@Nonnull Node node) {
|
||||
return Preconditions.checkNotNull(node, "node").isPrefix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldIgnore(Node node) {
|
||||
public boolean shouldIgnore(@Nonnull Node node) {
|
||||
return !Preconditions.checkNotNull(node, "node").isPrefix();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Map.Entry<Integer, String> getEntry(Node node) {
|
||||
public Map.Entry<Integer, String> getEntry(@Nonnull Node node) {
|
||||
return Preconditions.checkNotNull(node, "node").getPrefix();
|
||||
}
|
||||
},
|
||||
|
@ -64,17 +65,18 @@ public enum ChatMetaType {
|
|||
*/
|
||||
SUFFIX {
|
||||
@Override
|
||||
public boolean matches(Node node) {
|
||||
public boolean matches(@Nonnull Node node) {
|
||||
return Preconditions.checkNotNull(node, "node").isSuffix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldIgnore(Node node) {
|
||||
public boolean shouldIgnore(@Nonnull Node node) {
|
||||
return !Preconditions.checkNotNull(node, "node").isSuffix();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Map.Entry<Integer, String> getEntry(Node node) {
|
||||
public Map.Entry<Integer, String> getEntry(@Nonnull Node node) {
|
||||
return Preconditions.checkNotNull(node, "node").getSuffix();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -41,6 +41,8 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
|||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
@ -76,7 +78,7 @@ public class ApiStorage implements Storage {
|
|||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> logAction(@NonNull LogEntry entry) {
|
||||
return handle.noBuffer().logAction(entry);
|
||||
return handle.noBuffer().logAction(entry).thenApply(x -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,12 +88,12 @@ public class ApiStorage implements Storage {
|
|||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadUser(@NonNull UUID uuid, String username) {
|
||||
return handle.noBuffer().loadUser(uuid, username == null ? null : checkUsername(username));
|
||||
return handle.noBuffer().loadUser(uuid, username == null ? null : checkUsername(username)).thenApply(Objects::nonNull);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveUser(@NonNull User user) {
|
||||
return handle.noBuffer().saveUser(ApiUser.cast(user));
|
||||
return handle.noBuffer().saveUser(ApiUser.cast(user)).thenApply(x -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,22 +108,22 @@ public class ApiStorage implements Storage {
|
|||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> createAndLoadGroup(@NonNull String name) {
|
||||
return handle.noBuffer().createAndLoadGroup(checkName(name), CreationCause.API);
|
||||
return handle.noBuffer().createAndLoadGroup(checkName(name), CreationCause.API).thenApply(Objects::nonNull);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadGroup(@NonNull String name) {
|
||||
return handle.noBuffer().loadGroup(checkName(name));
|
||||
return handle.noBuffer().loadGroup(checkName(name)).thenApply(Optional::isPresent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadAllGroups() {
|
||||
return handle.noBuffer().loadAllGroups();
|
||||
return handle.noBuffer().loadAllGroups().thenApply(x -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveGroup(@NonNull Group group) {
|
||||
return handle.noBuffer().saveGroup(ApiGroup.cast(group));
|
||||
return handle.noBuffer().saveGroup(ApiGroup.cast(group)).thenApply(x -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -129,7 +131,7 @@ public class ApiStorage implements Storage {
|
|||
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().get(ConfigKeys.DEFAULT_GROUP_NAME))) {
|
||||
throw new IllegalArgumentException("Cannot delete the default group.");
|
||||
}
|
||||
return handle.noBuffer().deleteGroup(ApiGroup.cast(group), DeletionCause.API);
|
||||
return handle.noBuffer().deleteGroup(ApiGroup.cast(group), DeletionCause.API).thenApply(x -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,32 +141,32 @@ public class ApiStorage implements Storage {
|
|||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> createAndLoadTrack(@NonNull String name) {
|
||||
return handle.noBuffer().createAndLoadTrack(checkName(name), CreationCause.API);
|
||||
return handle.noBuffer().createAndLoadTrack(checkName(name), CreationCause.API).thenApply(Objects::nonNull);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadTrack(@NonNull String name) {
|
||||
return handle.noBuffer().loadTrack(checkName(name));
|
||||
return handle.noBuffer().loadTrack(checkName(name)).thenApply(Optional::isPresent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadAllTracks() {
|
||||
return handle.noBuffer().loadAllTracks();
|
||||
return handle.noBuffer().loadAllTracks().thenApply(x -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveTrack(@NonNull Track track) {
|
||||
return handle.noBuffer().saveTrack(ApiTrack.cast(track));
|
||||
return handle.noBuffer().saveTrack(ApiTrack.cast(track)).thenApply(x -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> deleteTrack(@NonNull Track track) {
|
||||
return handle.noBuffer().deleteTrack(ApiTrack.cast(track), DeletionCause.API);
|
||||
return handle.noBuffer().deleteTrack(ApiTrack.cast(track), DeletionCause.API).thenApply(x -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveUUIDData(@NonNull String username, @NonNull UUID uuid) {
|
||||
return handle.noBuffer().saveUUIDData(uuid, checkUsername(username));
|
||||
return handle.noBuffer().saveUUIDData(uuid, checkUsername(username)).thenApply(x -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -173,7 +173,13 @@ public abstract class SubCommand<T> extends Command<T, Void> {
|
|||
}
|
||||
|
||||
public static void save(User user, Sender sender, LuckPermsPlugin plugin) {
|
||||
boolean success = plugin.getStorage().noBuffer().saveUser(user).join();
|
||||
try {
|
||||
plugin.getStorage().noBuffer().saveUser(user).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.USER_SAVE_ERROR.send(sender, user.getFriendlyName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender.isImport()) {
|
||||
user.getRefreshBuffer().request();
|
||||
|
@ -187,14 +193,16 @@ public abstract class SubCommand<T> extends Command<T, Void> {
|
|||
messagingService.get().getUpdateBuffer().request();
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
Message.USER_SAVE_ERROR.send(sender, user.getFriendlyName());
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(Group group, Sender sender, LuckPermsPlugin plugin) {
|
||||
boolean success = plugin.getStorage().noBuffer().saveGroup(group).join();
|
||||
try {
|
||||
plugin.getStorage().noBuffer().saveGroup(group).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.GROUP_SAVE_ERROR.send(sender, group.getFriendlyName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender.isImport()) {
|
||||
plugin.getUpdateTaskBuffer().request();
|
||||
|
@ -208,14 +216,16 @@ public abstract class SubCommand<T> extends Command<T, Void> {
|
|||
messagingService.get().getUpdateBuffer().request();
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
Message.GROUP_SAVE_ERROR.send(sender, group.getFriendlyName());
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(Track track, Sender sender, LuckPermsPlugin plugin) {
|
||||
boolean success = plugin.getStorage().noBuffer().saveTrack(track).join();
|
||||
try {
|
||||
plugin.getStorage().noBuffer().saveTrack(track).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.TRACK_SAVE_ERROR.send(sender, track.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender.isImport()) {
|
||||
plugin.getUpdateTaskBuffer().request();
|
||||
|
@ -229,9 +239,5 @@ public abstract class SubCommand<T> extends Command<T, Void> {
|
|||
messagingService.get().getUpdateBuffer().request();
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
Message.TRACK_SAVE_ERROR.send(sender, track.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,10 @@ public class HolderShowTracks<T extends PermissionHolder> extends SubCommand<T>
|
|||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadAllTracks().join()) {
|
||||
try {
|
||||
plugin.getStorage().loadAllTracks().get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.TRACKS_LOAD_ERROR.send(sender);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ParentAdd extends SharedSubCommand {
|
|||
String groupName = ArgumentUtils.handleName(0, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join()) {
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ParentAddTemp extends SharedSubCommand {
|
|||
MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);
|
||||
TemporaryModifier modifier = plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR);
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join()) {
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ParentClearTrack extends SharedSubCommand {
|
|||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadTrack(trackName).join()) {
|
||||
if (!plugin.getStorage().loadTrack(trackName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ParentSet extends SharedSubCommand {
|
|||
String groupName = ArgumentUtils.handleName(0, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join()) {
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class ParentSetTrack extends SharedSubCommand {
|
|||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadTrack(trackName).join()) {
|
||||
if (!plugin.getStorage().loadTrack(trackName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class ParentSetTrack extends SharedSubCommand {
|
|||
|
||||
MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join()) {
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
|
|
@ -59,12 +59,15 @@ public class CreateGroup extends SingleCommand {
|
|||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (plugin.getStorage().loadGroup(groupName).join()) {
|
||||
if (plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.ALREADY_EXISTS.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().createAndLoadGroup(groupName, CreationCause.COMMAND).join()) {
|
||||
try {
|
||||
plugin.getStorage().createAndLoadGroup(groupName, CreationCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.CREATE_ERROR.send(sender, groupName);
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class DeleteGroup extends SingleCommand {
|
|||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join()) {
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
@ -73,7 +73,10 @@ public class DeleteGroup extends SingleCommand {
|
|||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().deleteGroup(group, DeletionCause.COMMAND).join()) {
|
||||
try {
|
||||
plugin.getStorage().deleteGroup(group, DeletionCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.DELETE_ERROR.send(sender, group.getFriendlyName());
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class GroupMainCommand extends MainCommand<Group, String> {
|
|||
|
||||
@Override
|
||||
protected Group getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||
if (!plugin.getStorage().loadGroup(target).join()) {
|
||||
if (!plugin.getStorage().loadGroup(target).join().isPresent()) {
|
||||
// failed to load, but it might be a display name.
|
||||
|
||||
// nope, not a display name
|
||||
|
|
|
@ -56,12 +56,15 @@ public class GroupRename extends SubCommand<Group> {
|
|||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (plugin.getStorage().loadGroup(newGroupName).join()) {
|
||||
if (plugin.getStorage().loadGroup(newGroupName).join().isPresent()) {
|
||||
Message.ALREADY_EXISTS.send(sender, newGroupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().createAndLoadGroup(newGroupName, CreationCause.COMMAND).join()) {
|
||||
try {
|
||||
plugin.getStorage().createAndLoadGroup(newGroupName, CreationCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.CREATE_ERROR.send(sender, newGroupName);
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
@ -72,7 +75,10 @@ public class GroupRename extends SubCommand<Group> {
|
|||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().deleteGroup(group, DeletionCause.COMMAND).join()) {
|
||||
try {
|
||||
plugin.getStorage().deleteGroup(group, DeletionCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.DELETE_ERROR.send(sender, group.getFriendlyName());
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,11 @@ public class ListGroups extends SingleCommand {
|
|||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
if (!plugin.getStorage().loadAllGroups().join()) {
|
||||
|
||||
try {
|
||||
plugin.getStorage().loadAllGroups().get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.GROUPS_LOAD_ERROR.send(sender);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
|
|
@ -72,11 +72,12 @@ public class BulkUpdateCommand extends SingleCommand {
|
|||
}
|
||||
|
||||
Message.BULK_UPDATE_STARTING.send(sender);
|
||||
plugin.getStorage().applyBulkUpdate(operation).thenAcceptAsync(b -> {
|
||||
if (b) {
|
||||
plugin.getStorage().applyBulkUpdate(operation).whenCompleteAsync((v, ex) -> {
|
||||
if (ex == null) {
|
||||
plugin.getUpdateTaskBuffer().requestDirectly();
|
||||
Message.BULK_UPDATE_SUCCESS.send(sender);
|
||||
} else {
|
||||
ex.printStackTrace();
|
||||
Message.BULK_UPDATE_FAILURE.send(sender);
|
||||
}
|
||||
}, plugin.getScheduler().async());
|
||||
|
|
|
@ -59,12 +59,15 @@ public class CreateTrack extends SingleCommand {
|
|||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (plugin.getStorage().loadTrack(trackName).join()) {
|
||||
if (plugin.getStorage().loadTrack(trackName).join().isPresent()) {
|
||||
Message.ALREADY_EXISTS.send(sender, trackName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().createAndLoadTrack(trackName, CreationCause.COMMAND).join()) {
|
||||
try {
|
||||
plugin.getStorage().createAndLoadTrack(trackName, CreationCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.CREATE_ERROR.send(sender, trackName);
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class DeleteTrack extends SingleCommand {
|
|||
}
|
||||
|
||||
String trackName = args.get(0).toLowerCase();
|
||||
if (!plugin.getStorage().loadTrack(trackName).join()) {
|
||||
if (!plugin.getStorage().loadTrack(trackName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
@ -66,7 +66,10 @@ public class DeleteTrack extends SingleCommand {
|
|||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().deleteTrack(track, DeletionCause.COMMAND).join()) {
|
||||
try {
|
||||
plugin.getStorage().deleteTrack(track, DeletionCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.DELETE_ERROR.send(sender, track.getName());
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,10 @@ public class ListTracks extends SingleCommand {
|
|||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
if (!plugin.getStorage().loadAllTracks().join()) {
|
||||
try {
|
||||
plugin.getStorage().loadAllTracks().get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.TRACKS_LOAD_ERROR.send(sender);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class TrackAppend extends SubCommand<Track> {
|
|||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join()) {
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class TrackInsert extends SubCommand<Track> {
|
|||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join()) {
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class TrackMainCommand extends MainCommand<Track, String> {
|
|||
|
||||
@Override
|
||||
protected Track getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||
if (!plugin.getStorage().loadTrack(target).join()) {
|
||||
if (!plugin.getStorage().loadTrack(target).join().isPresent()) {
|
||||
Message.TRACK_NOT_FOUND.send(sender, target);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -56,12 +56,15 @@ public class TrackRename extends SubCommand<Track> {
|
|||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (plugin.getStorage().loadTrack(newTrackName).join()) {
|
||||
if (plugin.getStorage().loadTrack(newTrackName).join().isPresent()) {
|
||||
Message.ALREADY_EXISTS.send(sender, newTrackName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().createAndLoadTrack(newTrackName, CreationCause.COMMAND).join()) {
|
||||
try {
|
||||
plugin.getStorage().createAndLoadTrack(newTrackName, CreationCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.CREATE_ERROR.send(sender, newTrackName);
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
@ -72,7 +75,10 @@ public class TrackRename extends SubCommand<Track> {
|
|||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().deleteTrack(track, DeletionCause.COMMAND).join()) {
|
||||
try {
|
||||
plugin.getStorage().deleteTrack(track, DeletionCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.DELETE_ERROR.send(sender, track.getName());
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class UserDemote extends SubCommand<User> {
|
|||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadTrack(trackName).join()) {
|
||||
if (!plugin.getStorage().loadTrack(trackName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ public class UserDemote extends SubCommand<User> {
|
|||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadGroup(previous).join()) {
|
||||
if (!plugin.getStorage().loadGroup(previous).join().isPresent()) {
|
||||
Message.USER_DEMOTE_ERROR_MALFORMED.send(sender, previous);
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
|
|
@ -118,7 +118,11 @@ public class UserMainCommand extends MainCommand<User, UserIdentifier> {
|
|||
|
||||
@Override
|
||||
protected User getTarget(UserIdentifier target, LuckPermsPlugin plugin, Sender sender) {
|
||||
if (!plugin.getStorage().loadUser(target.getUuid(), target.getUsername().orElse(null)).join()) {
|
||||
|
||||
try {
|
||||
plugin.getStorage().loadUser(target.getUuid(), target.getUsername().orElse(null)).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.LOADING_ERROR.send(sender);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class UserPromote extends SubCommand<User> {
|
|||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadTrack(trackName).join()) {
|
||||
if (!plugin.getStorage().loadTrack(trackName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class UserPromote extends SubCommand<User> {
|
|||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadGroup(next).join()) {
|
||||
if (!plugin.getStorage().loadGroup(next).join().isPresent()) {
|
||||
Message.USER_PROMOTE_ERROR_MALFORMED.send(sender, next);
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import me.lucko.luckperms.common.storage.wrappings.PhasedStorage;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
|
@ -88,6 +89,21 @@ public class AbstractStorage implements Storage {
|
|||
}, dao.getPlugin().getScheduler().async());
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> makeFuture(ThrowingRunnable runnable) {
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
runnable.run();
|
||||
} catch (Exception e) {
|
||||
Throwables.propagateIfPossible(e);
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
}, dao.getPlugin().getScheduler().async());
|
||||
}
|
||||
|
||||
private interface ThrowingRunnable {
|
||||
void run() throws Exception;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return dao.getName();
|
||||
|
@ -124,7 +140,7 @@ public class AbstractStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> logAction(LogEntry entry) {
|
||||
public CompletableFuture<Void> logAction(LogEntry entry) {
|
||||
return makeFuture(() -> dao.logAction(entry));
|
||||
}
|
||||
|
||||
|
@ -134,26 +150,23 @@ public class AbstractStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> applyBulkUpdate(BulkUpdate bulkUpdate) {
|
||||
public CompletableFuture<Void> applyBulkUpdate(BulkUpdate bulkUpdate) {
|
||||
return makeFuture(() -> dao.applyBulkUpdate(bulkUpdate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadUser(UUID uuid, String username) {
|
||||
public CompletableFuture<User> loadUser(UUID uuid, String username) {
|
||||
return makeFuture(() -> {
|
||||
if (dao.loadUser(uuid, username)) {
|
||||
User u = plugin.getUserManager().getIfLoaded(uuid);
|
||||
if (u != null) {
|
||||
plugin.getApiProvider().getEventFactory().handleUserLoad(u);
|
||||
}
|
||||
return true;
|
||||
User user = dao.loadUser(uuid, username);
|
||||
if (user != null) {
|
||||
plugin.getApiProvider().getEventFactory().handleUserLoad(user);
|
||||
}
|
||||
return false;
|
||||
return user;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveUser(User user) {
|
||||
public CompletableFuture<Void> saveUser(User user) {
|
||||
return makeFuture(() -> dao.saveUser(user));
|
||||
}
|
||||
|
||||
|
@ -168,57 +181,45 @@ public class AbstractStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> createAndLoadGroup(String name, CreationCause cause) {
|
||||
public CompletableFuture<Group> createAndLoadGroup(String name, CreationCause cause) {
|
||||
return makeFuture(() -> {
|
||||
if (dao.createAndLoadGroup(name)) {
|
||||
Group g = plugin.getGroupManager().getIfLoaded(name);
|
||||
if (g != null) {
|
||||
plugin.getApiProvider().getEventFactory().handleGroupCreate(g, cause);
|
||||
}
|
||||
return true;
|
||||
Group group = dao.createAndLoadGroup(name);
|
||||
if (group != null) {
|
||||
plugin.getApiProvider().getEventFactory().handleGroupCreate(group, cause);
|
||||
}
|
||||
return false;
|
||||
return group;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadGroup(String name) {
|
||||
public CompletableFuture<Optional<Group>> loadGroup(String name) {
|
||||
return makeFuture(() -> {
|
||||
if (dao.loadGroup(name)) {
|
||||
Group g = plugin.getGroupManager().getIfLoaded(name);
|
||||
if (g != null) {
|
||||
plugin.getApiProvider().getEventFactory().handleGroupLoad(g);
|
||||
}
|
||||
return true;
|
||||
Optional<Group> group = dao.loadGroup(name);
|
||||
if (group.isPresent()) {
|
||||
plugin.getApiProvider().getEventFactory().handleGroupLoad(group.get());
|
||||
}
|
||||
return false;
|
||||
return group;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadAllGroups() {
|
||||
public CompletableFuture<Void> loadAllGroups() {
|
||||
return makeFuture(() -> {
|
||||
if (dao.loadAllGroups()) {
|
||||
plugin.getApiProvider().getEventFactory().handleGroupLoadAll();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
dao.loadAllGroups();
|
||||
plugin.getApiProvider().getEventFactory().handleGroupLoadAll();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveGroup(Group group) {
|
||||
public CompletableFuture<Void> saveGroup(Group group) {
|
||||
return makeFuture(() -> dao.saveGroup(group));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> deleteGroup(Group group, DeletionCause cause) {
|
||||
public CompletableFuture<Void> deleteGroup(Group group, DeletionCause cause) {
|
||||
return makeFuture(() -> {
|
||||
if (dao.deleteGroup(group)) {
|
||||
plugin.getApiProvider().getEventFactory().handleGroupDelete(group, cause);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
dao.deleteGroup(group);
|
||||
plugin.getApiProvider().getEventFactory().handleGroupDelete(group, cause);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -228,62 +229,50 @@ public class AbstractStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> createAndLoadTrack(String name, CreationCause cause) {
|
||||
public CompletableFuture<Track> createAndLoadTrack(String name, CreationCause cause) {
|
||||
return makeFuture(() -> {
|
||||
if (dao.createAndLoadTrack(name)) {
|
||||
Track t = plugin.getTrackManager().getIfLoaded(name);
|
||||
if (t != null) {
|
||||
plugin.getApiProvider().getEventFactory().handleTrackCreate(t, cause);
|
||||
}
|
||||
return true;
|
||||
Track track = dao.createAndLoadTrack(name);
|
||||
if (track != null) {
|
||||
plugin.getApiProvider().getEventFactory().handleTrackCreate(track, cause);
|
||||
}
|
||||
return false;
|
||||
return track;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadTrack(String name) {
|
||||
public CompletableFuture<Optional<Track>> loadTrack(String name) {
|
||||
return makeFuture(() -> {
|
||||
if (dao.loadTrack(name)) {
|
||||
Track t = plugin.getTrackManager().getIfLoaded(name);
|
||||
if (t != null) {
|
||||
plugin.getApiProvider().getEventFactory().handleTrackLoad(t);
|
||||
}
|
||||
return true;
|
||||
Optional<Track> track = dao.loadTrack(name);
|
||||
if (track.isPresent()) {
|
||||
plugin.getApiProvider().getEventFactory().handleTrackLoad(track.get());
|
||||
}
|
||||
return false;
|
||||
return track;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadAllTracks() {
|
||||
public CompletableFuture<Void> loadAllTracks() {
|
||||
return makeFuture(() -> {
|
||||
if (dao.loadAllTracks()) {
|
||||
plugin.getApiProvider().getEventFactory().handleTrackLoadAll();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
dao.loadAllTracks();
|
||||
plugin.getApiProvider().getEventFactory().handleTrackLoadAll();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveTrack(Track track) {
|
||||
public CompletableFuture<Void> saveTrack(Track track) {
|
||||
return makeFuture(() -> dao.saveTrack(track));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> deleteTrack(Track track, DeletionCause cause) {
|
||||
public CompletableFuture<Void> deleteTrack(Track track, DeletionCause cause) {
|
||||
return makeFuture(() -> {
|
||||
if (dao.deleteTrack(track)) {
|
||||
plugin.getApiProvider().getEventFactory().handleTrackDelete(track, cause);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
dao.deleteTrack(track);
|
||||
plugin.getApiProvider().getEventFactory().handleTrackDelete(track, cause);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveUUIDData(UUID uuid, String username) {
|
||||
public CompletableFuture<Void> saveUUIDData(UUID uuid, String username) {
|
||||
return makeFuture(() -> dao.saveUUIDData(uuid, username));
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import me.lucko.luckperms.common.model.User;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
@ -59,43 +60,43 @@ public interface Storage {
|
|||
|
||||
Map<String, String> getMeta();
|
||||
|
||||
CompletableFuture<Boolean> logAction(LogEntry entry);
|
||||
CompletableFuture<Void> logAction(LogEntry entry);
|
||||
|
||||
CompletableFuture<Log> getLog();
|
||||
|
||||
CompletableFuture<Boolean> applyBulkUpdate(BulkUpdate bulkUpdate);
|
||||
CompletableFuture<Void> applyBulkUpdate(BulkUpdate bulkUpdate);
|
||||
|
||||
CompletableFuture<Boolean> loadUser(UUID uuid, String username);
|
||||
CompletableFuture<User> loadUser(UUID uuid, String username);
|
||||
|
||||
CompletableFuture<Boolean> saveUser(User user);
|
||||
CompletableFuture<Void> saveUser(User user);
|
||||
|
||||
CompletableFuture<Set<UUID>> getUniqueUsers();
|
||||
|
||||
CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(String permission);
|
||||
|
||||
CompletableFuture<Boolean> createAndLoadGroup(String name, CreationCause cause);
|
||||
CompletableFuture<Group> createAndLoadGroup(String name, CreationCause cause);
|
||||
|
||||
CompletableFuture<Boolean> loadGroup(String name);
|
||||
CompletableFuture<Optional<Group>> loadGroup(String name);
|
||||
|
||||
CompletableFuture<Boolean> loadAllGroups();
|
||||
CompletableFuture<Void> loadAllGroups();
|
||||
|
||||
CompletableFuture<Boolean> saveGroup(Group group);
|
||||
CompletableFuture<Void> saveGroup(Group group);
|
||||
|
||||
CompletableFuture<Boolean> deleteGroup(Group group, DeletionCause cause);
|
||||
CompletableFuture<Void> deleteGroup(Group group, DeletionCause cause);
|
||||
|
||||
CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(String permission);
|
||||
|
||||
CompletableFuture<Boolean> createAndLoadTrack(String name, CreationCause cause);
|
||||
CompletableFuture<Track> createAndLoadTrack(String name, CreationCause cause);
|
||||
|
||||
CompletableFuture<Boolean> loadTrack(String name);
|
||||
CompletableFuture<Optional<Track>> loadTrack(String name);
|
||||
|
||||
CompletableFuture<Boolean> loadAllTracks();
|
||||
CompletableFuture<Void> loadAllTracks();
|
||||
|
||||
CompletableFuture<Boolean> saveTrack(Track track);
|
||||
CompletableFuture<Void> saveTrack(Track track);
|
||||
|
||||
CompletableFuture<Boolean> deleteTrack(Track track, DeletionCause cause);
|
||||
CompletableFuture<Void> deleteTrack(Track track, DeletionCause cause);
|
||||
|
||||
CompletableFuture<Boolean> saveUUIDData(UUID uuid, String username);
|
||||
CompletableFuture<Void> saveUUIDData(UUID uuid, String username);
|
||||
|
||||
CompletableFuture<UUID> getUUID(String username);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -61,43 +62,43 @@ public abstract class AbstractDao {
|
|||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
public abstract boolean logAction(LogEntry entry) throws Exception;
|
||||
public abstract void logAction(LogEntry entry) throws Exception;
|
||||
|
||||
public abstract Log getLog() throws Exception;
|
||||
|
||||
public abstract boolean applyBulkUpdate(BulkUpdate bulkUpdate) throws Exception;
|
||||
public abstract void applyBulkUpdate(BulkUpdate bulkUpdate) throws Exception;
|
||||
|
||||
public abstract boolean loadUser(UUID uuid, String username) throws Exception;
|
||||
public abstract User loadUser(UUID uuid, String username) throws Exception;
|
||||
|
||||
public abstract boolean saveUser(User user) throws Exception;
|
||||
public abstract void saveUser(User user) throws Exception;
|
||||
|
||||
public abstract Set<UUID> getUniqueUsers() throws Exception;
|
||||
|
||||
public abstract List<HeldPermission<UUID>> getUsersWithPermission(String permission) throws Exception;
|
||||
|
||||
public abstract boolean createAndLoadGroup(String name) throws Exception;
|
||||
public abstract Group createAndLoadGroup(String name) throws Exception;
|
||||
|
||||
public abstract boolean loadGroup(String name) throws Exception;
|
||||
public abstract Optional<Group> loadGroup(String name) throws Exception;
|
||||
|
||||
public abstract boolean loadAllGroups() throws Exception;
|
||||
public abstract void loadAllGroups() throws Exception;
|
||||
|
||||
public abstract boolean saveGroup(Group group) throws Exception;
|
||||
public abstract void saveGroup(Group group) throws Exception;
|
||||
|
||||
public abstract boolean deleteGroup(Group group) throws Exception;
|
||||
public abstract void deleteGroup(Group group) throws Exception;
|
||||
|
||||
public abstract List<HeldPermission<String>> getGroupsWithPermission(String permission) throws Exception;
|
||||
|
||||
public abstract boolean createAndLoadTrack(String name) throws Exception;
|
||||
public abstract Track createAndLoadTrack(String name) throws Exception;
|
||||
|
||||
public abstract boolean loadTrack(String name) throws Exception;
|
||||
public abstract Optional<Track> loadTrack(String name) throws Exception;
|
||||
|
||||
public abstract boolean loadAllTracks() throws Exception;
|
||||
public abstract void loadAllTracks() throws Exception;
|
||||
|
||||
public abstract boolean saveTrack(Track track) throws Exception;
|
||||
public abstract void saveTrack(Track track) throws Exception;
|
||||
|
||||
public abstract boolean deleteTrack(Track track) throws Exception;
|
||||
public abstract void deleteTrack(Track track) throws Exception;
|
||||
|
||||
public abstract boolean saveUUIDData(UUID uuid, String username) throws Exception;
|
||||
public abstract void saveUUIDData(UUID uuid, String username) throws Exception;
|
||||
|
||||
public abstract UUID getUUID(String username) throws Exception;
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -90,8 +91,8 @@ public class SplitStorageDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean logAction(LogEntry entry) throws Exception {
|
||||
return backing.get(types.get("log")).logAction(entry);
|
||||
public void logAction(LogEntry entry) throws Exception {
|
||||
backing.get(types.get("log")).logAction(entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,27 +101,26 @@ public class SplitStorageDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applyBulkUpdate(BulkUpdate bulkUpdate) throws Exception {
|
||||
public void applyBulkUpdate(BulkUpdate bulkUpdate) throws Exception {
|
||||
String userType = types.get("user");
|
||||
String groupType = types.get("group");
|
||||
|
||||
boolean ret = backing.get(userType).applyBulkUpdate(bulkUpdate);
|
||||
backing.get(userType).applyBulkUpdate(bulkUpdate);
|
||||
|
||||
// if differs
|
||||
if (!userType.equals(groupType)) {
|
||||
if (!backing.get(groupType).applyBulkUpdate(bulkUpdate)) {
|
||||
ret = false;
|
||||
}
|
||||
backing.get(groupType).applyBulkUpdate(bulkUpdate);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadUser(UUID uuid, String username) throws Exception {
|
||||
public User loadUser(UUID uuid, String username) throws Exception {
|
||||
return backing.get(types.get("user")).loadUser(uuid, username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveUser(User user) throws Exception {
|
||||
return backing.get(types.get("user")).saveUser(user);
|
||||
public void saveUser(User user) throws Exception {
|
||||
backing.get(types.get("user")).saveUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -134,28 +134,28 @@ public class SplitStorageDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean createAndLoadGroup(String name) throws Exception {
|
||||
public Group createAndLoadGroup(String name) throws Exception {
|
||||
return backing.get(types.get("group")).createAndLoadGroup(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadGroup(String name) throws Exception {
|
||||
public Optional<Group> loadGroup(String name) throws Exception {
|
||||
return backing.get(types.get("group")).loadGroup(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadAllGroups() throws Exception {
|
||||
return backing.get(types.get("group")).loadAllGroups();
|
||||
public void loadAllGroups() throws Exception {
|
||||
backing.get(types.get("group")).loadAllGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveGroup(Group group) throws Exception {
|
||||
return backing.get(types.get("group")).saveGroup(group);
|
||||
public void saveGroup(Group group) throws Exception {
|
||||
backing.get(types.get("group")).saveGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteGroup(Group group) throws Exception {
|
||||
return backing.get(types.get("group")).deleteGroup(group);
|
||||
public void deleteGroup(Group group) throws Exception {
|
||||
backing.get(types.get("group")).deleteGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -164,33 +164,33 @@ public class SplitStorageDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean createAndLoadTrack(String name) throws Exception {
|
||||
public Track createAndLoadTrack(String name) throws Exception {
|
||||
return backing.get(types.get("track")).createAndLoadTrack(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadTrack(String name) throws Exception {
|
||||
public Optional<Track> loadTrack(String name) throws Exception {
|
||||
return backing.get(types.get("track")).loadTrack(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadAllTracks() throws Exception {
|
||||
return backing.get(types.get("track")).loadAllTracks();
|
||||
public void loadAllTracks() throws Exception {
|
||||
backing.get(types.get("track")).loadAllTracks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveTrack(Track track) throws Exception {
|
||||
return backing.get(types.get("track")).saveTrack(track);
|
||||
public void saveTrack(Track track) throws Exception {
|
||||
backing.get(types.get("track")).saveTrack(track);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteTrack(Track track) throws Exception {
|
||||
return backing.get(types.get("track")).deleteTrack(track);
|
||||
public void deleteTrack(Track track) throws Exception {
|
||||
backing.get(types.get("track")).deleteTrack(track);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveUUIDData(UUID uuid, String username) throws Exception {
|
||||
return backing.get(types.get("uuid")).saveUUIDData(uuid, username);
|
||||
public void saveUUIDData(UUID uuid, String username) throws Exception {
|
||||
backing.get(types.get("uuid")).saveUUIDData(uuid, username);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -73,6 +73,7 @@ import java.util.LinkedHashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.FileHandler;
|
||||
|
@ -303,7 +304,7 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean logAction(LogEntry entry) {
|
||||
public void logAction(LogEntry entry) {
|
||||
actionLogger.info(String.format(LOG_FORMAT,
|
||||
(entry.getActor().equals(Constants.CONSOLE_UUID) ? "" : entry.getActor() + " "),
|
||||
entry.getActorName(),
|
||||
|
@ -312,7 +313,6 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
entry.getActedName(),
|
||||
entry.getAction())
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -322,7 +322,7 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applyBulkUpdate(BulkUpdate bulkUpdate) throws Exception {
|
||||
public void applyBulkUpdate(BulkUpdate bulkUpdate) throws Exception {
|
||||
if (bulkUpdate.getDataType().isIncludingUsers()) {
|
||||
File[] files = getDirectory(StorageLocation.USER).listFiles(getFileTypeFilter());
|
||||
if (files == null) {
|
||||
|
@ -374,11 +374,10 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadUser(UUID uuid, String username) throws Exception {
|
||||
public User loadUser(UUID uuid, String username) throws Exception {
|
||||
User user = plugin.getUserManager().getOrMake(UserIdentifier.of(uuid, username));
|
||||
user.getIoLock().lock();
|
||||
try {
|
||||
|
@ -412,11 +411,11 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
user.getIoLock().unlock();
|
||||
}
|
||||
user.getRefreshBuffer().requestDirectly();
|
||||
return true;
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveUser(User user) throws Exception {
|
||||
public void saveUser(User user) throws Exception {
|
||||
user.getIoLock().lock();
|
||||
try {
|
||||
if (!GenericUserManager.shouldSave(user)) {
|
||||
|
@ -437,7 +436,6 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
} finally {
|
||||
user.getIoLock().unlock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -478,7 +476,7 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean createAndLoadGroup(String name) throws Exception {
|
||||
public Group createAndLoadGroup(String name) throws Exception {
|
||||
Group group = plugin.getGroupManager().getOrMake(name);
|
||||
group.getIoLock().lock();
|
||||
try {
|
||||
|
@ -502,11 +500,11 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
group.getIoLock().unlock();
|
||||
}
|
||||
group.getRefreshBuffer().requestDirectly();
|
||||
return true;
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadGroup(String name) throws Exception {
|
||||
public Optional<Group> loadGroup(String name) throws Exception {
|
||||
Group group = plugin.getGroupManager().getIfLoaded(name);
|
||||
if (group != null) {
|
||||
group.getIoLock().lock();
|
||||
|
@ -516,7 +514,7 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
ConfigurationNode object = readFile(StorageLocation.GROUP, name);
|
||||
|
||||
if (object == null) {
|
||||
return false;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
if (group == null) {
|
||||
|
@ -536,13 +534,15 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
}
|
||||
}
|
||||
group.getRefreshBuffer().requestDirectly();
|
||||
return true;
|
||||
return Optional.of(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadAllGroups() {
|
||||
public void loadAllGroups() throws IOException {
|
||||
String[] fileNames = groupsDirectory.list(getFileTypeFilter());
|
||||
if (fileNames == null) return false;
|
||||
if (fileNames == null) {
|
||||
throw new IOException("Not a directory");
|
||||
}
|
||||
List<String> groups = Arrays.stream(fileNames)
|
||||
.map(s -> s.substring(0, s.length() - fileExtension.length()))
|
||||
.collect(Collectors.toList());
|
||||
|
@ -565,12 +565,10 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
gm.getAll().values().stream()
|
||||
.filter(g -> !groups.contains(g.getName()))
|
||||
.forEach(gm::unload);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveGroup(Group group) throws Exception {
|
||||
public void saveGroup(Group group) throws Exception {
|
||||
group.getIoLock().lock();
|
||||
try {
|
||||
ConfigurationNode data = SimpleConfigurationNode.root();
|
||||
|
@ -585,11 +583,10 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
} finally {
|
||||
group.getIoLock().unlock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteGroup(Group group) throws Exception {
|
||||
public void deleteGroup(Group group) throws Exception {
|
||||
group.getIoLock().lock();
|
||||
try {
|
||||
File groupFile = new File(groupsDirectory, group.getName() + fileExtension);
|
||||
|
@ -603,7 +600,7 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
} finally {
|
||||
group.getIoLock().unlock();
|
||||
}
|
||||
return true;
|
||||
plugin.getGroupManager().unload(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -634,7 +631,7 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean createAndLoadTrack(String name) throws Exception {
|
||||
public Track createAndLoadTrack(String name) throws Exception {
|
||||
Track track = plugin.getTrackManager().getOrMake(name);
|
||||
track.getIoLock().lock();
|
||||
try {
|
||||
|
@ -658,11 +655,11 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
} finally {
|
||||
track.getIoLock().unlock();
|
||||
}
|
||||
return true;
|
||||
return track;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadTrack(String name) throws Exception {
|
||||
public Optional<Track> loadTrack(String name) throws Exception {
|
||||
Track track = plugin.getTrackManager().getIfLoaded(name);
|
||||
if (track != null) {
|
||||
track.getIoLock().lock();
|
||||
|
@ -672,7 +669,7 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
ConfigurationNode object = readFile(StorageLocation.TRACK, name);
|
||||
|
||||
if (object == null) {
|
||||
return false;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
if (track == null) {
|
||||
|
@ -693,13 +690,15 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
track.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return Optional.of(track);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadAllTracks() {
|
||||
public void loadAllTracks() throws IOException {
|
||||
String[] fileNames = tracksDirectory.list(getFileTypeFilter());
|
||||
if (fileNames == null) return false;
|
||||
if (fileNames == null) {
|
||||
throw new IOException("Not a directory");
|
||||
}
|
||||
List<String> tracks = Arrays.stream(fileNames)
|
||||
.map(s -> s.substring(0, s.length() - fileExtension.length()))
|
||||
.collect(Collectors.toList());
|
||||
|
@ -722,12 +721,10 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
tm.getAll().values().stream()
|
||||
.filter(t -> !tracks.contains(t.getName()))
|
||||
.forEach(tm::unload);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveTrack(Track track) throws Exception {
|
||||
public void saveTrack(Track track) throws Exception {
|
||||
track.getIoLock().lock();
|
||||
try {
|
||||
ConfigurationNode data = SimpleConfigurationNode.root();
|
||||
|
@ -739,11 +736,10 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
} finally {
|
||||
track.getIoLock().unlock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteTrack(Track track) throws Exception {
|
||||
public void deleteTrack(Track track) throws Exception {
|
||||
track.getIoLock().lock();
|
||||
try {
|
||||
File trackFile = new File(tracksDirectory, track.getName() + fileExtension);
|
||||
|
@ -757,13 +753,12 @@ public abstract class ConfigurateDao extends AbstractDao {
|
|||
} finally {
|
||||
track.getIoLock().unlock();
|
||||
}
|
||||
return true;
|
||||
plugin.getTrackManager().unload(track);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveUUIDData(UUID uuid, String username) {
|
||||
public void saveUUIDData(UUID uuid, String username) {
|
||||
uuidCache.addMapping(uuid, username);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -69,6 +69,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -144,7 +145,7 @@ public class MongoDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean logAction(LogEntry entry) {
|
||||
public void logAction(LogEntry entry) {
|
||||
MongoCollection<Document> c = database.getCollection(prefix + "action");
|
||||
Document doc = new Document()
|
||||
.append("timestamp", entry.getTimestamp())
|
||||
|
@ -159,7 +160,6 @@ public class MongoDao extends AbstractDao {
|
|||
}
|
||||
|
||||
c.insertOne(doc);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -192,7 +192,7 @@ public class MongoDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applyBulkUpdate(BulkUpdate bulkUpdate) {
|
||||
public void applyBulkUpdate(BulkUpdate bulkUpdate) {
|
||||
if (bulkUpdate.getDataType().isIncludingUsers()) {
|
||||
MongoCollection<Document> c = database.getCollection(prefix + "users");
|
||||
try (MongoCursor<Document> cursor = c.find().iterator()) {
|
||||
|
@ -242,11 +242,10 @@ public class MongoDao extends AbstractDao {
|
|||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadUser(UUID uuid, String username) {
|
||||
public User loadUser(UUID uuid, String username) {
|
||||
User user = plugin.getUserManager().getOrMake(UserIdentifier.of(uuid, username));
|
||||
user.getIoLock().lock();
|
||||
try {
|
||||
|
@ -283,18 +282,18 @@ public class MongoDao extends AbstractDao {
|
|||
user.getIoLock().unlock();
|
||||
}
|
||||
user.getRefreshBuffer().requestDirectly();
|
||||
return true;
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveUser(User user) {
|
||||
public void saveUser(User user) {
|
||||
user.getIoLock().lock();
|
||||
try {
|
||||
MongoCollection<Document> c = database.getCollection(prefix + "users");
|
||||
if (!GenericUserManager.shouldSave(user)) {
|
||||
return c.deleteOne(new Document("_id", user.getUuid())).wasAcknowledged();
|
||||
c.deleteOne(new Document("_id", user.getUuid()));
|
||||
} else {
|
||||
return c.replaceOne(new Document("_id", user.getUuid()), userToDoc(user), new UpdateOptions().upsert(true)).wasAcknowledged();
|
||||
c.replaceOne(new Document("_id", user.getUuid()), userToDoc(user), new UpdateOptions().upsert(true));
|
||||
}
|
||||
} finally {
|
||||
user.getIoLock().unlock();
|
||||
|
@ -336,7 +335,7 @@ public class MongoDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean createAndLoadGroup(String name) {
|
||||
public Group createAndLoadGroup(String name) {
|
||||
Group group = plugin.getGroupManager().getOrMake(name);
|
||||
group.getIoLock().lock();
|
||||
try {
|
||||
|
@ -354,18 +353,25 @@ public class MongoDao extends AbstractDao {
|
|||
group.getIoLock().unlock();
|
||||
}
|
||||
group.getRefreshBuffer().requestDirectly();
|
||||
return true;
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadGroup(String name) {
|
||||
Group group = plugin.getGroupManager().getOrMake(name);
|
||||
group.getIoLock().lock();
|
||||
public Optional<Group> loadGroup(String name) {
|
||||
Group group = plugin.getGroupManager().getIfLoaded(name);
|
||||
if (group != null) {
|
||||
group.getIoLock().lock();
|
||||
}
|
||||
try {
|
||||
MongoCollection<Document> c = database.getCollection(prefix + "groups");
|
||||
try (MongoCursor<Document> cursor = c.find(new Document("_id", group.getName())).iterator()) {
|
||||
try (MongoCursor<Document> cursor = c.find(new Document("_id", name)).iterator()) {
|
||||
if (!cursor.hasNext()) {
|
||||
return false;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
if (group == null) {
|
||||
group = plugin.getGroupManager().getOrMake(name);
|
||||
group.getIoLock().lock();
|
||||
}
|
||||
|
||||
Document d = cursor.next();
|
||||
|
@ -373,14 +379,16 @@ public class MongoDao extends AbstractDao {
|
|||
group.setEnduringNodes(nodes);
|
||||
}
|
||||
} finally {
|
||||
group.getIoLock().unlock();
|
||||
if (group != null) {
|
||||
group.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
group.getRefreshBuffer().requestDirectly();
|
||||
return true;
|
||||
return Optional.of(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadAllGroups() {
|
||||
public void loadAllGroups() {
|
||||
List<String> groups = new ArrayList<>();
|
||||
MongoCollection<Document> c = database.getCollection(prefix + "groups");
|
||||
try (MongoCursor<Document> cursor = c.find().iterator()) {
|
||||
|
@ -408,27 +416,25 @@ public class MongoDao extends AbstractDao {
|
|||
gm.getAll().values().stream()
|
||||
.filter(g -> !groups.contains(g.getName()))
|
||||
.forEach(gm::unload);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveGroup(Group group) {
|
||||
public void saveGroup(Group group) {
|
||||
group.getIoLock().lock();
|
||||
try {
|
||||
MongoCollection<Document> c = database.getCollection(prefix + "groups");
|
||||
return c.replaceOne(new Document("_id", group.getName()), groupToDoc(group), new UpdateOptions().upsert(true)).wasAcknowledged();
|
||||
c.replaceOne(new Document("_id", group.getName()), groupToDoc(group), new UpdateOptions().upsert(true));
|
||||
} finally {
|
||||
group.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteGroup(Group group) {
|
||||
public void deleteGroup(Group group) {
|
||||
group.getIoLock().lock();
|
||||
try {
|
||||
MongoCollection<Document> c = database.getCollection(prefix + "groups");
|
||||
return c.deleteOne(new Document("_id", group.getName())).wasAcknowledged();
|
||||
c.deleteOne(new Document("_id", group.getName()));
|
||||
} finally {
|
||||
group.getIoLock().unlock();
|
||||
}
|
||||
|
@ -456,7 +462,7 @@ public class MongoDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean createAndLoadTrack(String name) {
|
||||
public Track createAndLoadTrack(String name) {
|
||||
Track track = plugin.getTrackManager().getOrMake(name);
|
||||
track.getIoLock().lock();
|
||||
try {
|
||||
|
@ -473,31 +479,42 @@ public class MongoDao extends AbstractDao {
|
|||
} finally {
|
||||
track.getIoLock().unlock();
|
||||
}
|
||||
return true;
|
||||
return track;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadTrack(String name) {
|
||||
Track track = plugin.getTrackManager().getOrMake(name);
|
||||
track.getIoLock().lock();
|
||||
public Optional<Track> loadTrack(String name) {
|
||||
Track track = plugin.getTrackManager().getIfLoaded(name);
|
||||
if (track != null) {
|
||||
track.getIoLock().lock();
|
||||
}
|
||||
|
||||
try {
|
||||
MongoCollection<Document> c = database.getCollection(prefix + "tracks");
|
||||
try (MongoCursor<Document> cursor = c.find(new Document("_id", track.getName())).iterator()) {
|
||||
if (cursor.hasNext()) {
|
||||
Document d = cursor.next();
|
||||
//noinspection unchecked
|
||||
track.setGroups((List<String>) d.get("groups"));
|
||||
return true;
|
||||
try (MongoCursor<Document> cursor = c.find(new Document("_id", name)).iterator()) {
|
||||
if (!cursor.hasNext()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return false;
|
||||
|
||||
if (track == null) {
|
||||
track = plugin.getTrackManager().getOrMake(name);
|
||||
track.getIoLock().lock();
|
||||
}
|
||||
|
||||
Document d = cursor.next();
|
||||
//noinspection unchecked
|
||||
track.setGroups((List<String>) d.get("groups"));
|
||||
}
|
||||
} finally {
|
||||
track.getIoLock().unlock();
|
||||
if (track != null) {
|
||||
track.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
return Optional.of(track);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadAllTracks() {
|
||||
public void loadAllTracks() {
|
||||
List<String> tracks = new ArrayList<>();
|
||||
MongoCollection<Document> c = database.getCollection(prefix + "tracks");
|
||||
try (MongoCursor<Document> cursor = c.find().iterator()) {
|
||||
|
@ -525,37 +542,34 @@ public class MongoDao extends AbstractDao {
|
|||
tm.getAll().values().stream()
|
||||
.filter(t -> !tracks.contains(t.getName()))
|
||||
.forEach(tm::unload);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveTrack(Track track) {
|
||||
public void saveTrack(Track track) {
|
||||
track.getIoLock().lock();
|
||||
try {
|
||||
MongoCollection<Document> c = database.getCollection(prefix + "tracks");
|
||||
return c.replaceOne(new Document("_id", track.getName()), trackToDoc(track)).wasAcknowledged();
|
||||
c.replaceOne(new Document("_id", track.getName()), trackToDoc(track));
|
||||
} finally {
|
||||
track.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteTrack(Track track) {
|
||||
public void deleteTrack(Track track) {
|
||||
track.getIoLock().lock();
|
||||
try {
|
||||
MongoCollection<Document> c = database.getCollection(prefix + "tracks");
|
||||
return c.deleteOne(new Document("_id", track.getName())).wasAcknowledged();
|
||||
c.deleteOne(new Document("_id", track.getName()));
|
||||
} finally {
|
||||
track.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveUUIDData(UUID uuid, String username) {
|
||||
public void saveUUIDData(UUID uuid, String username) {
|
||||
MongoCollection<Document> c = database.getCollection(prefix + "uuid");
|
||||
c.replaceOne(new Document("_id", uuid), new Document("_id", uuid).append("name", username.toLowerCase()), new UpdateOptions().upsert(true));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -69,6 +69,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -228,7 +229,7 @@ public class SqlDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean logAction(LogEntry entry) throws SQLException {
|
||||
public void logAction(LogEntry entry) throws SQLException {
|
||||
try (Connection c = provider.getConnection()) {
|
||||
try (PreparedStatement ps = c.prepareStatement(prefix.apply(ACTION_INSERT))) {
|
||||
ps.setLong(1, entry.getTimestamp());
|
||||
|
@ -239,7 +240,6 @@ public class SqlDao extends AbstractDao {
|
|||
ps.setString(6, entry.getActedName());
|
||||
ps.setString(7, entry.getAction());
|
||||
ps.execute();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,11 +271,10 @@ public class SqlDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applyBulkUpdate(BulkUpdate bulkUpdate) throws SQLException {
|
||||
public void applyBulkUpdate(BulkUpdate bulkUpdate) throws SQLException {
|
||||
String queryString = bulkUpdate.buildAsSql();
|
||||
|
||||
try (Connection c = provider.getConnection()) {
|
||||
|
||||
if (bulkUpdate.getDataType().isIncludingUsers()) {
|
||||
String table = prefix.apply("{prefix}user_permissions");
|
||||
try (Statement s = c.createStatement()) {
|
||||
|
@ -290,11 +289,10 @@ public class SqlDao extends AbstractDao {
|
|||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadUser(UUID uuid, String username) throws SQLException {
|
||||
public User loadUser(UUID uuid, String username) throws SQLException {
|
||||
User user = plugin.getUserManager().getOrMake(UserIdentifier.of(uuid, username));
|
||||
user.getIoLock().lock();
|
||||
try {
|
||||
|
@ -368,11 +366,11 @@ public class SqlDao extends AbstractDao {
|
|||
user.getIoLock().unlock();
|
||||
}
|
||||
user.getRefreshBuffer().requestDirectly();
|
||||
return true;
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveUser(User user) throws SQLException {
|
||||
public void saveUser(User user) throws SQLException {
|
||||
user.getIoLock().lock();
|
||||
try {
|
||||
// Empty data - just delete from the DB.
|
||||
|
@ -388,7 +386,7 @@ public class SqlDao extends AbstractDao {
|
|||
ps.execute();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get a snapshot of current data.
|
||||
|
@ -482,8 +480,6 @@ public class SqlDao extends AbstractDao {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
} finally {
|
||||
user.getIoLock().unlock();
|
||||
}
|
||||
|
@ -530,7 +526,7 @@ public class SqlDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean createAndLoadGroup(String name) throws SQLException {
|
||||
public Group createAndLoadGroup(String name) throws SQLException {
|
||||
String query;
|
||||
switch (provider.getName()) {
|
||||
case "H2":
|
||||
|
@ -554,11 +550,11 @@ public class SqlDao extends AbstractDao {
|
|||
}
|
||||
}
|
||||
|
||||
return loadGroup(name);
|
||||
return loadGroup(name).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadGroup(String name) throws SQLException {
|
||||
public Optional<Group> loadGroup(String name) throws SQLException {
|
||||
// Check the group actually exists
|
||||
List<String> groups = new ArrayList<>();
|
||||
try (Connection c = provider.getConnection()) {
|
||||
|
@ -573,7 +569,7 @@ public class SqlDao extends AbstractDao {
|
|||
}
|
||||
|
||||
if (!groups.contains(name)) {
|
||||
return false;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
Group group = plugin.getGroupManager().getOrMake(name);
|
||||
|
@ -609,11 +605,11 @@ public class SqlDao extends AbstractDao {
|
|||
group.getIoLock().unlock();
|
||||
}
|
||||
group.getRefreshBuffer().requestDirectly();
|
||||
return true;
|
||||
return Optional.of(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadAllGroups() throws SQLException {
|
||||
public void loadAllGroups() throws SQLException {
|
||||
List<String> groups = new ArrayList<>();
|
||||
try (Connection c = provider.getConnection()) {
|
||||
try (PreparedStatement ps = c.prepareStatement(prefix.apply(GROUP_SELECT_ALL))) {
|
||||
|
@ -643,12 +639,10 @@ public class SqlDao extends AbstractDao {
|
|||
gm.getAll().values().stream()
|
||||
.filter(g -> !groups.contains(g.getName()))
|
||||
.forEach(gm::unload);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveGroup(Group group) throws SQLException {
|
||||
public void saveGroup(Group group) throws SQLException {
|
||||
group.getIoLock().lock();
|
||||
try {
|
||||
// Empty data, just delete.
|
||||
|
@ -659,7 +653,7 @@ public class SqlDao extends AbstractDao {
|
|||
ps.execute();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get a snapshot of current data
|
||||
|
@ -724,15 +718,13 @@ public class SqlDao extends AbstractDao {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} finally {
|
||||
group.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteGroup(Group group) throws SQLException {
|
||||
public void deleteGroup(Group group) throws SQLException {
|
||||
group.getIoLock().lock();
|
||||
try {
|
||||
try (Connection c = provider.getConnection()) {
|
||||
|
@ -746,10 +738,11 @@ public class SqlDao extends AbstractDao {
|
|||
ps.execute();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} finally {
|
||||
group.getIoLock().unlock();
|
||||
}
|
||||
|
||||
plugin.getGroupManager().unload(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -777,7 +770,7 @@ public class SqlDao extends AbstractDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean createAndLoadTrack(String name) throws SQLException {
|
||||
public Track createAndLoadTrack(String name) throws SQLException {
|
||||
Track track = plugin.getTrackManager().getOrMake(name);
|
||||
track.getIoLock().lock();
|
||||
try {
|
||||
|
@ -799,7 +792,6 @@ public class SqlDao extends AbstractDao {
|
|||
if (exists.get()) {
|
||||
// Track exists, let's load.
|
||||
track.setGroups(gson.fromJson(groups.get(), LIST_STRING_TYPE));
|
||||
return true;
|
||||
} else {
|
||||
String json = gson.toJson(track.getGroups());
|
||||
try (Connection c = provider.getConnection()) {
|
||||
|
@ -809,43 +801,52 @@ public class SqlDao extends AbstractDao {
|
|||
ps.execute();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} finally {
|
||||
track.getIoLock().unlock();
|
||||
}
|
||||
return track;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadTrack(String name) throws SQLException {
|
||||
Track track = plugin.getTrackManager().getOrMake(name);
|
||||
track.getIoLock().lock();
|
||||
public Optional<Track> loadTrack(String name) throws SQLException {
|
||||
Track track = plugin.getTrackManager().getIfLoaded(name);
|
||||
if (track != null) {
|
||||
track.getIoLock().lock();
|
||||
}
|
||||
try {
|
||||
AtomicReference<String> groups = new AtomicReference<>(null);
|
||||
|
||||
try (Connection c = provider.getConnection()) {
|
||||
try (PreparedStatement ps = c.prepareStatement(prefix.apply(TRACK_SELECT))) {
|
||||
ps.setString(1, track.getName());
|
||||
ps.setString(1, name);
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
groups.set(rs.getString("groups"));
|
||||
} else {
|
||||
return false;
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (track == null) {
|
||||
track = plugin.getTrackManager().getOrMake(name);
|
||||
track.getIoLock().lock();
|
||||
}
|
||||
|
||||
track.setGroups(gson.fromJson(groups.get(), LIST_STRING_TYPE));
|
||||
return true;
|
||||
return Optional.of(track);
|
||||
|
||||
} finally {
|
||||
track.getIoLock().unlock();
|
||||
if (track != null) {
|
||||
track.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadAllTracks() throws SQLException {
|
||||
public void loadAllTracks() throws SQLException {
|
||||
List<String> tracks = new ArrayList<>();
|
||||
try (Connection c = provider.getConnection()) {
|
||||
try (PreparedStatement ps = c.prepareStatement(prefix.apply(TRACK_SELECT_ALL))) {
|
||||
|
@ -875,12 +876,10 @@ public class SqlDao extends AbstractDao {
|
|||
tm.getAll().values().stream()
|
||||
.filter(t -> !tracks.contains(t.getName()))
|
||||
.forEach(tm::unload);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveTrack(Track track) throws SQLException {
|
||||
public void saveTrack(Track track) throws SQLException {
|
||||
track.getIoLock().lock();
|
||||
try {
|
||||
String s = gson.toJson(track.getGroups());
|
||||
|
@ -891,14 +890,13 @@ public class SqlDao extends AbstractDao {
|
|||
ps.execute();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} finally {
|
||||
track.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteTrack(Track track) throws SQLException {
|
||||
public void deleteTrack(Track track) throws SQLException {
|
||||
track.getIoLock().lock();
|
||||
try {
|
||||
try (Connection c = provider.getConnection()) {
|
||||
|
@ -912,11 +910,10 @@ public class SqlDao extends AbstractDao {
|
|||
}
|
||||
|
||||
plugin.getTrackManager().unload(track);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveUUIDData(UUID uuid, String username) throws SQLException {
|
||||
public void saveUUIDData(UUID uuid, String username) throws SQLException {
|
||||
final String u = username.toLowerCase();
|
||||
AtomicReference<String> remoteUserName = new AtomicReference<>(null);
|
||||
|
||||
|
@ -943,7 +940,7 @@ public class SqlDao extends AbstractDao {
|
|||
if (remoteUserName.get() != null) {
|
||||
// the value is already correct
|
||||
if (remoteUserName.get().equals(u)) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection c = provider.getConnection()) {
|
||||
|
@ -953,7 +950,6 @@ public class SqlDao extends AbstractDao {
|
|||
ps.execute();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// first time we've seen this uuid
|
||||
try (Connection c = provider.getConnection()) {
|
||||
|
@ -964,7 +960,6 @@ public class SqlDao extends AbstractDao {
|
|||
ps.execute();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,9 +48,9 @@ public class BufferedOutputStorage implements Storage, Runnable {
|
|||
|
||||
private final long flushTime;
|
||||
|
||||
private final Buffer<User, Boolean> userOutputBuffer = Buffer.of(user -> BufferedOutputStorage.this.delegate.saveUser(user).join());
|
||||
private final Buffer<Group, Boolean> groupOutputBuffer = Buffer.of(group -> BufferedOutputStorage.this.delegate.saveGroup(group).join());
|
||||
private final Buffer<Track, Boolean> trackOutputBuffer = Buffer.of(track -> BufferedOutputStorage.this.delegate.saveTrack(track).join());
|
||||
private final Buffer<User, Void> userOutputBuffer = Buffer.of(user -> BufferedOutputStorage.this.delegate.saveUser(user).join());
|
||||
private final Buffer<Group, Void> groupOutputBuffer = Buffer.of(group -> BufferedOutputStorage.this.delegate.saveGroup(group).join());
|
||||
private final Buffer<Track, Void> trackOutputBuffer = Buffer.of(track -> BufferedOutputStorage.this.delegate.saveTrack(track).join());
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -79,25 +79,25 @@ public class BufferedOutputStorage implements Storage, Runnable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveUser(User user) {
|
||||
public CompletableFuture<Void> saveUser(User user) {
|
||||
return userOutputBuffer.enqueue(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveGroup(Group group) {
|
||||
public CompletableFuture<Void> saveGroup(Group group) {
|
||||
return groupOutputBuffer.enqueue(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveTrack(Track track) {
|
||||
public CompletableFuture<Void> saveTrack(Track track) {
|
||||
return trackOutputBuffer.enqueue(track);
|
||||
}
|
||||
|
||||
private interface Exclude {
|
||||
Storage noBuffer();
|
||||
CompletableFuture<Void> shutdown();
|
||||
CompletableFuture<Boolean> saveUser(User user);
|
||||
CompletableFuture<Boolean> saveGroup(Group group);
|
||||
CompletableFuture<Boolean> saveTrack(Track track);
|
||||
void shutdown();
|
||||
CompletableFuture<Void> saveUser(User user);
|
||||
CompletableFuture<Void> saveGroup(Group group);
|
||||
CompletableFuture<Void> saveTrack(Track track);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import me.lucko.luckperms.common.storage.Storage;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
@ -100,7 +101,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> logAction(LogEntry entry) {
|
||||
public CompletableFuture<Void> logAction(LogEntry entry) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.logAction(entry);
|
||||
|
@ -120,7 +121,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> applyBulkUpdate(BulkUpdate bulkUpdate) {
|
||||
public CompletableFuture<Void> applyBulkUpdate(BulkUpdate bulkUpdate) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.applyBulkUpdate(bulkUpdate);
|
||||
|
@ -130,7 +131,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadUser(UUID uuid, String username) {
|
||||
public CompletableFuture<User> loadUser(UUID uuid, String username) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.loadUser(uuid, username);
|
||||
|
@ -140,7 +141,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveUser(User user) {
|
||||
public CompletableFuture<Void> saveUser(User user) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.saveUser(user);
|
||||
|
@ -170,7 +171,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> createAndLoadGroup(String name, CreationCause cause) {
|
||||
public CompletableFuture<Group> createAndLoadGroup(String name, CreationCause cause) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.createAndLoadGroup(name, cause);
|
||||
|
@ -180,7 +181,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadGroup(String name) {
|
||||
public CompletableFuture<Optional<Group>> loadGroup(String name) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.loadGroup(name);
|
||||
|
@ -190,7 +191,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadAllGroups() {
|
||||
public CompletableFuture<Void> loadAllGroups() {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.loadAllGroups();
|
||||
|
@ -200,7 +201,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveGroup(Group group) {
|
||||
public CompletableFuture<Void> saveGroup(Group group) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.saveGroup(group);
|
||||
|
@ -210,7 +211,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> deleteGroup(Group group, DeletionCause cause) {
|
||||
public CompletableFuture<Void> deleteGroup(Group group, DeletionCause cause) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.deleteGroup(group, cause);
|
||||
|
@ -230,7 +231,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> createAndLoadTrack(String name, CreationCause cause) {
|
||||
public CompletableFuture<Track> createAndLoadTrack(String name, CreationCause cause) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.createAndLoadTrack(name, cause);
|
||||
|
@ -240,7 +241,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadTrack(String name) {
|
||||
public CompletableFuture<Optional<Track>> loadTrack(String name) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.loadTrack(name);
|
||||
|
@ -250,7 +251,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadAllTracks() {
|
||||
public CompletableFuture<Void> loadAllTracks() {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.loadAllTracks();
|
||||
|
@ -260,7 +261,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveTrack(Track track) {
|
||||
public CompletableFuture<Void> saveTrack(Track track) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.saveTrack(track);
|
||||
|
@ -270,7 +271,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> deleteTrack(Track track, DeletionCause cause) {
|
||||
public CompletableFuture<Void> deleteTrack(Track track, DeletionCause cause) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.deleteTrack(track, cause);
|
||||
|
@ -280,7 +281,7 @@ public class PhasedStorage implements Storage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveUUIDData(UUID uuid, String username) {
|
||||
public CompletableFuture<Void> saveUUIDData(UUID uuid, String username) {
|
||||
phaser.register();
|
||||
try {
|
||||
return delegate.saveUUIDData(uuid, username);
|
||||
|
|
|
@ -53,7 +53,7 @@ public class LoginHelper {
|
|||
// No previous data for this player
|
||||
plugin.getApiProvider().getEventFactory().handleUserFirstLogin(u, username);
|
||||
cache.addToCache(u, u);
|
||||
CompletableFuture<Boolean> future = plugin.getStorage().noBuffer().saveUUIDData(u, username);
|
||||
CompletableFuture<Void> future = plugin.getStorage().noBuffer().saveUUIDData(u, username);
|
||||
if (joinUuidSave) {
|
||||
future.join();
|
||||
}
|
||||
|
@ -65,16 +65,15 @@ public class LoginHelper {
|
|||
}
|
||||
|
||||
// Online mode, no cache needed. This is just for name -> uuid lookup.
|
||||
CompletableFuture<Boolean> future = plugin.getStorage().noBuffer().saveUUIDData(u, username);
|
||||
CompletableFuture<Void> future = plugin.getStorage().noBuffer().saveUUIDData(u, username);
|
||||
if (joinUuidSave) {
|
||||
future.join();
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getStorage().noBuffer().loadUser(cache.getUUID(u), username).join();
|
||||
User user = plugin.getUserManager().getIfLoaded(cache.getUUID(u));
|
||||
User user = plugin.getStorage().noBuffer().loadUser(cache.getUUID(u), username).join();
|
||||
if (user == null) {
|
||||
throw new RuntimeException("Failed to load user");
|
||||
throw new NullPointerException("User is null");
|
||||
} else {
|
||||
// Setup defaults for the user
|
||||
boolean save = false;
|
||||
|
|
|
@ -450,22 +450,26 @@ public class LuckPermsSubjectData implements LPSubjectData {
|
|||
} else {
|
||||
if (t.getType().isUser()) {
|
||||
User user = ((User) t);
|
||||
return service.getPlugin().getStorage().saveUser(user).thenComposeAsync(success -> {
|
||||
if (!success) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
CompletableFuture<Void> fut = new CompletableFuture<>();
|
||||
service.getPlugin().getStorage().saveUser(user).whenCompleteAsync((v, ex) -> {
|
||||
if (ex != null) {
|
||||
fut.complete(null);
|
||||
}
|
||||
|
||||
return user.getRefreshBuffer().request();
|
||||
user.getRefreshBuffer().request().thenAccept(fut::complete);
|
||||
}, service.getPlugin().getScheduler().async());
|
||||
return fut;
|
||||
} else {
|
||||
Group group = ((Group) t);
|
||||
return service.getPlugin().getStorage().saveGroup(group).thenComposeAsync(success -> {
|
||||
if (!success) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
CompletableFuture<Void> fut = new CompletableFuture<>();
|
||||
service.getPlugin().getStorage().saveGroup(group).whenCompleteAsync((v, ex) -> {
|
||||
if (ex != null) {
|
||||
fut.complete(null);
|
||||
}
|
||||
|
||||
return service.getPlugin().getUpdateTaskBuffer().request();
|
||||
service.getPlugin().getUpdateTaskBuffer().request().thenAccept(fut::complete);
|
||||
}, service.getPlugin().getScheduler().async());
|
||||
return fut;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user