Reduce the amount of unnecessary data in info command outputs a bit

This commit is contained in:
Luck 2018-01-23 19:55:21 +00:00
parent e1c60fa70f
commit 982254ff5e
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
7 changed files with 41 additions and 105 deletions

View File

@ -94,7 +94,6 @@ import java.io.File;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@ -549,15 +548,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
return getSenderFactory().wrap(getServer().getConsoleSender());
}
@Override
public Map<String, Object> getExtraInfo() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("Vault Enabled", this.vaultHookManager != null);
map.put("Bukkit Defaults count", this.defaultsProvider.size());
map.put("Bukkit Child Permissions count", this.childPermissionProvider.getPermissions().size());
return map;
}
private static boolean checkInvalidVersion() {
try {
Class.forName("com.google.gson.JsonElement");

View File

@ -59,12 +59,7 @@ public class GroupInfo extends SubCommand<Group> {
Message.GROUP_INFO_GENERAL.send(sender,
group.getName(),
group.getDisplayName().orElse(group.getName()),
group.getWeight().isPresent() ? group.getWeight().getAsInt() : "None",
group.getEnduringData().asList().size(),
group.getEnduringData().asList().stream().filter(n -> !(n.isGroupNode() || n.isPrefix() || n.isSuffix() || n.isMeta())).mapToInt(n -> 1).sum(),
group.getEnduringData().asList().stream().filter(Node::isPrefix).mapToInt(n -> 1).sum(),
group.getEnduringData().asList().stream().filter(Node::isSuffix).mapToInt(n -> 1).sum(),
group.getEnduringData().asList().stream().filter(Node::isMeta).mapToInt(n -> 1).sum()
group.getWeight().isPresent() ? group.getWeight().getAsInt() : "None"
);
Set<Node> parents = group.getEnduringData().asSet().stream()

View File

@ -30,7 +30,6 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.CommandUtils;
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
import me.lucko.luckperms.common.locale.CommandSpec;
import me.lucko.luckperms.common.locale.LocaleManager;
import me.lucko.luckperms.common.locale.Message;
@ -41,7 +40,6 @@ import me.lucko.luckperms.common.utils.Predicates;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class InfoCommand extends SingleCommand {
public InfoCommand(LocaleManager locale) {
@ -50,8 +48,6 @@ public class InfoCommand extends SingleCommand {
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
final LuckPermsConfiguration c = plugin.getConfiguration();
Message.INFO_TOP.send(sender,
plugin.getVersion(),
plugin.getServerType().getFriendlyName(),
@ -59,11 +55,9 @@ public class InfoCommand extends SingleCommand {
plugin.getServerVersion()
);
Map<String, String> storageInfo = plugin.getStorage().getMeta();
Message.EMPTY.send(sender, "&f- &bStorage:");
Message.EMPTY.send(sender, "&f- &3Type: &f" + plugin.getStorage().getName());
for (Map.Entry<String, String> e : storageInfo.entrySet()) {
for (Map.Entry<String, String> e : plugin.getStorage().getMeta().entrySet()) {
Message.EMPTY.send(sender, "&f- &3" + e.getKey() + ": " + formatValue(e.getValue()));
}
@ -75,20 +69,9 @@ public class InfoCommand extends SingleCommand {
DateUtil.formatTimeBrief((System.currentTimeMillis() - plugin.getStartTime()) / 1000L),
plugin.getUserManager().getAll().size(),
plugin.getGroupManager().getAll().size(),
plugin.getTrackManager().getAll().size(),
plugin.getContextManager().getCalculatorsSize(),
plugin.getPermissionVault().getSize(),
plugin.getCalculatorFactory().getActiveProcessors().stream().collect(Collectors.joining(", "))
plugin.getTrackManager().getAll().size()
);
Map<String, Object> platformInfo = plugin.getExtraInfo();
if (!platformInfo.isEmpty()) {
Message.EMPTY.send(sender, "&f- &bPlatform Info:");
for (Map.Entry<String, Object> e : platformInfo.entrySet()) {
Message.EMPTY.send(sender, "&f- &3" + e.getKey() + ": " + formatValue(e.getValue().toString()));
}
}
return CommandResult.SUCCESS;
}

View File

@ -25,9 +25,12 @@
package me.lucko.luckperms.common.commands.impl.user;
import com.google.common.collect.ListMultimap;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.caching.MetaData;
import me.lucko.luckperms.api.context.ContextSet;
import me.lucko.luckperms.common.commands.ArgumentPermissions;
import me.lucko.luckperms.common.commands.CommandPermission;
import me.lucko.luckperms.common.commands.CommandResult;
@ -65,12 +68,7 @@ public class UserInfo extends SubCommand<User> {
user.getName().orElse("Unknown"),
user.getUuid(),
status.asString(plugin.getLocaleManager()),
user.getPrimaryGroup().getValue(),
user.getEnduringData().asList().size(),
user.getEnduringData().asList().stream().filter(n -> !(n.isGroupNode() || n.isPrefix() || n.isSuffix() || n.isMeta())).mapToInt(n -> 1).sum(),
user.getEnduringData().asList().stream().filter(Node::isPrefix).mapToInt(n -> 1).sum(),
user.getEnduringData().asList().stream().filter(Node::isSuffix).mapToInt(n -> 1).sum(),
user.getEnduringData().asList().stream().filter(Node::isMeta).mapToInt(n -> 1).sum()
user.getPrimaryGroup().getValue()
);
Set<Node> parents = user.getEnduringData().asSet().stream()
@ -101,22 +99,33 @@ public class UserInfo extends SubCommand<User> {
String context = "&bNone";
String prefix = "&bNone";
String suffix = "&bNone";
String meta = "&bNone";
Contexts contexts = plugin.getContextForUser(user);
if (contexts != null) {
context = contexts.getContexts().toSet().stream()
.map(e -> CommandUtils.contextToString(e.getKey(), e.getValue()))
.collect(Collectors.joining(" "));
MetaData meta = user.getCachedData().getMetaData(contexts);
if (meta.getPrefix() != null) {
prefix = "&f\"" + meta.getPrefix() + "&f\"";
ContextSet contextSet = contexts.getContexts();
if (!contextSet.isEmpty()) {
context = contextSet.toSet().stream()
.map(e -> CommandUtils.contextToString(e.getKey(), e.getValue()))
.collect(Collectors.joining(" "));
}
if (meta.getSuffix() != null) {
suffix = "&f\"" + meta.getSuffix() + "&f\"";
MetaData data = user.getCachedData().getMetaData(contexts);
if (data.getPrefix() != null) {
prefix = "&f\"" + data.getPrefix() + "&f\"";
}
if (data.getSuffix() != null) {
suffix = "&f\"" + data.getSuffix() + "&f\"";
}
ListMultimap<String, String> metaMap = data.getMetaMultimap();
if (!metaMap.isEmpty()) {
meta = metaMap.entries().stream()
.map(e -> CommandUtils.contextToString(e.getKey(), e.getValue()))
.collect(Collectors.joining(" "));
}
}
Message.USER_INFO_DATA.send(sender, CommandUtils.formatBoolean(contexts != null), context, prefix, suffix);
Message.USER_INFO_DATA.send(sender, CommandUtils.formatBoolean(contexts != null), context, prefix, suffix, meta);
return CommandResult.SUCCESS;
}
}

View File

@ -176,20 +176,17 @@ public enum Message {
"{PREFIX}&2Running &bLuckPerms v{}&2 by &bLuck&2." + "\n" +
"{PREFIX}&f- &3Platform: &f{}" + "\n" +
"{PREFIX}&f- &3Server Brand: &f{}" + "\n" +
"{PREFIX}&f- &3Server Version: &f{}",
"{PREFIX}&f- &3Server Version:" + "\n" +
"{PREFIX}&f- {}",
false
),
INFO_MIDDLE(
"{PREFIX}&f- &bMessaging Type: &f{}" + "\n" +
"{PREFIX}&f- &bMessaging: &f{}" + "\n" +
"{PREFIX}&f- &bInstance:" + "\n" +
"{PREFIX}&f- &3Server Name: &f{}" + "\n" +
"{PREFIX}&f- &3Online Players: &a{}" + "\n" +
"{PREFIX}&f- &3Unique Connections: &a{}" + "\n" +
"{PREFIX}&f- &3Static contexts: &f{}" + "\n" +
"{PREFIX}&f- &3Online Players: &a{} &7(&a{}&7 unique)" + "\n" +
"{PREFIX}&f- &3Uptime: &7{}" + "\n" +
"{PREFIX}&f- &3Local Data: &a{} &7users, &a{} &7groups, &a{} &7tracks" + "\n" +
"{PREFIX}&f- &3Context Calculators: &a{}" + "\n" +
"{PREFIX}&f- &3Known permissions: &a{}" + "\n" +
"{PREFIX}&f- &3Active processors: &7{10}",
"{PREFIX}&f- &3Local Data: &a{} &7users, &a{} &7groups, &a{} &7tracks",
false
),
@ -308,22 +305,17 @@ public enum Message {
"{PREFIX}&b&l> &bUser Info: &f{}" + "\n" +
"{PREFIX}&f- &3UUID: &f{}" + "\n" +
"{PREFIX}&f- &3Status: {}" + "\n" +
"{PREFIX}&f- &3Primary Group: &f{}" + "\n" +
"{PREFIX}&f- &aCounts:" + "\n" +
"{PREFIX}&f- &3Nodes: &a{}" + "\n" +
"{PREFIX}&f- &3Permissions: &a{}" + "\n" +
"{PREFIX}&f- &3Prefixes: &a{}" + "\n" +
"{PREFIX}&f- &3Suffixes: &a{}" + "\n" +
"{PREFIX}&f- &3Meta: &a{}",
"{PREFIX}&f- &3Primary Group: &f{}",
false
),
USER_INFO_DATA(
"{PREFIX}&f- &aCached Data:" + "\n" +
"{PREFIX}&f- &aContextual Data:" + "\n" +
"{PREFIX}&f- &3Has contextual data: {}" + "\n" +
"{PREFIX}&f- &3Current Contexts: {}" + "\n" +
"{PREFIX}&f- &3Current Prefix: {}" + "\n" +
"{PREFIX}&f- &3Current Suffix: {}",
"{PREFIX}&f- &3Applicable contexts: {}" + "\n" +
"{PREFIX}&f- &3Prefix: {}" + "\n" +
"{PREFIX}&f- &3Suffix: {}" + "\n" +
"{PREFIX}&f- &3Meta: {}",
false
),
@ -356,13 +348,7 @@ public enum Message {
GROUP_INFO_GENERAL(
"{PREFIX}&b&l> &bGroup Info: &f{}" + "\n" +
"{PREFIX}&f- &3Display Name: &f{}" + "\n" +
"{PREFIX}&f- &3Weight: &f{}" + "\n" +
"{PREFIX}&f- &aCounts:" + "\n" +
"{PREFIX}&f- &3Nodes: &a{}" + "\n" +
"{PREFIX}&f- &3Permissions: &a{}" + "\n" +
"{PREFIX}&f- &3Prefixes: &a{}" + "\n" +
"{PREFIX}&f- &3Suffixes: &a{}" + "\n" +
"{PREFIX}&f- &3Meta: &a{}",
"{PREFIX}&f- &3Weight: &f{}",
false
),
GROUP_SET_WEIGHT("&aSet weight to &b{}&a for group &b{}&a.", true),

View File

@ -57,7 +57,6 @@ import java.io.File;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
@ -379,15 +378,6 @@ public interface LuckPermsPlugin {
return Collections.emptyList();
}
/**
* Gets a map of extra information to be shown in the info command
*
* @return a map of options
*/
default Map<String, Object> getExtraInfo() {
return Collections.emptyMap();
}
/**
* Gets the update task buffer of the platform, used for scheduling and running update tasks.
*

View File

@ -111,11 +111,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.AbstractCollection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
@ -507,20 +504,6 @@ public class LPSpongePlugin implements LuckPermsSpongePlugin {
return Collections.singletonList(new SpongeMainCommand(this));
}
@Override
public Map<String, Object> getExtraInfo() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("SubjectCollection count", this.service.getLoadedCollections().size());
map.put("Subject count",
this.service.getLoadedCollections().values().stream()
.map(LPSubjectCollection::getLoadedSubjects)
.mapToInt(AbstractCollection::size)
.sum()
);
map.put("PermissionDescription count", this.service.getDescriptions().size());
return map;
}
public Game getGame() {
return this.game;
}