|
6 | 6 | import tc.oc.pgm.api.Config;
|
7 | 7 | import tc.oc.pgm.api.PGM;
|
8 | 8 | import tc.oc.pgm.api.Permissions;
|
| 9 | +import tc.oc.pgm.api.integration.Integration; |
9 | 10 | import tc.oc.pgm.api.player.MatchPlayer;
|
10 | 11 |
|
11 | 12 | /**
|
@@ -36,15 +37,28 @@ public int compare(MatchPlayer ma, MatchPlayer mb) {
|
36 | 37 | Player b = mb.getBukkit();
|
37 | 38 | Player viewer = this.viewer.getBukkit();
|
38 | 39 |
|
39 |
| - boolean aStaff = a.hasPermission(Permissions.STAFF); |
40 |
| - boolean bStaff = b.hasPermission(Permissions.STAFF); |
| 40 | + // Check if the viewer has staff permissions |
| 41 | + boolean isStaff = viewer.hasPermission(Permissions.STAFF); |
41 | 42 |
|
42 |
| - // Staff take priority |
43 |
| - if (aStaff && !bStaff) { |
44 |
| - return -1; |
45 |
| - } else if (bStaff && !aStaff) { |
46 |
| - return 1; |
47 |
| - } |
| 43 | + // Check if viewer is friends with the player |
| 44 | + boolean aFriend = Integration.isFriend(viewer, a); |
| 45 | + boolean bFriend = Integration.isFriend(viewer, b); |
| 46 | + |
| 47 | + if (aFriend && !bFriend) return -1; |
| 48 | + else if (bFriend && !aFriend) return 1; |
| 49 | + |
| 50 | + String aNick = aFriend || isStaff ? null : Integration.getNick(a); |
| 51 | + String bNick = bFriend || isStaff ? null : Integration.getNick(b); |
| 52 | + |
| 53 | + // Check if 'a' and 'b' are staff members (only counts if they're not nicked) |
| 54 | + boolean aStaff = aNick == null && a.hasPermission(Permissions.STAFF); |
| 55 | + boolean bStaff = bNick == null && b.hasPermission(Permissions.STAFF); |
| 56 | + |
| 57 | + if (aStaff && !bStaff) return -1; |
| 58 | + else if (bStaff && !aStaff) return 1; |
| 59 | + |
| 60 | + // Compare the nicknames of 'a' and 'b' if both are nicked, skip group permission check |
| 61 | + if (aNick != null && bNick != null) return aNick.compareToIgnoreCase(bNick); |
48 | 62 |
|
49 | 63 | // If players have different permissions, the player with the highest ranked perm
|
50 | 64 | // that the other one does't have is first. Disguised players effectively have no perms.
|
|
0 commit comments