mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-10-31 07:51:05 +01:00
Export groups in order of weight, then alphabetically
This commit is contained in:
parent
b8e65c4f26
commit
770db2fee0
@ -29,7 +29,6 @@ import me.lucko.luckperms.api.Node;
|
|||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.commands.utils.Util;
|
import me.lucko.luckperms.common.commands.utils.Util;
|
||||||
import me.lucko.luckperms.common.core.NodeFactory;
|
import me.lucko.luckperms.common.core.NodeFactory;
|
||||||
import me.lucko.luckperms.common.core.model.Group;
|
|
||||||
import me.lucko.luckperms.common.core.model.Track;
|
import me.lucko.luckperms.common.core.model.Track;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
import me.lucko.luckperms.common.locale.Message;
|
import me.lucko.luckperms.common.locale.Message;
|
||||||
@ -110,20 +109,35 @@ public class Exporter implements Runnable {
|
|||||||
|
|
||||||
// Create the actual groups first
|
// Create the actual groups first
|
||||||
write(writer, "# Create groups");
|
write(writer, "# Create groups");
|
||||||
for (Group group : plugin.getGroupManager().getAll().values()) {
|
plugin.getGroupManager().getAll().values().stream()
|
||||||
write(writer, "/luckperms creategroup " + group.getName());
|
.sorted((o1, o2) -> {
|
||||||
}
|
int i = Integer.compare(o2.getWeight().orElse(0), o1.getWeight().orElse(0));
|
||||||
|
return i != 0 ? i : o1.getName().compareToIgnoreCase(o2.getName());
|
||||||
|
})
|
||||||
|
.filter(g -> !g.getName().equals("default"))
|
||||||
|
.forEach(group -> {
|
||||||
|
write(writer, "/luckperms creategroup " + group.getName());
|
||||||
|
});
|
||||||
|
|
||||||
write(writer, "");
|
write(writer, "");
|
||||||
|
|
||||||
AtomicInteger groupCount = new AtomicInteger(0);
|
AtomicInteger groupCount = new AtomicInteger(0);
|
||||||
for (Group group : plugin.getGroupManager().getAll().values()) {
|
|
||||||
write(writer, "# Export group: " + group.getName());
|
// export groups in order of weight
|
||||||
for (Node node : group.getNodes().values()) {
|
plugin.getGroupManager().getAll().values().stream()
|
||||||
write(writer, NodeFactory.nodeAsCommand(node, group.getName(), true));
|
.sorted((o1, o2) -> {
|
||||||
}
|
int i = Integer.compare(o2.getWeight().orElse(0), o1.getWeight().orElse(0));
|
||||||
write(writer, "");
|
return i != 0 ? i : o1.getName().compareToIgnoreCase(o2.getName());
|
||||||
log.logAllProgress("Exported {} groups so far.", groupCount.incrementAndGet());
|
})
|
||||||
}
|
.forEach(group -> {
|
||||||
|
write(writer, "# Export group: " + group.getName());
|
||||||
|
for (Node node : group.getNodes().values()) {
|
||||||
|
write(writer, NodeFactory.nodeAsCommand(node, group.getName(), true));
|
||||||
|
}
|
||||||
|
write(writer, "");
|
||||||
|
log.logAllProgress("Exported {} groups so far.", groupCount.incrementAndGet());
|
||||||
|
});
|
||||||
|
|
||||||
log.log("Exported " + groupCount.get() + " groups.");
|
log.log("Exported " + groupCount.get() + " groups.");
|
||||||
|
|
||||||
write(writer, "");
|
write(writer, "");
|
||||||
|
Loading…
Reference in New Issue
Block a user