diff --git a/common/src/main/java/me/lucko/luckperms/commands/Util.java b/common/src/main/java/me/lucko/luckperms/commands/Util.java index 4a69a0712..ee2355243 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/Util.java +++ b/common/src/main/java/me/lucko/luckperms/commands/Util.java @@ -23,14 +23,12 @@ package me.lucko.luckperms.commands; import lombok.experimental.UtilityClass; +import me.lucko.luckperms.api.Node; import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Patterns; import me.lucko.luckperms.utils.DateUtil; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; @UtilityClass public class Util { @@ -115,35 +113,53 @@ public class Util { return sb.delete(sb.length() - 6, sb.length()).toString(); } - public static String permNodesToString(Map nodes) { - if (nodes.isEmpty()) return "&6None"; - + public static String permNodesToString(SortedSet nodes) { StringBuilder sb = new StringBuilder(); - - for (Map.Entry e : nodes.entrySet()) { - if (e.getValue()) { - sb.append("&a").append(e.getKey()).append("&7, "); - } else { - sb.append("&c").append(e.getKey()).append("&7, "); + for (Node node : nodes) { + if (node.isTemporary()) { + continue; } + + sb.append("&6-> ").append(node.getValue() ? "&a" : "&c"); + sb.append(node.getPermission()); + if (node.isServerSpecific()) { + sb.append(" &7(&f").append(node.getServer().get()).append("&7)"); + } + if (node.isWorldSpecific()) { + sb.append(" &7(&f").append(node.getWorld().get()).append("&7)"); + } + sb.append("\n"); } - return sb.delete(sb.length() - 2, sb.length()).toString(); + if (sb.length() == 0) { + return "&6None"; + } + + return sb.toString(); } - public static String tempNodesToString(Map, Long> nodes) { - if (nodes.isEmpty()) return "&6None"; - + public static String tempNodesToString(SortedSet nodes) { StringBuilder sb = new StringBuilder(); - for (Map.Entry, Long> e : nodes.entrySet()) { - if (e.getKey().getValue()) { - sb.append("&a").append(e.getKey().getKey()).append("&6 - expires in ") - .append(DateUtil.formatDateDiff(e.getValue())).append("\n"); - } else { - sb.append("&c").append(e.getKey().getKey()).append("&6 - expires in ") - .append(DateUtil.formatDateDiff(e.getValue())).append("\n"); + for (Node node : nodes) { + if (!node.isTemporary()) { + continue; } + + sb.append("&6-> ").append(node.getValue() ? "&a" : "&c"); + sb.append(node.getPermission()); + if (node.isServerSpecific()) { + sb.append(" &7(&f").append(node.getServer().get()).append("&7)"); + } + if (node.isWorldSpecific()) { + sb.append(" &7(&f").append(node.getWorld().get()).append("&7)"); + } + + sb.append("&6 - expires in ").append(DateUtil.formatDateDiff(node.getExpiryUnixTime())).append("\n"); + } + + if (sb.length() == 0) { + return "&6None"; } return sb.toString(); diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupListNodes.java b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupListNodes.java index 5efcffbf3..98a4da5af 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupListNodes.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupListNodes.java @@ -30,8 +30,6 @@ import me.lucko.luckperms.groups.Group; import java.util.List; -import static me.lucko.luckperms.core.PermissionHolder.exportToLegacy; - public class GroupListNodes extends SubCommand { public GroupListNodes() { super("listnodes", "Lists the permission nodes the group has", "/%s group listnodes", @@ -40,8 +38,8 @@ public class GroupListNodes extends SubCommand { @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List args, String label) { - Message.LISTNODES.send(sender, group.getName(), Util.permNodesToString(exportToLegacy(group.getPermanentNodes()))); - Message.LISTNODES_TEMP.send(sender, group.getName(), Util.tempNodesToString(group.getTemporaryNodesLegacy())); + Message.LISTNODES.send(sender, group.getName(), Util.permNodesToString(group.getPermissions())); + Message.LISTNODES_TEMP.send(sender, group.getName(), Util.tempNodesToString(group.getPermissions())); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserListNodes.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserListNodes.java index d17b90274..854c26371 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserListNodes.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserListNodes.java @@ -30,8 +30,6 @@ import me.lucko.luckperms.users.User; import java.util.List; -import static me.lucko.luckperms.core.PermissionHolder.exportToLegacy; - public class UserListNodes extends SubCommand { public UserListNodes() { super("listnodes", "Lists the permission nodes the user has", "/%s user listnodes", @@ -40,8 +38,8 @@ public class UserListNodes extends SubCommand { @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List args, String label) { - Message.LISTNODES.send(sender, user.getName(), Util.permNodesToString(exportToLegacy(user.getPermanentNodes()))); - Message.LISTNODES_TEMP.send(sender, user.getName(), Util.tempNodesToString(user.getTemporaryNodesLegacy())); + Message.LISTNODES.send(sender, user.getName(), Util.permNodesToString(user.getPermissions())); + Message.LISTNODES_TEMP.send(sender, user.getName(), Util.tempNodesToString(user.getPermissions())); return CommandResult.SUCCESS; } }