Skip to content

Commit

Permalink
Add whitelist indicator for /seen and /whois (EssentialsX#5486)
Browse files Browse the repository at this point in the history
Co-authored-by: Josh Roy <[email protected]>
  • Loading branch information
2 people authored and HarvelsX committed Jun 2, 2024
1 parent d73ed13 commit 3c0cfbf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected void run(final Server server, final CommandSource sender, final String
final boolean showBan = sender.isAuthorized("essentials.seen.banreason", ess);
final boolean showIp = sender.isAuthorized("essentials.seen.ip", ess);
final boolean showLocation = sender.isAuthorized("essentials.seen.location", ess);
final boolean showWhitelist = sender.isAuthorized("essentials.seen.whitelist", ess);
final boolean searchAccounts = commandLabel.contains("alts") && sender.isAuthorized("essentials.seen.alts", ess);

User player;
Expand Down Expand Up @@ -79,21 +80,21 @@ public void run() {
}

private void showUserSeen(final User user) throws Exception {
showSeenMessage(sender, user, searchAccounts, showBan, showIp, showLocation);
showSeenMessage(sender, user, searchAccounts, showBan, showIp, showLocation, showWhitelist);
}
});
} else {
showSeenMessage(sender, player, searchAccounts, showBan, showIp, showLocation);
showSeenMessage(sender, player, searchAccounts, showBan, showIp, showLocation, showWhitelist);
}
}

private void showSeenMessage(final CommandSource sender, final User player, final boolean searchAccounts, final boolean showBan, final boolean showIp, final boolean showLocation) {
private void showSeenMessage(final CommandSource sender, final User player, final boolean searchAccounts, final boolean showBan, final boolean showIp, final boolean showLocation, final boolean showWhitelist) {
if (searchAccounts) {
seenIP(sender, player.getLastLoginAddress(), player.getDisplayName());
} else if (player.getBase().isOnline() && canInteractWith(sender, player)) {
seenOnline(sender, player, showIp);
} else {
seenOffline(sender, player, showBan, showIp, showLocation);
seenOffline(sender, player, showBan, showIp, showLocation, showWhitelist);
}
}

Expand Down Expand Up @@ -134,7 +135,7 @@ private void seenOnline(final CommandSource sender, final User user, final boole
}
}

private void seenOffline(final CommandSource sender, final User user, final boolean showBan, final boolean showIp, final boolean showLocation) {
private void seenOffline(final CommandSource sender, final User user, final boolean showBan, final boolean showIp, final boolean showLocation, final boolean showWhitelist) {
user.setDisplayNick();
if (user.getLastLogout() > 0) {
sender.sendMessage(tl("seenOffline", user.getName(), DateUtil.formatDateDiff(user.getLastLogout())));
Expand All @@ -150,6 +151,10 @@ private void seenOffline(final CommandSource sender, final User user, final bool
sender.sendMessage(tl("userUnknown", user.getName()));
}

if (showWhitelist) {
sender.sendMessage(tl("whoisWhitelist", user.getBase().isWhitelisted() ? tl("true") : tl("false")));
}

if (BanLookup.isBanned(ess, user)) {
final BanEntry banEntry = BanLookup.getBanEntry(ess, user.getName());
final String reason = showBan ? banEntry.getReason() : tl("true");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void run(final Server server, final CommandSource sender, final String co
sender.sendMessage(tl("whoisOp", user.getBase().isOp() ? tl("true") : tl("false")));
sender.sendMessage(tl("whoisFly", user.getBase().getAllowFlight() ? tl("true") : tl("false"), user.getBase().isFlying() ? tl("flying") : tl("notFlying")));
sender.sendMessage(tl("whoisSpeed", user.getBase().isFlying() ? user.getBase().getFlySpeed() : user.getBase().getWalkSpeed()));
sender.sendMessage(tl("whoisWhitelist", user.getBase().isWhitelisted() ? tl("true") : tl("false")));
if (user.isAfk()) {
sender.sendMessage(tl("whoisAFKSince", tl("true"), DateUtil.formatDateDiff(user.getAfkSince())));
} else {
Expand Down
1 change: 1 addition & 0 deletions Essentials/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,7 @@ whoisPlaytime=\u00a76 - Playtime\:\u00a7r {0}
whoisTempBanned=\u00a76 - Ban expires\:\u00a7r {0}
whoisTop=\u00a76 \=\=\=\=\=\= WhoIs\:\u00a7c {0} \u00a76\=\=\=\=\=\=
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
whoisWhitelist=\u00a76 - Whitelist\:\u00a7r {0}
workbenchCommandDescription=Opens up a workbench.
workbenchCommandUsage=/<command>
worldCommandDescription=Switch between worlds.
Expand Down
1 change: 1 addition & 0 deletions Essentials/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ permissions:
essentials.seen.ip: true
essentials.seen.location: true
essentials.seen.uuid: true
essentials.seen.whitelist: true
essentials.keepinv:
default: false
description: Controls whether players keep their inventory on death.
Expand Down

0 comments on commit 3c0cfbf

Please sign in to comment.