mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +01:00
Slight speed improvement for import processes
This commit is contained in:
parent
073b775566
commit
c35ab38f36
@ -167,7 +167,12 @@ public abstract class SubCommand<T> extends Command<T, Void> {
|
||||
|
||||
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<T> extends Command<T, Void> {
|
||||
|
||||
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<T> extends Command<T, Void> {
|
||||
|
||||
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);
|
||||
|
@ -93,4 +93,9 @@ public class AbstractSender<T> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
|
@ -101,6 +101,10 @@ public class PriorityComparator implements Comparator<LocalizedNode> {
|
||||
}
|
||||
|
||||
public int compareStrings(String o1, String o2) {
|
||||
if (o1.equals(o2)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
CollationKey o1c = collationKeyCache.get(o1);
|
||||
CollationKey o2c = collationKeyCache.get(o2);
|
||||
|
@ -213,6 +213,11 @@ public class Importer implements Runnable {
|
||||
public boolean isConsole() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImport() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
@ -68,28 +68,24 @@ public class SpongeMigrationUtils {
|
||||
}
|
||||
|
||||
// Migrate options
|
||||
try {
|
||||
Map<Set<Context>, Map<String, String>> opts = subject.getSubjectData().getAllOptions();
|
||||
for (Map.Entry<Set<Context>, Map<String, String>> e : opts.entrySet()) {
|
||||
ContextSet context = Util.convertContexts(e.getKey());
|
||||
Map<Set<Context>, Map<String, String>> opts = subject.getSubjectData().getAllOptions();
|
||||
for (Map.Entry<Set<Context>, Map<String, String>> 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<String, String> 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<String, String> 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
|
||||
|
Loading…
Reference in New Issue
Block a user