diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/InfoCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/InfoCommand.java index f682cbe30..c374d4d09 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/InfoCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/InfoCommand.java @@ -35,6 +35,8 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; +import net.kyori.adventure.text.Component; + import java.util.Map; public class InfoCommand extends SingleCommand { @@ -44,7 +46,7 @@ public class InfoCommand extends SingleCommand { @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, ArgumentList args, String label) { - Map storageMeta = plugin.getStorage().getMeta(); + Map storageMeta = plugin.getStorage().getMeta(); Message.INFO.send(sender, plugin, storageMeta); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java index 8f3ee18b2..f4fbdc00e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java @@ -71,7 +71,6 @@ import static net.kyori.adventure.text.Component.space; import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.Component.translatable; import static net.kyori.adventure.text.format.NamedTextColor.AQUA; -import static net.kyori.adventure.text.format.NamedTextColor.BLUE; import static net.kyori.adventure.text.format.NamedTextColor.DARK_AQUA; import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; import static net.kyori.adventure.text.format.NamedTextColor.DARK_GREEN; @@ -322,7 +321,7 @@ public interface Message { .append(space()) .append(text(target, GREEN)) .append(text(" - ", GRAY)) - .append(text("meta: ", BLUE)) + .append(text("meta: ", AQUA)) .append(text(metaKey, GREEN)) .append(text(" - ", GRAY)) .append(text(result, GRAY)) @@ -1319,7 +1318,7 @@ public interface Message { ) ); - Args2> INFO = (plugin, storageMeta) -> join(newline(), + Args2> INFO = (plugin, storageMeta) -> join(newline(), // "&2Running &bLuckPerms v{}&2 by &bLuck&2." // "&f- &3Platform: &f{}" // "&f- &3Server Brand: &f{}" @@ -1382,28 +1381,14 @@ public interface Message { .append(text(plugin.getStorage().getName(), WHITE)) ); - for (Map.Entry metaEntry : storageMeta.entrySet()) { + for (Map.Entry metaEntry : storageMeta.entrySet()) { builder.append(newline()); - - String value = metaEntry.getValue(); - Component valueComponent; - if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { - valueComponent = formatBoolean(Boolean.parseBoolean(value)); - } else { - try { - int i = Integer.parseInt(value); - valueComponent = text(i, GREEN); - } catch (NumberFormatException e) { - valueComponent = text(value, WHITE); - } - } - builder.append(prefixed(text() .color(DARK_AQUA) .append(text(" ")) - .append(text(metaEntry.getKey())) + .append(metaEntry.getKey()) .append(text(": ")) - .append(valueComponent) + .append(metaEntry.getValue()) )); } })), diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/Storage.java b/common/src/main/java/me/lucko/luckperms/common/storage/Storage.java index a2ae3c6f9..425baec9e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/Storage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/Storage.java @@ -39,6 +39,7 @@ import me.lucko.luckperms.common.storage.implementation.split.SplitStorage; import me.lucko.luckperms.common.storage.misc.NodeEntry; import me.lucko.luckperms.common.util.Throwing; +import net.kyori.adventure.text.Component; import net.luckperms.api.actionlog.Action; import net.luckperms.api.event.cause.CreationCause; import net.luckperms.api.event.cause.DeletionCause; @@ -128,7 +129,7 @@ public class Storage { } } - public Map getMeta() { + public Map getMeta() { return this.implementation.getMeta(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/StorageImplementation.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/StorageImplementation.java index 1e18c9183..56f85b383 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/StorageImplementation.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/StorageImplementation.java @@ -34,6 +34,7 @@ import me.lucko.luckperms.common.node.matcher.ConstraintNodeMatcher; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.storage.misc.NodeEntry; +import net.kyori.adventure.text.Component; import net.luckperms.api.actionlog.Action; import net.luckperms.api.model.PlayerSaveResult; import net.luckperms.api.node.Node; @@ -56,7 +57,7 @@ public interface StorageImplementation { void shutdown(); - default Map getMeta() { + default Map getMeta() { return Collections.emptyMap(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/mongodb/MongoStorage.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/mongodb/MongoStorage.java index f8fb75f89..c0f0c20c6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/mongodb/MongoStorage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/mongodb/MongoStorage.java @@ -42,6 +42,7 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.bulkupdate.BulkUpdate; import me.lucko.luckperms.common.bulkupdate.BulkUpdateStatistics; import me.lucko.luckperms.common.context.contextset.MutableContextSetImpl; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; @@ -55,6 +56,8 @@ import me.lucko.luckperms.common.storage.misc.PlayerSaveResultImpl; import me.lucko.luckperms.common.storage.misc.StorageCredentials; import me.lucko.luckperms.common.util.Iterators; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; import net.luckperms.api.actionlog.Action; import net.luckperms.api.context.Context; import net.luckperms.api.context.ContextSet; @@ -142,8 +145,8 @@ public class MongoStorage implements StorageImplementation { } @Override - public Map getMeta() { - Map meta = new LinkedHashMap<>(); + public Map getMeta() { + Map meta = new LinkedHashMap<>(); boolean success = true; long start = System.currentTimeMillis(); @@ -155,11 +158,15 @@ public class MongoStorage implements StorageImplementation { long duration = System.currentTimeMillis() - start; if (success) { - meta.put("Ping", duration + "ms"); - meta.put("Connected", "true"); - } else { - meta.put("Connected", "false"); + meta.put( + Component.translatable("luckperms.command.info.storage.meta.ping-key"), + Component.text(duration + "ms", NamedTextColor.GREEN) + ); } + meta.put( + Component.translatable("luckperms.command.info.storage.meta.connected-key"), + Message.formatBoolean(success) + ); return meta; } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/split/SplitStorage.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/split/SplitStorage.java index 6778ebe7e..365f099a1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/split/SplitStorage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/split/SplitStorage.java @@ -29,6 +29,7 @@ import com.google.common.collect.ImmutableMap; import me.lucko.luckperms.common.actionlog.Log; import me.lucko.luckperms.common.bulkupdate.BulkUpdate; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; @@ -38,6 +39,7 @@ import me.lucko.luckperms.common.storage.StorageType; import me.lucko.luckperms.common.storage.implementation.StorageImplementation; import me.lucko.luckperms.common.storage.misc.NodeEntry; +import net.kyori.adventure.text.Component; import net.luckperms.api.actionlog.Action; import net.luckperms.api.model.PlayerSaveResult; import net.luckperms.api.node.Node; @@ -48,6 +50,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.UUID; +import java.util.stream.Collectors; public class SplitStorage implements StorageImplementation { private final LuckPermsPlugin plugin; @@ -106,9 +109,14 @@ public class SplitStorage implements StorageImplementation { } @Override - public Map getMeta() { - Map meta = new LinkedHashMap<>(); - meta.put("Types", this.types.toString()); + public Map getMeta() { + Map meta = new LinkedHashMap<>(); + meta.put( + Component.translatable("luckperms.command.info.storage.meta.split-types-key"), + Message.formatStringList(this.types.entrySet().stream() + .map(e -> e.getKey().toString().toLowerCase() + "->" + e.getValue().getName().toLowerCase()) + .collect(Collectors.toList())) + ); for (StorageImplementation backing : this.implementations.values()) { meta.putAll(backing.getMeta()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlStorage.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlStorage.java index 5c93d7bd7..a8a075e93 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlStorage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlStorage.java @@ -47,6 +47,7 @@ import me.lucko.luckperms.common.storage.misc.PlayerSaveResultImpl; import me.lucko.luckperms.common.util.Uuids; import me.lucko.luckperms.common.util.gson.GsonProvider; +import net.kyori.adventure.text.Component; import net.luckperms.api.actionlog.Action; import net.luckperms.api.model.PlayerSaveResult; import net.luckperms.api.model.data.DataType; @@ -219,7 +220,7 @@ public class SqlStorage implements StorageImplementation { } @Override - public Map getMeta() { + public Map getMeta() { return this.connectionFactory.getMeta(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/ConnectionFactory.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/ConnectionFactory.java index 2aff1a659..27e84bcd4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/ConnectionFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/ConnectionFactory.java @@ -27,6 +27,8 @@ package me.lucko.luckperms.common.storage.implementation.sql.connection; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import net.kyori.adventure.text.Component; + import java.sql.Connection; import java.sql.SQLException; import java.util.Collections; @@ -41,7 +43,7 @@ public interface ConnectionFactory { void shutdown() throws Exception; - default Map getMeta() { + default Map getMeta() { return Collections.emptyMap(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/file/FlatfileConnectionFactory.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/file/FlatfileConnectionFactory.java index 06f2d1d9a..9bd0a336f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/file/FlatfileConnectionFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/file/FlatfileConnectionFactory.java @@ -28,11 +28,14 @@ package me.lucko.luckperms.common.storage.implementation.sql.connection.file; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.storage.implementation.sql.connection.ConnectionFactory; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.text.DecimalFormat; -import java.util.LinkedHashMap; +import java.util.Collections; import java.util.Map; abstract class FlatfileConnectionFactory implements ConnectionFactory { @@ -54,9 +57,8 @@ abstract class FlatfileConnectionFactory implements ConnectionFactory { } @Override - public Map getMeta() { - Map meta = new LinkedHashMap<>(); - + public Map getMeta() { + String fileSize; Path databaseFile = getWriteFile(); if (Files.exists(databaseFile)) { long length; @@ -67,11 +69,14 @@ abstract class FlatfileConnectionFactory implements ConnectionFactory { } double size = length / 1048576D; - meta.put("File Size", DF.format(size) + "MB"); + fileSize = DF.format(size) + "MB"; } else { - meta.put("File Size", "0MB"); + fileSize = "0MB"; } - return meta; + return Collections.singletonMap( + Component.translatable("luckperms.command.info.storage.meta.file-size-key"), + Component.text(fileSize, NamedTextColor.GREEN) + ); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java index fde3f2a35..d561b7d80 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java @@ -29,11 +29,15 @@ import com.google.common.collect.ImmutableList; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.logging.PluginLogger; import me.lucko.luckperms.common.storage.implementation.sql.connection.ConnectionFactory; import me.lucko.luckperms.common.storage.misc.StorageCredentials; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; + import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; @@ -119,8 +123,8 @@ public abstract class HikariConnectionFactory implements ConnectionFactory { } @Override - public Map getMeta() { - Map meta = new LinkedHashMap<>(); + public Map getMeta() { + Map meta = new LinkedHashMap<>(); boolean success = true; long start = System.currentTimeMillis(); @@ -134,11 +138,15 @@ public abstract class HikariConnectionFactory implements ConnectionFactory { long duration = System.currentTimeMillis() - start; if (success) { - meta.put("Ping", duration + "ms"); - meta.put("Connected", "true"); - } else { - meta.put("Connected", "false"); + meta.put( + Component.translatable("luckperms.command.info.storage.meta.ping-key"), + Component.text(duration + "ms", NamedTextColor.GREEN) + ); } + meta.put( + Component.translatable("luckperms.command.info.storage.meta.connected-key"), + Message.formatBoolean(success) + ); return meta; } diff --git a/common/src/main/resources/luckperms_en.properties b/common/src/main/resources/luckperms_en.properties index 3ec892a06..c461dc25b 100644 --- a/common/src/main/resources/luckperms_en.properties +++ b/common/src/main/resources/luckperms_en.properties @@ -119,6 +119,10 @@ luckperms.command.info.server-brand-key=Server Brand luckperms.command.info.server-version-key=Server Version luckperms.command.info.storage-key=Storage luckperms.command.info.storage-type-key=Type +luckperms.command.info.storage.meta.split-types-key=Types +luckperms.command.info.storage.meta.ping-key=Ping +luckperms.command.info.storage.meta.connected-key=Connected +luckperms.command.info.storage.meta.file-size-key=File Size luckperms.command.info.extensions-key=Extensions luckperms.command.info.messaging-key=Messaging luckperms.command.info.instance-key=Instance