Skip to content
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 related emails.

Already on GitHub? Sign in to your account

Add whitelist indicator for /seen and /whois #5486

Merged
merged 3 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
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
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 @@ -1569,6 +1569,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 @@ -638,6 +638,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