Improve /lp listgroups output - closes #368
This commit is contained in:
parent
1bb1f5ebb3
commit
7a6c0ab154
@ -57,6 +57,16 @@ search-showing-users: "&bShowing user entries:"
|
|||||||
search-showing-groups: "&bShowing group entries:"
|
search-showing-groups: "&bShowing group entries:"
|
||||||
search-showing-users-with-page: "&bShowing user entries: {0}"
|
search-showing-users-with-page: "&bShowing user entries: {0}"
|
||||||
search-showing-groups-with-page: "&bShowing group entries: {0}"
|
search-showing-groups-with-page: "&bShowing group entries: {0}"
|
||||||
|
apply-edits-invalid-code: "&aInvalid code. &7({0})"
|
||||||
|
apply-edits-unable-to-read: "&aUnable to read data using the given code. &7({0})"
|
||||||
|
apply-edits-no-target: "&aUnable to parse the target of the edit. Please supply it as an extra argument."
|
||||||
|
apply-edits-target-group-not-exists: "&aTarget group &b{0}&a does not exist."
|
||||||
|
apply-edits-target-user-not-uuid: "&aTarget user &b{0}&a is not a valid uuid."
|
||||||
|
apply-edits-target-user-unable-to-load: "&aUnable to load target user &b{0}&a."
|
||||||
|
apply-edits-target-unknown: "&aInvalid target. &7({0})"
|
||||||
|
apply-edits-success: "&aSuccessfully applied &b{0}&a nodes to &b{1}&a."
|
||||||
|
editor-upload-failure: "&cUnable to upload permission data to the editor."
|
||||||
|
editor-url: "&aEditor URL:"
|
||||||
check-result: "&aPermission check result on user &b{0}&a for permission &b{1}&a: &f{2}"
|
check-result: "&aPermission check result on user &b{0}&a for permission &b{1}&a: &f{2}"
|
||||||
create-success: "&b{0}&a was successfully created."
|
create-success: "&b{0}&a was successfully created."
|
||||||
delete-success: "&b{0}&a was successfully deleted."
|
delete-success: "&b{0}&a was successfully deleted."
|
||||||
@ -116,21 +126,18 @@ info: >
|
|||||||
create-group-error: "There was an error whilst creating the group."
|
create-group-error: "There was an error whilst creating the group."
|
||||||
delete-group-error: "There was an error whilst deleting the group."
|
delete-group-error: "There was an error whilst deleting the group."
|
||||||
delete-group-error-default: "You cannot delete the default group."
|
delete-group-error-default: "You cannot delete the default group."
|
||||||
groups-list: "&aGroups: {0}"
|
groups-list: "&aGroups: &7(name, weight, tracks)"
|
||||||
|
groups-list-entry: "&f- &3{0} &7- &b{1}"
|
||||||
|
groups-list-entry-with-tracks: "&f- &3{0} &7- &b{1} &7- [&3{2}&7]"
|
||||||
create-track-error: "There was an error whilst creating the track."
|
create-track-error: "There was an error whilst creating the track."
|
||||||
delete-track-error: "There was an error whilst deleting the track."
|
delete-track-error: "There was an error whilst deleting the track."
|
||||||
tracks-list: "&aTracks: {0}"
|
tracks-list: "&aTracks: {0}"
|
||||||
listnodes: "&b{0}'s Nodes:"
|
listnodes: "&b{0}'s Nodes:"
|
||||||
listnodes-with-page: "&b{0}'s Nodes: {1}"
|
listnodes-with-page: "&b{0}'s Nodes: {1}"
|
||||||
listnodes-temp: >
|
listnodes-temp: "&b{0}'s Temporary Nodes:"
|
||||||
&b{0}'s Temporary Nodes:\n
|
listnodes-temp-with-page: "&b{0}'s Temporary Nodes: {1}"
|
||||||
{1}
|
listparents: "&b{0}'s Parent Groups:"
|
||||||
listparents: >
|
listparents-temp: "&b{0}'s Temporary Parent Groups:"
|
||||||
&b{0}'s Parent Groups:\n
|
|
||||||
{1}
|
|
||||||
listparents-temp: >
|
|
||||||
&b{0}'s Temporary Parent Groups:\n
|
|
||||||
{1}
|
|
||||||
list-tracks: >
|
list-tracks: >
|
||||||
&b{0}'s Tracks:\n
|
&b{0}'s Tracks:\n
|
||||||
{1}
|
{1}
|
||||||
|
@ -29,14 +29,21 @@ import me.lucko.luckperms.common.commands.CommandResult;
|
|||||||
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
|
import me.lucko.luckperms.common.commands.abstraction.SingleCommand;
|
||||||
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.commands.utils.Util;
|
||||||
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
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.Track;
|
||||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.Message;
|
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.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
|
import net.kyori.text.Component;
|
||||||
|
import net.kyori.text.TextComponent;
|
||||||
|
import net.kyori.text.event.ClickEvent;
|
||||||
|
import net.kyori.text.event.HoverEvent;
|
||||||
|
import net.kyori.text.serializer.ComponentSerializer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -52,14 +59,37 @@ public class ListGroups extends SingleCommand {
|
|||||||
return CommandResult.LOADING_ERROR;
|
return CommandResult.LOADING_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message.GROUPS_LIST.send(
|
Message.GROUPS_LIST.send(sender);
|
||||||
sender,
|
plugin.getGroupManager().getAll().values().stream()
|
||||||
Util.toCommaSep(plugin.getGroupManager().getAll().values().stream()
|
.sorted((o1, o2) -> {
|
||||||
.map(Group::getDisplayName)
|
int i = Integer.compare(o2.getWeight().orElse(0), o1.getWeight().orElse(0));
|
||||||
.sorted()
|
return i != 0 ? i : o1.getName().compareToIgnoreCase(o2.getName());
|
||||||
.collect(Collectors.toList())
|
})
|
||||||
)
|
.forEach(group -> {
|
||||||
);
|
List<String> tracks = plugin.getTrackManager().getAll().values().stream().filter(t -> t.containsGroup(group)).map(Track::getName).collect(Collectors.toList());
|
||||||
|
Component component;
|
||||||
|
|
||||||
|
if (tracks.isEmpty()) {
|
||||||
|
component = ComponentSerializer.parseFromLegacy(Message.GROUPS_LIST_ENTRY.asString(plugin.getLocaleManager(),
|
||||||
|
group.getDisplayName(),
|
||||||
|
group.getWeight().orElse(0)
|
||||||
|
), Constants.COLOR_CHAR);
|
||||||
|
} else {
|
||||||
|
component = ComponentSerializer.parseFromLegacy(Message.GROUPS_LIST_ENTRY_WITH_TRACKS.asString(plugin.getLocaleManager(),
|
||||||
|
group.getDisplayName(),
|
||||||
|
group.getWeight().orElse(0),
|
||||||
|
Util.toCommaSep(tracks)
|
||||||
|
), Constants.COLOR_CHAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
component.applyRecursively(c -> {
|
||||||
|
c.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + label + " group " + group.getName() + " info"));
|
||||||
|
c.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("Click to view more info about " + group.getName() + ".").color('7')));
|
||||||
|
});
|
||||||
|
|
||||||
|
sender.sendMessage(component);
|
||||||
|
});
|
||||||
|
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,9 @@ public enum Message {
|
|||||||
CREATE_GROUP_ERROR("There was an error whilst creating the group.", true),
|
CREATE_GROUP_ERROR("There was an error whilst creating the group.", true),
|
||||||
DELETE_GROUP_ERROR("There was an error whilst deleting the group.", true),
|
DELETE_GROUP_ERROR("There was an error whilst deleting the group.", true),
|
||||||
DELETE_GROUP_ERROR_DEFAULT("You cannot delete the default group.", true),
|
DELETE_GROUP_ERROR_DEFAULT("You cannot delete the default group.", true),
|
||||||
GROUPS_LIST("&aGroups: {0}", true),
|
GROUPS_LIST("&aGroups: &7(name, weight, tracks)", true),
|
||||||
|
GROUPS_LIST_ENTRY("&f- &3{0} &7- &b{1}", true),
|
||||||
|
GROUPS_LIST_ENTRY_WITH_TRACKS("&f- &3{0} &7- &b{1} &7- [&3{2}&7]", true),
|
||||||
|
|
||||||
CREATE_TRACK_ERROR("There was an error whilst creating the track.", true),
|
CREATE_TRACK_ERROR("There was an error whilst creating the track.", true),
|
||||||
DELETE_TRACK_ERROR("There was an error whilst deleting the track.", true),
|
DELETE_TRACK_ERROR("There was an error whilst deleting the track.", true),
|
||||||
|
Loading…
Reference in New Issue
Block a user