Add /lp export --without-groups (#2498)

This commit is contained in:
Luck 2020-08-13 10:00:49 +01:00
parent ac9706b83f
commit e1bac438aa
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 14 additions and 8 deletions

View File

@ -83,15 +83,17 @@ public class Exporter implements Runnable {
private final Sender executor; private final Sender executor;
private final Path filePath; private final Path filePath;
private final boolean includeUsers; private final boolean includeUsers;
private final boolean includeGroups;
private final boolean saveFile; private final boolean saveFile;
private final String label; private final String label;
private final ProgressLogger log; 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.plugin = plugin;
this.executor = executor; this.executor = executor;
this.filePath = filePath; this.filePath = filePath;
this.includeUsers = includeUsers; this.includeUsers = includeUsers;
this.includeGroups = includeGroups;
this.saveFile = saveFile; this.saveFile = saveFile;
this.label = null; this.label = null;
@ -100,11 +102,12 @@ public class Exporter implements Runnable {
this.log.addListener(executor); 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.plugin = plugin;
this.executor = executor; this.executor = executor;
this.filePath = null; this.filePath = null;
this.includeUsers = includeUsers; this.includeUsers = includeUsers;
this.includeGroups = includeGroups;
this.saveFile = saveFile; this.saveFile = saveFile;
this.label = label; this.label = label;
@ -121,11 +124,13 @@ public class Exporter implements Runnable {
.add("generatedAt", DATE_FORMAT.format(new Date(System.currentTimeMillis()))) .add("generatedAt", DATE_FORMAT.format(new Date(System.currentTimeMillis())))
.toJson()); .toJson());
if (this.includeGroups) {
this.log.log("Gathering group data..."); this.log.log("Gathering group data...");
json.add("groups", exportGroups()); json.add("groups", exportGroups());
this.log.log("Gathering track data..."); this.log.log("Gathering track data...");
json.add("tracks", exportTracks()); json.add("tracks", exportTracks());
}
if (this.includeUsers) { if (this.includeUsers) {
this.log.log("Gathering user data..."); this.log.log("Gathering user data...");

View File

@ -57,6 +57,7 @@ public class ExportCommand extends SingleCommand {
} }
boolean includeUsers = !args.remove("--without-users"); boolean includeUsers = !args.remove("--without-users");
boolean includeGroups = !args.remove("--without-groups");
boolean saveFile = !args.remove("--upload"); boolean saveFile = !args.remove("--upload");
Exporter exporter; Exporter exporter;
@ -92,14 +93,14 @@ public class ExportCommand extends SingleCommand {
return CommandResult.STATE_ERROR; return CommandResult.STATE_ERROR;
} }
exporter = new Exporter(plugin, sender, path, includeUsers, saveFile); exporter = new Exporter(plugin, sender, path, includeUsers, includeGroups, saveFile);
} else { } else {
if (!this.running.compareAndSet(false, true)) { if (!this.running.compareAndSet(false, true)) {
Message.EXPORT_ALREADY_RUNNING.send(sender); Message.EXPORT_ALREADY_RUNNING.send(sender);
return CommandResult.STATE_ERROR; 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. // Run the exporter in its own thread.