From e1bac438aafc73bc96e7d1193f217babfcf80a03 Mon Sep 17 00:00:00 2001 From: Luck Date: Thu, 13 Aug 2020 10:00:49 +0100 Subject: [PATCH] Add /lp export --without-groups (#2498) --- .../lucko/luckperms/common/backup/Exporter.java | 17 +++++++++++------ .../common/commands/misc/ExportCommand.java | 5 +++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java b/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java index 7ac16f920..af4a4a28b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java +++ b/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java @@ -83,15 +83,17 @@ public class Exporter implements Runnable { private final Sender executor; private final Path filePath; private final boolean includeUsers; + private final boolean includeGroups; private final boolean saveFile; private final String label; private final ProgressLogger log; - public Exporter(LuckPermsPlugin plugin, Sender executor, Path filePath, boolean includeUsers, boolean saveFile) { + public Exporter(LuckPermsPlugin plugin, Sender executor, Path filePath, boolean includeUsers, boolean includeGroups, boolean saveFile) { this.plugin = plugin; this.executor = executor; this.filePath = filePath; this.includeUsers = includeUsers; + this.includeGroups = includeGroups; this.saveFile = saveFile; this.label = null; @@ -100,11 +102,12 @@ public class Exporter implements Runnable { this.log.addListener(executor); } - public Exporter(LuckPermsPlugin plugin, Sender executor, boolean includeUsers, boolean saveFile, String label) { + public Exporter(LuckPermsPlugin plugin, Sender executor, boolean includeUsers, boolean includeGroups, boolean saveFile, String label) { this.plugin = plugin; this.executor = executor; this.filePath = null; this.includeUsers = includeUsers; + this.includeGroups = includeGroups; this.saveFile = saveFile; this.label = label; @@ -121,11 +124,13 @@ public class Exporter implements Runnable { .add("generatedAt", DATE_FORMAT.format(new Date(System.currentTimeMillis()))) .toJson()); - this.log.log("Gathering group data..."); - json.add("groups", exportGroups()); + if (this.includeGroups) { + this.log.log("Gathering group data..."); + json.add("groups", exportGroups()); - this.log.log("Gathering track data..."); - json.add("tracks", exportTracks()); + this.log.log("Gathering track data..."); + json.add("tracks", exportTracks()); + } if (this.includeUsers) { this.log.log("Gathering user data..."); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/ExportCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ExportCommand.java index 72b80790e..77a98920d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/ExportCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ExportCommand.java @@ -57,6 +57,7 @@ public class ExportCommand extends SingleCommand { } boolean includeUsers = !args.remove("--without-users"); + boolean includeGroups = !args.remove("--without-groups"); boolean saveFile = !args.remove("--upload"); Exporter exporter; @@ -92,14 +93,14 @@ public class ExportCommand extends SingleCommand { return CommandResult.STATE_ERROR; } - exporter = new Exporter(plugin, sender, path, includeUsers, saveFile); + exporter = new Exporter(plugin, sender, path, includeUsers, includeGroups, saveFile); } else { if (!this.running.compareAndSet(false, true)) { Message.EXPORT_ALREADY_RUNNING.send(sender); return CommandResult.STATE_ERROR; } - exporter = new Exporter(plugin, sender, includeUsers, saveFile, label); + exporter = new Exporter(plugin, sender, includeUsers, includeGroups, saveFile, label); } // Run the exporter in its own thread.