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 1 commit
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
5 changes: 5 additions & 0 deletions Essentials/src/main/java/com/earth2me/essentials/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -1242,4 +1242,9 @@ public boolean isToggleShout() {
}
return toggleShout == null ? toggleShout = ess.getSettings().isShoutDefault() : toggleShout;
}

public boolean isWhitelisted() {
JRoy marked this conversation as resolved.
Show resolved Hide resolved
final OfflinePlayerStub ops = new OfflinePlayerStub(this.getUUID(), this.getServer());
return ops.isWhitelisted();
}
}
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 Down Expand Up @@ -188,6 +189,10 @@ private void seenOffline(final CommandSource sender, final User user, final bool
sender.sendMessage(tl("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
}
}

if (showWhitelist) {
sender.sendMessage(tl("whoisWhitelist", user.isWhitelisted() ? tl("true") : tl("false")));
}
JRoy marked this conversation as resolved.
Show resolved Hide resolved
}

private void seenIP(final CommandSource sender, final String ipAddress, final String display) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public void run(final Server server, final CommandSource sender, final String co
sender.sendMessage(tl("whoisMutedReason", user.isMuted() ? muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true") : tl("false"),
user.getMuteReason()));
}

sender.sendMessage(tl("whoisWhitelist", user.isWhitelisted() ? tl("true") : tl("false")));
JRoy marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
Expand Down
1 change: 1 addition & 0 deletions Essentials/src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,7 @@ whoisPlaytime=§6 - Playtime\:§r {0}
whoisTempBanned=§6 - Ban expires\:§r {0}
whoisTop=§6 \=\=\=\=\=\= WhoIs\:§c {0} §6\=\=\=\=\=\=
whoisUuid=§6 - UUID\:§r {0}
whoisWhitelist=§6 - Whitelist\:§r {0}
JRoy marked this conversation as resolved.
Show resolved Hide resolved
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