diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SubCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SubCommand.java index 9ecc408fc..d6b909d32 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SubCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SubCommand.java @@ -167,7 +167,12 @@ public abstract class SubCommand extends Command { public static void save(User user, Sender sender, LuckPermsPlugin plugin) { boolean success = plugin.getStorage().force().saveUser(user).join(); - user.getRefreshBuffer().requestDirectly(); + + if (sender.isImport()) { + user.getRefreshBuffer().request(); + } else { + user.getRefreshBuffer().requestDirectly(); + } if (success) { Message.USER_SAVE_SUCCESS.send(sender); @@ -178,7 +183,12 @@ public abstract class SubCommand extends Command { public static void save(Group group, Sender sender, LuckPermsPlugin plugin) { boolean success = plugin.getStorage().force().saveGroup(group).join(); - plugin.getUpdateTaskBuffer().requestDirectly(); + + if (sender.isImport()) { + plugin.getUpdateTaskBuffer().request(); + } else { + plugin.getUpdateTaskBuffer().requestDirectly(); + } if (success) { Message.GROUP_SAVE_SUCCESS.send(sender); @@ -189,7 +199,12 @@ public abstract class SubCommand extends Command { public static void save(Track track, Sender sender, LuckPermsPlugin plugin) { boolean success = plugin.getStorage().force().saveTrack(track).join(); - plugin.getUpdateTaskBuffer().requestDirectly(); + + if (sender.isImport()) { + plugin.getUpdateTaskBuffer().request(); + } else { + plugin.getUpdateTaskBuffer().requestDirectly(); + } if (success) { Message.TRACK_SAVE_SUCCESS.send(sender); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java b/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java index 08585ee20..c0d0ca476 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java @@ -93,4 +93,9 @@ public class AbstractSender implements Sender { return this.uuid.equals(Constants.CONSOLE_UUID) || this.uuid.equals(Constants.IMPORT_UUID); } + @Override + public boolean isImport() { + return this.uuid.equals(Constants.IMPORT_UUID); + } + } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/sender/Sender.java b/common/src/main/java/me/lucko/luckperms/common/commands/sender/Sender.java index 4958024ce..7ea0b7baa 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/sender/Sender.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/sender/Sender.java @@ -85,4 +85,11 @@ public interface Sender { */ boolean isConsole(); + /** + * Gets whether this sender is an import process + * + * @return if the sender is an import process + */ + boolean isImport(); + } diff --git a/common/src/main/java/me/lucko/luckperms/common/core/PriorityComparator.java b/common/src/main/java/me/lucko/luckperms/common/core/PriorityComparator.java index 265f2cab9..afc89e263 100644 --- a/common/src/main/java/me/lucko/luckperms/common/core/PriorityComparator.java +++ b/common/src/main/java/me/lucko/luckperms/common/core/PriorityComparator.java @@ -101,6 +101,10 @@ public class PriorityComparator implements Comparator { } public int compareStrings(String o1, String o2) { + if (o1.equals(o2)) { + return 1; + } + try { CollationKey o1c = collationKeyCache.get(o1); CollationKey o2c = collationKeyCache.get(o2); 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 6731e319b..c719b99f6 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 @@ -213,6 +213,11 @@ public class Importer implements Runnable { public boolean isConsole() { return true; } + + @Override + public boolean isImport() { + return true; + } } @Getter diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/SpongeMigrationUtils.java b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/SpongeMigrationUtils.java index e2a3342c6..2f3e428b4 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/SpongeMigrationUtils.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/SpongeMigrationUtils.java @@ -68,28 +68,24 @@ public class SpongeMigrationUtils { } // Migrate options - try { - Map, Map> opts = subject.getSubjectData().getAllOptions(); - for (Map.Entry, Map> e : opts.entrySet()) { - ContextSet context = Util.convertContexts(e.getKey()); + Map, Map> opts = subject.getSubjectData().getAllOptions(); + for (Map.Entry, Map> e : opts.entrySet()) { + ContextSet context = Util.convertContexts(e.getKey()); - ExtractedContexts extractedContexts = ExtractedContexts.generate(context); - ContextSet contexts = extractedContexts.getContextSet(); - String server = extractedContexts.getServer(); - String world = extractedContexts.getWorld(); + ExtractedContexts extractedContexts = ExtractedContexts.generate(context); + ContextSet contexts = extractedContexts.getContextSet(); + String server = extractedContexts.getServer(); + String world = extractedContexts.getWorld(); - for (Map.Entry opt : e.getValue().entrySet()) { - if (opt.getKey().equalsIgnoreCase("prefix")) { - holder.setPermissionUnchecked(NodeFactory.makePrefixNode(priority, opt.getValue()).setServer(server).setWorld(world).withExtraContext(contexts).setValue(true).build()); - } else if (opt.getKey().equalsIgnoreCase("suffix")) { - holder.setPermissionUnchecked(NodeFactory.makeSuffixNode(priority, opt.getValue()).setServer(server).setWorld(world).withExtraContext(contexts).setValue(true).build()); - } else { - holder.setPermissionUnchecked(NodeFactory.makeMetaNode(opt.getKey(), opt.getValue()).setServer(server).setWorld(world).withExtraContext(contexts).setValue(true).build()); - } + for (Map.Entry opt : e.getValue().entrySet()) { + if (opt.getKey().equalsIgnoreCase("prefix")) { + holder.setPermissionUnchecked(NodeFactory.makePrefixNode(priority, opt.getValue()).setServer(server).setWorld(world).withExtraContext(contexts).setValue(true).build()); + } else if (opt.getKey().equalsIgnoreCase("suffix")) { + holder.setPermissionUnchecked(NodeFactory.makeSuffixNode(priority, opt.getValue()).setServer(server).setWorld(world).withExtraContext(contexts).setValue(true).build()); + } else { + holder.setPermissionUnchecked(NodeFactory.makeMetaNode(opt.getKey(), opt.getValue()).setServer(server).setWorld(world).withExtraContext(contexts).setValue(true).build()); } } - } catch (Throwable ignored) { - // Ignore. This is just so older versions of Sponge API can be used. } // Migrate parents