mirror of
https://github.com/lucko/LuckPerms.git
synced 2025-08-27 08:14:22 +02:00
Add default file name for export command (#3248)
This commit is contained in:
@@ -241,6 +241,7 @@ watch-files: true
|
|||||||
# below.
|
# below.
|
||||||
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
|
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
|
||||||
# configured below.
|
# configured below.
|
||||||
|
# => custom Uses a messaging service provided using the LuckPerms API.
|
||||||
# => auto Attempts to automatically setup a messaging service using redis or sql.
|
# => auto Attempts to automatically setup a messaging service using redis or sql.
|
||||||
messaging-service: auto
|
messaging-service: auto
|
||||||
|
|
||||||
|
@@ -239,6 +239,7 @@ watch-files: true
|
|||||||
# the RedisBungee plugin installed.
|
# the RedisBungee plugin installed.
|
||||||
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
|
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
|
||||||
# configured below.
|
# configured below.
|
||||||
|
# => custom Uses a messaging service provided using the LuckPerms API.
|
||||||
# => auto Attempts to automatically setup a messaging service using redis or sql.
|
# => auto Attempts to automatically setup a messaging service using redis or sql.
|
||||||
messaging-service: auto
|
messaging-service: auto
|
||||||
|
|
||||||
|
@@ -38,13 +38,19 @@ import me.lucko.luckperms.common.util.Predicates;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class ExportCommand extends SingleCommand {
|
public class ExportCommand extends SingleCommand {
|
||||||
|
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm")
|
||||||
|
.withZone(ZoneId.systemDefault());
|
||||||
|
|
||||||
private final AtomicBoolean running = new AtomicBoolean(false);
|
private final AtomicBoolean running = new AtomicBoolean(false);
|
||||||
|
|
||||||
public ExportCommand() {
|
public ExportCommand() {
|
||||||
super(CommandSpec.EXPORT, "Export", CommandPermission.EXPORT, Predicates.notInRange(1, 2));
|
super(CommandSpec.EXPORT, "Export", CommandPermission.EXPORT, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,7 +74,12 @@ public class ExportCommand extends SingleCommand {
|
|||||||
exporter = new Exporter.WebUpload(plugin, sender, includeUsers, includeGroups, label);
|
exporter = new Exporter.WebUpload(plugin, sender, includeUsers, includeGroups, label);
|
||||||
} else {
|
} else {
|
||||||
Path dataDirectory = plugin.getBootstrap().getDataDirectory();
|
Path dataDirectory = plugin.getBootstrap().getDataDirectory();
|
||||||
Path path = dataDirectory.resolve(args.get(0) + ".json.gz");
|
Path path;
|
||||||
|
if (args.isEmpty()) {
|
||||||
|
path = dataDirectory.resolve("luckperms-" + DATE_FORMAT.format(Instant.now()) + ".json.gz");
|
||||||
|
} else {
|
||||||
|
path = dataDirectory.resolve(args.get(0) + ".json.gz");
|
||||||
|
}
|
||||||
|
|
||||||
if (!path.getParent().equals(dataDirectory)) {
|
if (!path.getParent().equals(dataDirectory)) {
|
||||||
Message.FILE_NOT_WITHIN_DIRECTORY.send(sender, path.toString());
|
Message.FILE_NOT_WITHIN_DIRECTORY.send(sender, path.toString());
|
||||||
|
@@ -244,6 +244,7 @@ watch-files = true
|
|||||||
# below.
|
# below.
|
||||||
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
|
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
|
||||||
# configured below.
|
# configured below.
|
||||||
|
# => custom Uses a messaging service provided using the LuckPerms API.
|
||||||
# => auto Attempts to automatically setup a messaging service using redis or sql.
|
# => auto Attempts to automatically setup a messaging service using redis or sql.
|
||||||
messaging-service = "auto"
|
messaging-service = "auto"
|
||||||
|
|
||||||
|
@@ -236,6 +236,7 @@ watch-files: true
|
|||||||
# below.
|
# below.
|
||||||
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
|
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
|
||||||
# configured below.
|
# configured below.
|
||||||
|
# => custom Uses a messaging service provided using the LuckPerms API.
|
||||||
# => auto Attempts to automatically setup a messaging service using redis or sql.
|
# => auto Attempts to automatically setup a messaging service using redis or sql.
|
||||||
messaging-service: auto
|
messaging-service: auto
|
||||||
|
|
||||||
|
@@ -244,6 +244,7 @@ watch-files = true
|
|||||||
# below.
|
# below.
|
||||||
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
|
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
|
||||||
# configured below.
|
# configured below.
|
||||||
|
# => custom Uses a messaging service provided using the LuckPerms API.
|
||||||
# => auto Attempts to automatically setup a messaging service using redis or sql.
|
# => auto Attempts to automatically setup a messaging service using redis or sql.
|
||||||
messaging-service = "auto"
|
messaging-service = "auto"
|
||||||
|
|
||||||
|
@@ -230,6 +230,7 @@ watch-files: true
|
|||||||
# configured below.
|
# configured below.
|
||||||
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
|
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
|
||||||
# configured below.
|
# configured below.
|
||||||
|
# => custom Uses a messaging service provided using the LuckPerms API.
|
||||||
# => auto Attempts to automatically setup a messaging service using redis or sql.
|
# => auto Attempts to automatically setup a messaging service using redis or sql.
|
||||||
messaging-service: auto
|
messaging-service: auto
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user