Show sql table prefix if set in '/lp info' (#3360)

This commit is contained in:
Zeromaniac 2022-04-08 21:35:40 +02:00 committed by GitHub
parent 126631fce8
commit 34873914bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 3 deletions

View File

@ -173,6 +173,13 @@ public class MongoStorage implements StorageImplementation {
Message.formatBoolean(success)
);
if (!this.prefix.isEmpty()) {
meta.put(
Component.translatable("luckperms.command.info.storage.meta.collection-prefix-key"),
Component.text(this.prefix)
);
}
return meta;
}

View File

@ -34,6 +34,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.bulkupdate.PreparedStatementBuilder;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.context.serializer.ContextSetJsonSerializer;
import me.lucko.luckperms.common.model.Group;
import me.lucko.luckperms.common.model.Track;
@ -230,7 +231,17 @@ public class SqlStorage implements StorageImplementation {
@Override
public Map<Component, Component> getMeta() {
return this.connectionFactory.getMeta();
Map<Component, Component> meta = this.connectionFactory.getMeta();
String tablePrefix = this.plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX);
if (!tablePrefix.equals("luckperms_")) {
meta.put(
Component.translatable("luckperms.command.info.storage.meta.table-prefix-key"),
Component.text(tablePrefix)
);
}
return meta;
}
@Override

View File

@ -32,6 +32,7 @@ import net.kyori.adventure.text.Component;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
@ -44,7 +45,7 @@ public interface ConnectionFactory {
void shutdown() throws Exception;
default Map<Component, Component> getMeta() {
return Collections.emptyMap();
return new LinkedHashMap<>();
}
Function<String, String> getStatementProcessor();

View File

@ -37,6 +37,7 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
/**
@ -119,9 +120,11 @@ abstract class FlatfileConnectionFactory implements ConnectionFactory {
fileSize = "0MB";
}
return Collections.singletonMap(
Map<Component, Component> meta = new LinkedHashMap<>();
meta.put(
Component.translatable("luckperms.command.info.storage.meta.file-size-key"),
Component.text(fileSize, NamedTextColor.GREEN)
);
return meta;
}
}

View File

@ -151,6 +151,8 @@ 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.storage.meta.table-prefix-key=Table Prefix
luckperms.command.info.storage.meta.collection-prefix-key=Collection Prefix
luckperms.command.info.extensions-key=Extensions
luckperms.command.info.messaging-key=Messaging
luckperms.command.info.instance-key=Instance