mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 13:45:20 +01:00
Add more detail to the group info command
This commit is contained in:
parent
b4b661a3ad
commit
17406b448d
@ -22,17 +22,22 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.commands.group;
|
package me.lucko.luckperms.common.commands.group;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandException;
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
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.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.model.Group;
|
import me.lucko.luckperms.common.core.model.Group;
|
||||||
|
import me.lucko.luckperms.common.utils.DateUtil;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class GroupInfo extends SubCommand<Group> {
|
public class GroupInfo extends SubCommand<Group> {
|
||||||
public GroupInfo() {
|
public GroupInfo() {
|
||||||
@ -41,13 +46,40 @@ public class GroupInfo extends SubCommand<Group> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) throws CommandException {
|
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.getDisplayName(),
|
||||||
group.getPermanentNodes().size(),
|
group.getPermanentNodes().size(),
|
||||||
group.getTemporaryNodes().size(),
|
group.getTemporaryNodes().size(),
|
||||||
label,
|
group.getPrefixNodes().size(),
|
||||||
group.getName()
|
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;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,14 +73,14 @@ public class UserInfo extends SubCommand<User> {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
if (!parents.isEmpty()) {
|
if (!parents.isEmpty()) {
|
||||||
Message.USER_INFO_PARENT_HEADER.send(sender);
|
Message.INFO_PARENT_HEADER.send(sender);
|
||||||
for (Node node : parents) {
|
for (Node node : parents) {
|
||||||
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + Util.getNodeContextDescription(node));
|
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + Util.getNodeContextDescription(node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tempParents.isEmpty()) {
|
if (!tempParents.isEmpty()) {
|
||||||
Message.USER_INFO_TEMP_PARENT_HEADER.send(sender);
|
Message.INFO_TEMP_PARENT_HEADER.send(sender);
|
||||||
for (Node node : tempParents) {
|
for (Node node : tempParents) {
|
||||||
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + Util.getNodeContextDescription(node));
|
Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + Util.getNodeContextDescription(node));
|
||||||
Message.EMPTY.send(sender, "&f- &2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()));
|
Message.EMPTY.send(sender, "&f- &2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()));
|
||||||
|
@ -294,8 +294,8 @@ public enum Message {
|
|||||||
false
|
false
|
||||||
),
|
),
|
||||||
|
|
||||||
USER_INFO_PARENT_HEADER("&f- &aParent Groups:", true),
|
INFO_PARENT_HEADER("&f- &aParent Groups:", true),
|
||||||
USER_INFO_TEMP_PARENT_HEADER("&f- &aTemporary Parent 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_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_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),
|
USER_PRIMARYGROUP_SUCCESS("&b{0}&a's primary group was set to &b{1}&a.", true),
|
||||||
@ -322,11 +322,15 @@ public enum Message {
|
|||||||
),
|
),
|
||||||
USER_SHOWPOS("&aShowing &b{0}&a's position on track &b{1}&a.\n{2}", true),
|
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}&b&l> &bGroup Info: &f{0}" + "\n" +
|
||||||
"{PREFIX}&f- &3Permissions: &f{1}" + "\n" +
|
"{PREFIX}&f- &3Display Name: &f{1}" + "\n" +
|
||||||
"{PREFIX}&f- &3Temporary Permissions: &f{2}" + "\n" +
|
"{PREFIX}&f- &aCounts:" + "\n" +
|
||||||
"{PREFIX}&f- &3Use &b/{3} group {4} permission info &3to see all permissions.",
|
"{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
|
false
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -245,8 +245,8 @@ user-info-data: >
|
|||||||
{PREFIX}&f- &3Current Contexts: {1}\n
|
{PREFIX}&f- &3Current Contexts: {1}\n
|
||||||
{PREFIX}&f- &3Current Prefix: {2}\n
|
{PREFIX}&f- &3Current Prefix: {2}\n
|
||||||
{PREFIX}&f- &3Current Suffix: {3}
|
{PREFIX}&f- &3Current Suffix: {3}
|
||||||
user-info-parent-header: "&f- &aParent Groups:"
|
info-parent-header: "&f- &aParent Groups:"
|
||||||
user-info-temp-parent-header: "&f- &aTemporary Parent Groups:"
|
info-temp-parent-header: "&f- &aTemporary Parent Groups:"
|
||||||
user-getuuid: "&bThe UUID of &b{0}&b is &b{1}&b."
|
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-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."
|
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-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}"
|
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}&b&l> &bGroup Info: &f{0}\n
|
||||||
{PREFIX}&f- &3Permissions: &6{1}\n
|
{PREFIX}&f- &3Diaplay Name: &f{1}\n
|
||||||
{PREFIX}&f- &3Temporary Permissions: &6{2}\n
|
{PREFIX}&f- &aCounts:\n
|
||||||
{PREFIX}&f- &3Use &b/{3} group {4} permission info &3to see all permissions.
|
{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: >
|
track-info: >
|
||||||
{PREFIX}&b&l> &bShowing Track: &f{0}\n
|
{PREFIX}&b&l> &bShowing Track: &f{0}\n
|
||||||
|
Loading…
Reference in New Issue
Block a user