mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 15:08:18 +01:00
Add /alts alias for /seen (#3931)
Adds `essentials.alts` also to allow server admins to not give mods the ips of users. Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
parent
89c1e3b60d
commit
79406613c1
@ -27,12 +27,14 @@ public class Commandseen extends EssentialsCommand {
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
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);
|
||||
if (args.length < 1) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
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 searchAccounts = commandLabel.contains("alts") && sender.isAuthorized("essentials.seen.alts", ess);
|
||||
|
||||
User player;
|
||||
// Check by uuid, if it fails check by name.
|
||||
try {
|
||||
@ -43,8 +45,12 @@ public class Commandseen extends EssentialsCommand {
|
||||
}
|
||||
|
||||
if (player == null) {
|
||||
if (!searchAccounts) {
|
||||
if (sender.isAuthorized("essentials.seen.ipsearch", ess) && FormatUtil.validIP(args[0])) {
|
||||
seenIP(sender, args[0]);
|
||||
if (ess.getServer().getBanList(BanList.Type.IP).isBanned(args[0])) {
|
||||
sender.sendMessage(tl("isIpBanned", args[0]));
|
||||
}
|
||||
seenIP(sender, args[0], args[0]);
|
||||
return;
|
||||
} else if (ess.getServer().getBanList(BanList.Type.IP).isBanned(args[0])) {
|
||||
sender.sendMessage(tl("isIpBanned", args[0]));
|
||||
@ -53,6 +59,7 @@ public class Commandseen extends EssentialsCommand {
|
||||
sender.sendMessage(tl("whoisBanned", showBan ? BanLookup.getBanEntry(ess, args[0]).getReason() : tl("true")));
|
||||
return;
|
||||
}
|
||||
}
|
||||
ess.getScheduler().runTaskAsynchronously(ess, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -73,16 +80,18 @@ public class Commandseen extends EssentialsCommand {
|
||||
}
|
||||
|
||||
private void showUserSeen(final User user) throws Exception {
|
||||
showSeenMessage(sender, user, showBan, showIp, showLocation);
|
||||
showSeenMessage(sender, user, searchAccounts, showBan, showIp, showLocation);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
showSeenMessage(sender, player, showBan, showIp, showLocation);
|
||||
showSeenMessage(sender, player, searchAccounts, showBan, showIp, showLocation);
|
||||
}
|
||||
}
|
||||
|
||||
private void showSeenMessage(final CommandSource sender, final User player, final boolean showBan, final boolean showIp, final boolean showLocation) {
|
||||
if (player.getBase().isOnline() && canInteractWith(sender, player)) {
|
||||
private void showSeenMessage(final CommandSource sender, final User player, final boolean searchAccounts, final boolean showBan, final boolean showIp, final boolean showLocation) {
|
||||
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);
|
||||
@ -183,14 +192,10 @@ public class Commandseen extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private void seenIP(final CommandSource sender, final String ipAddress) {
|
||||
private void seenIP(final CommandSource sender, final String ipAddress, final String display) {
|
||||
final UserMap userMap = ess.getUserMap();
|
||||
|
||||
if (ess.getServer().getBanList(BanList.Type.IP).isBanned(ipAddress)) {
|
||||
sender.sendMessage(tl("isIpBanned", ipAddress));
|
||||
}
|
||||
|
||||
sender.sendMessage(tl("runningPlayerMatch", ipAddress));
|
||||
sender.sendMessage(tl("runningPlayerMatch", display));
|
||||
|
||||
ess.runTaskAsynchronously(() -> {
|
||||
final List<String> matches = new ArrayList<>();
|
||||
|
@ -391,7 +391,7 @@ commands:
|
||||
seen:
|
||||
description: Shows the last logout time of a player.
|
||||
usage: /<command> <playername>
|
||||
aliases: [eseen]
|
||||
aliases: [eseen, ealts, alts]
|
||||
sell:
|
||||
description: Sells the item currently in your hand.
|
||||
usage: /<command> <<itemname>|<id>|hand|inventory|blocks> [-][amount]
|
||||
|
Loading…
Reference in New Issue
Block a user