8000 Fix tablist order for friends and nicked players by applenick · Pull Request #1124 · PGMDev/PGM · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix tablist order for friends and nicked players #1124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account relate 8000 d emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions core/src/main/java/tc/oc/pgm/tablist/PlayerOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import tc.oc.pgm.api.Config;
import tc.oc.pgm.api.PGM;
import tc.oc.pgm.api.Permissions;
import tc.oc.pgm.api.integration.Integration;
import tc.oc.pgm.api.player.MatchPlayer;

/**
Expand Down Expand Up @@ -36,15 +37,28 @@ public int compare(MatchPlayer ma, MatchPlayer mb) {
Player b = mb.getBukkit();
Player viewer = this.viewer.getBukkit();

boolean aStaff = a.hasPermission(Permissions.STAFF);
boolean bStaff = b.hasPermission(Permissions.STAFF);
// Check if the viewer has staff permissions
boolean isStaff = viewer.hasPermission(Permissions.STAFF);

// Staff take priority
if (aStaff && !bStaff) {
return -1;
} else if (bStaff && !aStaff) {
return 1;
}
// Check if viewer is friends with the player
boolean aFriend = Integration.isFriend(viewer, a);
boolean bFriend = Integration.isFriend(viewer, b);

if (aFriend && !bFriend) return -1;
else if (bFriend && !aFriend) return 1;

String aNick = aFriend || isStaff ? null : Integration.getNick(a);
String bNick = bFriend || isStaff ? null : Integration.getNick(b);

// Check if 'a' and 'b' are staff members (only counts if they're not nicked)
boolean aStaff = aNick == null && a.hasPermission(Permissions.STAFF);
boolean bStaff = bNick == null && b.hasPermission(Permissions.STAFF);

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
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.
Expand Down
0