Add more detail to the group info command

This commit is contained in:
Luck 2016-12-18 23:34:33 +00:00
parent b4b661a3ad
commit 17406b448d
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 102 additions and 62 deletions

View File

@ -22,17 +22,22 @@
package me.lucko.luckperms.common.commands.group;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.SubCommand;
import me.lucko.luckperms.common.commands.sender.Sender;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.constants.Permission;
import me.lucko.luckperms.common.core.model.Group;
import me.lucko.luckperms.common.utils.DateUtil;
import me.lucko.luckperms.common.utils.Predicates;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class GroupInfo extends SubCommand<Group> {
public GroupInfo() {
@ -41,13 +46,40 @@ public class GroupInfo extends SubCommand<Group> {
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) throws CommandException {
Message.GROUP_INFO.send(sender,
Message.GROUP_INFO_GENERAL.send(sender,
group.getId(),
group.getDisplayName(),
group.getPermanentNodes().size(),
group.getTemporaryNodes().size(),
label,
group.getName()
group.getPrefixNodes().size(),
group.getSuffixNodes().size(),
group.getMetaNodes().size()
);
Set<Node> parents = group.getPermissions(false).stream()
.filter(Node::isGroupNode)
.filter(Node::isPermanent)
.collect(Collectors.toSet());
Set<Node> tempParents = group.getPermissions(false).stream()
.filter(Node::isGroupNode)
.filter(Node::isTemporary)
.collect(Collectors.toSet());
if (!parents.isEmpty()) {
Message.INFO_PARENT_HEADER.send(sender);
for (Node node : parents) {
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + Util.getNodeContextDescription(node));
}
}
if (!tempParents.isEmpty()) {
Message.INFO_TEMP_PARENT_HEADER.send(sender);
for (Node node : tempParents) {
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + Util.getNodeContextDescription(node));
Message.EMPTY.send(sender, "&f- &2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()));
}
}
return CommandResult.SUCCESS;
}
}

View File

@ -73,14 +73,14 @@ public class UserInfo extends SubCommand<User> {
.collect(Collectors.toSet());
if (!parents.isEmpty()) {
Message.USER_INFO_PARENT_HEADER.send(sender);
Message.INFO_PARENT_HEADER.send(sender);
for (Node node : parents) {
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + Util.getNodeContextDescription(node));
}
}
if (!tempParents.isEmpty()) {
Message.USER_INFO_TEMP_PARENT_HEADER.send(sender);
Message.INFO_TEMP_PARENT_HEADER.send(sender);
for (Node node : tempParents) {
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + Util.getNodeContextDescription(node));
Message.EMPTY.send(sender, "&f- &2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()));

View File

@ -124,31 +124,31 @@ public enum Message {
UPDATE_TASK_PUSH_FAILURE("&cError whilst pushing changes to other servers. Is Redis enabled?", true),
INFO(
"{PREFIX}&2Running &bLuckPerms v{0}&2 by &bLuck&2." + "\n" +
"{PREFIX}&f- &3Platform: &f{1}" + "\n" +
"{PREFIX}&f- &3Storage Method: &f{2}" + "\n" +
"{PREFIX}&f- &3Server Name: &f{3}" + "\n" +
"{PREFIX}&f- &3Sync Interval: &a{4} &fminutes" + "\n" +
"{PREFIX}&f- &bCounts:" + "\n" +
"{PREFIX}&f- &3Online Players: &a{5}" + "\n" +
"{PREFIX}&f- &3Loaded Users: &a{6}" + "\n" +
"{PREFIX}&f- &3Loaded Groups: &a{7}" + "\n" +
"{PREFIX}&f- &3Loaded Tracks: &a{8}" + "\n" +
"{PREFIX}&f- &3Log size: &a{9}" + "\n" +
"{PREFIX}&f- &3UUID Cache size: &a{10}" + "\n" +
"{PREFIX}&f- &3Translations loaded: &a{11}" + "\n" +
"{PREFIX}&f- &3Pre-process contexts: &a{12}" + "\n" +
"{PREFIX}&f- &3Context Calculators: &a{13}" + "\n" +
"{PREFIX}&f- &bConfiguration:" + "\n" +
"{PREFIX}&f- &3Online Mode: {14}" + "\n" +
"{PREFIX}&f- &3Redis Enabled: {15}" + "\n" +
"{PREFIX}&f- &bPermission Calculation:" + "\n" +
"{PREFIX}&f- &3Including Global: {16}" + "\n" +
"{PREFIX}&f- &3Including Global World: {17}" + "\n" +
"{PREFIX}&f- &3Applying Global Groups: {18}" + "\n" +
"{PREFIX}&f- &3Applying Global World Groups: {19}" + "\n" +
"{PREFIX}&f- &3Applying Wildcards: {20}" + "\n" +
"{PREFIX}&f- &3Applying Regex: {21}" + "\n" +
"{PREFIX}&f- &3Applying Shorthand: {22}",
"{PREFIX}&f- &3Platform: &f{1}" + "\n" +
"{PREFIX}&f- &3Storage Method: &f{2}" + "\n" +
"{PREFIX}&f- &3Server Name: &f{3}" + "\n" +
"{PREFIX}&f- &3Sync Interval: &a{4} &fminutes" + "\n" +
"{PREFIX}&f- &bCounts:" + "\n" +
"{PREFIX}&f- &3Online Players: &a{5}" + "\n" +
"{PREFIX}&f- &3Loaded Users: &a{6}" + "\n" +
"{PREFIX}&f- &3Loaded Groups: &a{7}" + "\n" +
"{PREFIX}&f- &3Loaded Tracks: &a{8}" + "\n" +
"{PREFIX}&f- &3Log size: &a{9}" + "\n" +
"{PREFIX}&f- &3UUID Cache size: &a{10}" + "\n" +
"{PREFIX}&f- &3Translations loaded: &a{11}" + "\n" +
"{PREFIX}&f- &3Pre-process contexts: &a{12}" + "\n" +
"{PREFIX}&f- &3Context Calculators: &a{13}" + "\n" +
"{PREFIX}&f- &bConfiguration:" + "\n" +
"{PREFIX}&f- &3Online Mode: {14}" + "\n" +
"{PREFIX}&f- &3Redis Enabled: {15}" + "\n" +
"{PREFIX}&f- &bPermission Calculation:" + "\n" +
"{PREFIX}&f- &3Including Global: {16}" + "\n" +
"{PREFIX}&f- &3Including Global World: {17}" + "\n" +
"{PREFIX}&f- &3Applying Global Groups: {18}" + "\n" +
"{PREFIX}&f- &3Applying Global World Groups: {19}" + "\n" +
"{PREFIX}&f- &3Applying Wildcards: {20}" + "\n" +
"{PREFIX}&f- &3Applying Regex: {21}" + "\n" +
"{PREFIX}&f- &3Applying Shorthand: {22}",
false
),
CREATE_GROUP_ERROR("There was an error whilst creating the group.", true),
@ -273,29 +273,29 @@ public enum Message {
USER_INFO_GENERAL(
"{PREFIX}&b&l> &bUser Info: &f{0}" + "\n" +
"{PREFIX}&f- &3UUID: &f{1}" + "\n" +
"{PREFIX}&f- &3Status: {2}" + "\n" +
"{PREFIX}&f- &3Primary Group: &f{3}" + "\n" +
"{PREFIX}&f- &aCounts:" + "\n" +
"{PREFIX}&f- &3Permissions: &a{4}" + "\n" +
"{PREFIX}&f- &3Temporary Permissions: &a{5}" + "\n" +
"{PREFIX}&f- &3Prefixes: &a{6}" + "\n" +
"{PREFIX}&f- &3Suffixes: &a{7}" + "\n" +
"{PREFIX}&f- &3Meta: &a{8}",
"{PREFIX}&f- &3UUID: &f{1}" + "\n" +
"{PREFIX}&f- &3Status: {2}" + "\n" +
"{PREFIX}&f- &3Primary Group: &f{3}" + "\n" +
"{PREFIX}&f- &aCounts:" + "\n" +
"{PREFIX}&f- &3Permissions: &a{4}" + "\n" +
"{PREFIX}&f- &3Temporary Permissions: &a{5}" + "\n" +
"{PREFIX}&f- &3Prefixes: &a{6}" + "\n" +
"{PREFIX}&f- &3Suffixes: &a{7}" + "\n" +
"{PREFIX}&f- &3Meta: &a{8}",
false
),
USER_INFO_DATA(
"{PREFIX}&f- &aCached Data:" + "\n" +
"{PREFIX}&f- &3Is Loaded: {0}" + "\n" +
"{PREFIX}&f- &3Current Contexts: {1}" + "\n" +
"{PREFIX}&f- &3Current Prefix: {2}" + "\n" +
"{PREFIX}&f- &3Current Suffix: {3}",
"{PREFIX}&f- &3Is Loaded: {0}" + "\n" +
"{PREFIX}&f- &3Current Contexts: {1}" + "\n" +
"{PREFIX}&f- &3Current Prefix: {2}" + "\n" +
"{PREFIX}&f- &3Current Suffix: {3}",
false
),
USER_INFO_PARENT_HEADER("&f- &aParent Groups:", true),
USER_INFO_TEMP_PARENT_HEADER("&f- &aTemporary Parent Groups:", true),
INFO_PARENT_HEADER("&f- &aParent Groups:", true),
INFO_TEMP_PARENT_HEADER("&f- &aTemporary Parent Groups:", true),
USER_GETUUID("&bThe UUID of &b{0}&b is &b{1}&b.", true),
USER_REMOVEGROUP_ERROR_PRIMARY("You cannot remove a user from their primary group.", true),
USER_PRIMARYGROUP_SUCCESS("&b{0}&a's primary group was set to &b{1}&a.", true),
@ -308,7 +308,7 @@ public enum Message {
USER_PROMOTE_ERROR_ENDOFTRACK("The end of track &4{0}&c was reached. Unable to promote user.", true),
USER_PROMOTE_ERROR_MALFORMED(
"{PREFIX}The next group on the track, {0}, no longer exists. Unable to promote user." + "\n" +
"{PREFIX}Either create the group, or remove it from the track and try again.",
"{PREFIX}Either create the group, or remove it from the track and try again.",
false
),
USER_DEMOTE_SUCCESS("&aDemoting user along track &b{0}&a from &b{1}&a to &b{2}&a.", true),
@ -317,22 +317,26 @@ public enum Message {
USER_DEMOTE_ERROR_ENDOFTRACK("The end of track &4{0}&c was reached. Unable to demote user.", true),
USER_DEMOTE_ERROR_MALFORMED(
"{PREFIX}The previous group on the track, {0}, no longer exists. Unable to demote user." + "\n" +
"{PREFIX}Either create the group, or remove it from the track and try again.",
"{PREFIX}Either create the group, or remove it from the track and try again.",
false
),
USER_SHOWPOS("&aShowing &b{0}&a's position on track &b{1}&a.\n{2}", true),
GROUP_INFO(
GROUP_INFO_GENERAL(
"{PREFIX}&b&l> &bGroup Info: &f{0}" + "\n" +
"{PREFIX}&f- &3Permissions: &f{1}" + "\n" +
"{PREFIX}&f- &3Temporary Permissions: &f{2}" + "\n" +
"{PREFIX}&f- &3Use &b/{3} group {4} permission info &3to see all permissions.",
"{PREFIX}&f- &3Display Name: &f{1}" + "\n" +
"{PREFIX}&f- &aCounts:" + "\n" +
"{PREFIX}&f- &3Permissions: &a{2}" + "\n" +
"{PREFIX}&f- &3Temporary Permissions: &a{3}" + "\n" +
"{PREFIX}&f- &3Prefixes: &a{4}" + "\n" +
"{PREFIX}&f- &3Suffixes: &a{5}" + "\n" +
"{PREFIX}&f- &3Meta: &a{6}",
false
),
TRACK_INFO(
"{PREFIX}&b&l> &bShowing Track: &f{0}" + "\n" +
"{PREFIX}&f- &7Path: &f{1}",
"{PREFIX}&f- &7Path: &f{1}",
false
),
TRACK_CLEAR("&b{0}&a's groups track was cleared.", true),
@ -383,10 +387,10 @@ public enum Message {
IMPORT_END_COMPLETE_ERR_SIN("&b(Import) &a&lCOMPLETED &7- took &b{0} &7seconds - &c{1} error.", true),
IMPORT_END_ERROR_HEADER(
"{PREFIX}&b(Import) &7------------> &fShowing Error #&b{0} &7<------------" + "\n" +
"{PREFIX}&b(Import) &fWhilst executing: &3Command #{1}" + "\n" +
"{PREFIX}&b(Import) &fCommand: &7{2}" + "\n" +
"{PREFIX}&b(Import) &fType: &3{3}" + "\n" +
"{PREFIX}&b(Import) &fOutput:",
"{PREFIX}&b(Import) &fWhilst executing: &3Command #{1}" + "\n" +
"{PREFIX}&b(Import) &fCommand: &7{2}" + "\n" +
"{PREFIX}&b(Import) &fType: &3{3}" + "\n" +
"{PREFIX}&b(Import) &fOutput:",
false
),

View File

@ -245,8 +245,8 @@ user-info-data: >
{PREFIX}&f- &3Current Contexts: {1}\n
{PREFIX}&f- &3Current Prefix: {2}\n
{PREFIX}&f- &3Current Suffix: {3}
user-info-parent-header: "&f- &aParent Groups:"
user-info-temp-parent-header: "&f- &aTemporary Parent Groups:"
info-parent-header: "&f- &aParent Groups:"
info-temp-parent-header: "&f- &aTemporary Parent Groups:"
user-getuuid: "&bThe UUID of &b{0}&b is &b{1}&b."
user-removegroup-error-primary: "You cannot remove a user from their primary group."
user-primarygroup-success: "&b{0}&a's primary group was set to &b{1}&a."
@ -270,11 +270,15 @@ user-demote-error-malformed: >
user-demote-error-not-contain-group: "Demotions are done based on primary groups. The users primary group is not on the track specified."
user-showpos: "&aShowing &b{0}&a's position on track &b{1}&a.{2}"
group-info: >
user-info-general: >
{PREFIX}&b&l> &bGroup Info: &f{0}\n
{PREFIX}&f- &3Permissions: &6{1}\n
{PREFIX}&f- &3Temporary Permissions: &6{2}\n
{PREFIX}&f- &3Use &b/{3} group {4} permission info &3to see all permissions.
{PREFIX}&f- &3Diaplay Name: &f{1}\n
{PREFIX}&f- &aCounts:\n
{PREFIX}&f- &3Permissions: &a{2}\n
{PREFIX}&f- &3Temporary Permissions: &a{3}\n
{PREFIX}&f- &3Prefixes: &a{4}\n
{PREFIX}&f- &3Suffixes: &a{5}\n
{PREFIX}&f- &3Meta: &a{6}
track-info: >
{PREFIX}&b&l> &bShowing Track: &f{0}\n