mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-03 16:13:27 +01:00
Make storage meta keys translatable
This commit is contained in:
parent
ad174742e9
commit
15d3000fc1
@ -35,6 +35,8 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
|||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.util.Predicates;
|
import me.lucko.luckperms.common.util.Predicates;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class InfoCommand extends SingleCommand {
|
public class InfoCommand extends SingleCommand {
|
||||||
@ -44,7 +46,7 @@ public class InfoCommand extends SingleCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, ArgumentList args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, ArgumentList args, String label) {
|
||||||
Map<String, String> storageMeta = plugin.getStorage().getMeta();
|
Map<Component, Component> storageMeta = plugin.getStorage().getMeta();
|
||||||
Message.INFO.send(sender, plugin, storageMeta);
|
Message.INFO.send(sender, plugin, storageMeta);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -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.text;
|
||||||
import static net.kyori.adventure.text.Component.translatable;
|
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.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_AQUA;
|
||||||
import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY;
|
import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY;
|
||||||
import static net.kyori.adventure.text.format.NamedTextColor.DARK_GREEN;
|
import static net.kyori.adventure.text.format.NamedTextColor.DARK_GREEN;
|
||||||
@ -322,7 +321,7 @@ public interface Message {
|
|||||||
.append(space())
|
.append(space())
|
||||||
.append(text(target, GREEN))
|
.append(text(target, GREEN))
|
||||||
.append(text(" - ", GRAY))
|
.append(text(" - ", GRAY))
|
||||||
.append(text("meta: ", BLUE))
|
.append(text("meta: ", AQUA))
|
||||||
.append(text(metaKey, GREEN))
|
.append(text(metaKey, GREEN))
|
||||||
.append(text(" - ", GRAY))
|
.append(text(" - ", GRAY))
|
||||||
.append(text(result, GRAY))
|
.append(text(result, GRAY))
|
||||||
@ -1319,7 +1318,7 @@ public interface Message {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
Args2<LuckPermsPlugin, Map<String, String>> INFO = (plugin, storageMeta) -> join(newline(),
|
Args2<LuckPermsPlugin, Map<Component, Component>> INFO = (plugin, storageMeta) -> join(newline(),
|
||||||
// "&2Running &bLuckPerms v{}&2 by &bLuck&2."
|
// "&2Running &bLuckPerms v{}&2 by &bLuck&2."
|
||||||
// "&f- &3Platform: &f{}"
|
// "&f- &3Platform: &f{}"
|
||||||
// "&f- &3Server Brand: &f{}"
|
// "&f- &3Server Brand: &f{}"
|
||||||
@ -1382,28 +1381,14 @@ public interface Message {
|
|||||||
.append(text(plugin.getStorage().getName(), WHITE))
|
.append(text(plugin.getStorage().getName(), WHITE))
|
||||||
);
|
);
|
||||||
|
|
||||||
for (Map.Entry<String, String> metaEntry : storageMeta.entrySet()) {
|
for (Map.Entry<Component, Component> metaEntry : storageMeta.entrySet()) {
|
||||||
builder.append(newline());
|
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()
|
builder.append(prefixed(text()
|
||||||
.color(DARK_AQUA)
|
.color(DARK_AQUA)
|
||||||
.append(text(" "))
|
.append(text(" "))
|
||||||
.append(text(metaEntry.getKey()))
|
.append(metaEntry.getKey())
|
||||||
.append(text(": "))
|
.append(text(": "))
|
||||||
.append(valueComponent)
|
.append(metaEntry.getValue())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
|
@ -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.storage.misc.NodeEntry;
|
||||||
import me.lucko.luckperms.common.util.Throwing;
|
import me.lucko.luckperms.common.util.Throwing;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.luckperms.api.actionlog.Action;
|
import net.luckperms.api.actionlog.Action;
|
||||||
import net.luckperms.api.event.cause.CreationCause;
|
import net.luckperms.api.event.cause.CreationCause;
|
||||||
import net.luckperms.api.event.cause.DeletionCause;
|
import net.luckperms.api.event.cause.DeletionCause;
|
||||||
@ -128,7 +129,7 @@ public class Storage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getMeta() {
|
public Map<Component, Component> getMeta() {
|
||||||
return this.implementation.getMeta();
|
return this.implementation.getMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ import me.lucko.luckperms.common.node.matcher.ConstraintNodeMatcher;
|
|||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.storage.misc.NodeEntry;
|
import me.lucko.luckperms.common.storage.misc.NodeEntry;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.luckperms.api.actionlog.Action;
|
import net.luckperms.api.actionlog.Action;
|
||||||
import net.luckperms.api.model.PlayerSaveResult;
|
import net.luckperms.api.model.PlayerSaveResult;
|
||||||
import net.luckperms.api.node.Node;
|
import net.luckperms.api.node.Node;
|
||||||
@ -56,7 +57,7 @@ public interface StorageImplementation {
|
|||||||
|
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
default Map<String, String> getMeta() {
|
default Map<Component, Component> getMeta() {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ import me.lucko.luckperms.common.actionlog.LoggedAction;
|
|||||||
import me.lucko.luckperms.common.bulkupdate.BulkUpdate;
|
import me.lucko.luckperms.common.bulkupdate.BulkUpdate;
|
||||||
import me.lucko.luckperms.common.bulkupdate.BulkUpdateStatistics;
|
import me.lucko.luckperms.common.bulkupdate.BulkUpdateStatistics;
|
||||||
import me.lucko.luckperms.common.context.contextset.MutableContextSetImpl;
|
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.Group;
|
||||||
import me.lucko.luckperms.common.model.Track;
|
import me.lucko.luckperms.common.model.Track;
|
||||||
import me.lucko.luckperms.common.model.User;
|
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.storage.misc.StorageCredentials;
|
||||||
import me.lucko.luckperms.common.util.Iterators;
|
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.actionlog.Action;
|
||||||
import net.luckperms.api.context.Context;
|
import net.luckperms.api.context.Context;
|
||||||
import net.luckperms.api.context.ContextSet;
|
import net.luckperms.api.context.ContextSet;
|
||||||
@ -142,8 +145,8 @@ public class MongoStorage implements StorageImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getMeta() {
|
public Map<Component, Component> getMeta() {
|
||||||
Map<String, String> meta = new LinkedHashMap<>();
|
Map<Component, Component> meta = new LinkedHashMap<>();
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
@ -155,11 +158,15 @@ public class MongoStorage implements StorageImplementation {
|
|||||||
long duration = System.currentTimeMillis() - start;
|
long duration = System.currentTimeMillis() - start;
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
meta.put("Ping", duration + "ms");
|
meta.put(
|
||||||
meta.put("Connected", "true");
|
Component.translatable("luckperms.command.info.storage.meta.ping-key"),
|
||||||
} else {
|
Component.text(duration + "ms", NamedTextColor.GREEN)
|
||||||
meta.put("Connected", "false");
|
);
|
||||||
}
|
}
|
||||||
|
meta.put(
|
||||||
|
Component.translatable("luckperms.command.info.storage.meta.connected-key"),
|
||||||
|
Message.formatBoolean(success)
|
||||||
|
);
|
||||||
|
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.actionlog.Log;
|
import me.lucko.luckperms.common.actionlog.Log;
|
||||||
import me.lucko.luckperms.common.bulkupdate.BulkUpdate;
|
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.Group;
|
||||||
import me.lucko.luckperms.common.model.Track;
|
import me.lucko.luckperms.common.model.Track;
|
||||||
import me.lucko.luckperms.common.model.User;
|
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.implementation.StorageImplementation;
|
||||||
import me.lucko.luckperms.common.storage.misc.NodeEntry;
|
import me.lucko.luckperms.common.storage.misc.NodeEntry;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.luckperms.api.actionlog.Action;
|
import net.luckperms.api.actionlog.Action;
|
||||||
import net.luckperms.api.model.PlayerSaveResult;
|
import net.luckperms.api.model.PlayerSaveResult;
|
||||||
import net.luckperms.api.node.Node;
|
import net.luckperms.api.node.Node;
|
||||||
@ -48,6 +50,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class SplitStorage implements StorageImplementation {
|
public class SplitStorage implements StorageImplementation {
|
||||||
private final LuckPermsPlugin plugin;
|
private final LuckPermsPlugin plugin;
|
||||||
@ -106,9 +109,14 @@ public class SplitStorage implements StorageImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getMeta() {
|
public Map<Component, Component> getMeta() {
|
||||||
Map<String, String> meta = new LinkedHashMap<>();
|
Map<Component, Component> meta = new LinkedHashMap<>();
|
||||||
meta.put("Types", this.types.toString());
|
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()) {
|
for (StorageImplementation backing : this.implementations.values()) {
|
||||||
meta.putAll(backing.getMeta());
|
meta.putAll(backing.getMeta());
|
||||||
}
|
}
|
||||||
|
@ -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.Uuids;
|
||||||
import me.lucko.luckperms.common.util.gson.GsonProvider;
|
import me.lucko.luckperms.common.util.gson.GsonProvider;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.luckperms.api.actionlog.Action;
|
import net.luckperms.api.actionlog.Action;
|
||||||
import net.luckperms.api.model.PlayerSaveResult;
|
import net.luckperms.api.model.PlayerSaveResult;
|
||||||
import net.luckperms.api.model.data.DataType;
|
import net.luckperms.api.model.data.DataType;
|
||||||
@ -219,7 +220,7 @@ public class SqlStorage implements StorageImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getMeta() {
|
public Map<Component, Component> getMeta() {
|
||||||
return this.connectionFactory.getMeta();
|
return this.connectionFactory.getMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ package me.lucko.luckperms.common.storage.implementation.sql.connection;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -41,7 +43,7 @@ public interface ConnectionFactory {
|
|||||||
|
|
||||||
void shutdown() throws Exception;
|
void shutdown() throws Exception;
|
||||||
|
|
||||||
default Map<String, String> getMeta() {
|
default Map<Component, Component> getMeta() {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.storage.implementation.sql.connection.ConnectionFactory;
|
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.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
abstract class FlatfileConnectionFactory implements ConnectionFactory {
|
abstract class FlatfileConnectionFactory implements ConnectionFactory {
|
||||||
@ -54,9 +57,8 @@ abstract class FlatfileConnectionFactory implements ConnectionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getMeta() {
|
public Map<Component, Component> getMeta() {
|
||||||
Map<String, String> meta = new LinkedHashMap<>();
|
String fileSize;
|
||||||
|
|
||||||
Path databaseFile = getWriteFile();
|
Path databaseFile = getWriteFile();
|
||||||
if (Files.exists(databaseFile)) {
|
if (Files.exists(databaseFile)) {
|
||||||
long length;
|
long length;
|
||||||
@ -67,11 +69,14 @@ abstract class FlatfileConnectionFactory implements ConnectionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double size = length / 1048576D;
|
double size = length / 1048576D;
|
||||||
meta.put("File Size", DF.format(size) + "MB");
|
fileSize = DF.format(size) + "MB";
|
||||||
} else {
|
} 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)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,15 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.zaxxer.hikari.HikariConfig;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
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.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
|
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
|
||||||
import me.lucko.luckperms.common.storage.implementation.sql.connection.ConnectionFactory;
|
import me.lucko.luckperms.common.storage.implementation.sql.connection.ConnectionFactory;
|
||||||
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
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.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
@ -119,8 +123,8 @@ public abstract class HikariConnectionFactory implements ConnectionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getMeta() {
|
public Map<Component, Component> getMeta() {
|
||||||
Map<String, String> meta = new LinkedHashMap<>();
|
Map<Component, Component> meta = new LinkedHashMap<>();
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
@ -134,11 +138,15 @@ public abstract class HikariConnectionFactory implements ConnectionFactory {
|
|||||||
long duration = System.currentTimeMillis() - start;
|
long duration = System.currentTimeMillis() - start;
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
meta.put("Ping", duration + "ms");
|
meta.put(
|
||||||
meta.put("Connected", "true");
|
Component.translatable("luckperms.command.info.storage.meta.ping-key"),
|
||||||
} else {
|
Component.text(duration + "ms", NamedTextColor.GREEN)
|
||||||
meta.put("Connected", "false");
|
);
|
||||||
}
|
}
|
||||||
|
meta.put(
|
||||||
|
Component.translatable("luckperms.command.info.storage.meta.connected-key"),
|
||||||
|
Message.formatBoolean(success)
|
||||||
|
);
|
||||||
|
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
@ -119,6 +119,10 @@ luckperms.command.info.server-brand-key=Server Brand
|
|||||||
luckperms.command.info.server-version-key=Server Version
|
luckperms.command.info.server-version-key=Server Version
|
||||||
luckperms.command.info.storage-key=Storage
|
luckperms.command.info.storage-key=Storage
|
||||||
luckperms.command.info.storage-type-key=Type
|
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.extensions-key=Extensions
|
||||||
luckperms.command.info.messaging-key=Messaging
|
luckperms.command.info.messaging-key=Messaging
|
||||||
luckperms.command.info.instance-key=Instance
|
luckperms.command.info.instance-key=Instance
|
||||||
|
Loading…
Reference in New Issue
Block a user