diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/SubCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/SubCommand.java index 96eb937e..cfcbad43 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/SubCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/SubCommand.java @@ -162,32 +162,44 @@ public abstract class SubCommand { } public static void save(User user, Sender sender, LuckPermsPlugin plugin) { - if (plugin.getDatastore().saveUser(user).getUnchecked()) { - Message.USER_SAVE_SUCCESS.send(sender); - } else { - Message.USER_SAVE_ERROR.send(sender); - } + plugin.doAsync(() -> { + boolean success = plugin.getDatastore().saveUser(user).getUnchecked(); + user.getRefreshBuffer().request().getUnchecked(); + + if (success) { + Message.USER_SAVE_SUCCESS.send(sender); + } else { + Message.USER_SAVE_ERROR.send(sender); + } + }); - user.getRefreshBuffer().request().getUnchecked(); } public static void save(Group group, Sender sender, LuckPermsPlugin plugin) { - if (plugin.getDatastore().saveGroup(group).getUnchecked()) { - Message.GROUP_SAVE_SUCCESS.send(sender); - } else { - Message.GROUP_SAVE_ERROR.send(sender); - } + plugin.doAsync(() -> { + boolean success = plugin.getDatastore().saveGroup(group).getUnchecked(); + plugin.getUpdateTaskBuffer().request().getUnchecked(); + + if (success) { + Message.GROUP_SAVE_SUCCESS.send(sender); + } else { + Message.GROUP_SAVE_ERROR.send(sender); + } + }); - plugin.getUpdateTaskBuffer().request(); } public static void save(Track track, Sender sender, LuckPermsPlugin plugin) { - if (plugin.getDatastore().saveTrack(track).getUnchecked()) { - Message.TRACK_SAVE_SUCCESS.send(sender); - } else { - Message.TRACK_SAVE_ERROR.send(sender); - } + plugin.doAsync(() -> { + boolean success = plugin.getDatastore().saveTrack(track).getUnchecked(); + plugin.getUpdateTaskBuffer().request().getUnchecked(); + + if (success) { + Message.TRACK_SAVE_SUCCESS.send(sender); + } else { + Message.TRACK_SAVE_ERROR.send(sender); + } + }); - plugin.getUpdateTaskBuffer().request(); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/data/Importer.java b/common/src/main/java/me/lucko/luckperms/common/data/Importer.java index 1586014c..fd0cf954 100644 --- a/common/src/main/java/me/lucko/luckperms/common/data/Importer.java +++ b/common/src/main/java/me/lucko/luckperms/common/data/Importer.java @@ -174,7 +174,9 @@ public class Importer { } private void logMessage(String msg) { - getResult(executing, "").getOutput().add(Util.stripColor(msg)); + if (executing != -1) { + getResult(executing, "").getOutput().add(Util.stripColor(msg)); + } } private static class FakeSender implements Sender { diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/AbstractDatastore.java b/common/src/main/java/me/lucko/luckperms/common/storage/AbstractDatastore.java index 51c9de62..3c50ca7e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/AbstractDatastore.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/AbstractDatastore.java @@ -87,6 +87,11 @@ public class AbstractDatastore implements Datastore { backing.doSync(r); } + @Override + public Datastore force() { + return this; + } + @Override public void init() { backing.init(); diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/Datastore.java b/common/src/main/java/me/lucko/luckperms/common/storage/Datastore.java index f2325a1a..f4d07899 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/Datastore.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/Datastore.java @@ -52,9 +52,7 @@ public interface Datastore { */ void doSync(Runnable r); - default Datastore force() { - return this; - } + Datastore force(); void init(); void shutdown(); diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/TolerantDatastore.java b/common/src/main/java/me/lucko/luckperms/common/storage/TolerantDatastore.java index 59b33125..873d417d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/TolerantDatastore.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/TolerantDatastore.java @@ -74,6 +74,11 @@ public class TolerantDatastore implements Datastore { backing.doSync(r); } + @Override + public Datastore force() { + return this; + } + @Override public void init() { backing.init();