refactor: minor userdata dump refactor

feat/data-edit-commands
William 5 months ago
parent 2bdd3dae37
commit a8ca3314d8
No known key found for this signature in database

@ -174,7 +174,8 @@ public class UserDataCommand extends PluginCommand {
} }
// Dump a snapshot // Dump a snapshot
private void dumpSnapshot(@NotNull CommandUser executor, @NotNull User user, @NotNull UUID version, boolean webDump) { private void dumpSnapshot(@NotNull CommandUser executor, @NotNull User user, @NotNull UUID version,
@NotNull DumpType type) {
final Optional<DataSnapshot.Packed> data = plugin.getDatabase().getSnapshot(user, version); final Optional<DataSnapshot.Packed> data = plugin.getDatabase().getSnapshot(user, version);
if (data.isEmpty()) { if (data.isEmpty()) {
plugin.getLocales().getLocale("error_invalid_version_uuid") plugin.getLocales().getLocale("error_invalid_version_uuid")
@ -187,7 +188,8 @@ public class UserDataCommand extends PluginCommand {
final DataDumper dumper = DataDumper.create(userData, user, plugin); final DataDumper dumper = DataDumper.create(userData, user, plugin);
try { try {
plugin.getLocales().getLocale("data_dumped", userData.getShortId(), user.getUsername(), plugin.getLocales().getLocale("data_dumped", userData.getShortId(), user.getUsername(),
(webDump ? dumper.toWeb() : dumper.toFile())).ifPresent(executor::sendMessage); (type == DumpType.WEB ? dumper.toWeb() : dumper.toFile()))
.ifPresent(executor::sendMessage);
} catch (Throwable e) { } catch (Throwable e) {
plugin.log(Level.SEVERE, "Failed to dump user data", e); plugin.log(Level.SEVERE, "Failed to dump user data", e);
} }
@ -256,7 +258,7 @@ public class UserDataCommand extends PluginCommand {
final User user = ctx.getArgument("username", User.class); final User user = ctx.getArgument("username", User.class);
final UUID version = ctx.getArgument("version", UUID.class); final UUID version = ctx.getArgument("version", UUID.class);
final DumpType type = ctx.getArgument("type", DumpType.class); final DumpType type = ctx.getArgument("type", DumpType.class);
dumpSnapshot(user(sub, ctx), user, version, type == DumpType.WEB); dumpSnapshot(user(sub, ctx), user, version, type);
}, user("username"), uuid("version"), dumpType()); }, user("username"), uuid("version"), dumpType());
} }

Loading…
Cancel
Save