From 21ec636a1ed4ae6a8564e55e8f5686c295d8ccd3 Mon Sep 17 00:00:00 2001 From: zzuf <11651753+zzufx@users.noreply.github.com> Date: Wed, 3 Jan 2024 04:05:21 -0300 Subject: [PATCH] Fix nicked player sorting in player list Signed-off-by: zzuf <11651753+zzufx@users.noreply.github.com> --- core/src/main/java/tc/oc/pgm/tablist/PlayerOrder.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/tc/oc/pgm/tablist/PlayerOrder.java b/core/src/main/java/tc/oc/pgm/tablist/PlayerOrder.java index ecbbee325e..d3478f9dc3 100644 --- a/core/src/main/java/tc/oc/pgm/tablist/PlayerOrder.java +++ b/core/src/main/java/tc/oc/pgm/tablist/PlayerOrder.java @@ -64,23 +64,26 @@ public int compare(MatchPlayer ma, MatchPlayer mb) { if (aStaff && !bStaff) return -1; else if (bStaff && !aStaff) return 1; - // Compare the nicknames of 'a' and 'b' if both are nicked, skip group permission check + // Compare the nicknames of 'a' and 'b'. If both are nicked, skip group permission check if (aNick != null && bNick != null) return aNick.compareToIgnoreCase(bNick); // If players have different permissions, the player with the highest ranked perm - // that the other one does't have is first. Disguised players effectively have no perms. + // that the other one doesn't have is first. Disguised players effectively have no perms. for (Config.Group group : PGM.get().getConfiguration().getGroups()) { Permission permission = group.getPermission(); boolean aPerm = a.hasPermission(permission); boolean bPerm = b.hasPermission(permission); - if (aPerm && !bPerm) { + if (aPerm && (!bPerm && aNick == null)) { return -1; - } else if (bPerm && !aPerm) { + } else if (bPerm && (!aPerm && bNick == null)) { return 1; } } + if (aNick != null && bNick == null) return aNick.compareToIgnoreCase(b.getName()); + else if (aNick == null && bNick != null) return a.getName().compareToIgnoreCase(bNick); + // All else equal, order the players alphabetically return a.getName().compareToIgnoreCase(b.getName()); }