mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-05 16:08:14 +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
|
@Override
|
||||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
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) {
|
if (args.length < 1) {
|
||||||
throw new NotEnoughArgumentsException();
|
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;
|
User player;
|
||||||
// Check by uuid, if it fails check by name.
|
// Check by uuid, if it fails check by name.
|
||||||
try {
|
try {
|
||||||
@ -43,8 +45,12 @@ public class Commandseen extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
|
if (!searchAccounts) {
|
||||||
if (sender.isAuthorized("essentials.seen.ipsearch", ess) && FormatUtil.validIP(args[0])) {
|
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;
|
return;
|
||||||
} else if (ess.getServer().getBanList(BanList.Type.IP).isBanned(args[0])) {
|
} else if (ess.getServer().getBanList(BanList.Type.IP).isBanned(args[0])) {
|
||||||
sender.sendMessage(tl("isIpBanned", 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")));
|
sender.sendMessage(tl("whoisBanned", showBan ? BanLookup.getBanEntry(ess, args[0]).getReason() : tl("true")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ess.getScheduler().runTaskAsynchronously(ess, new Runnable() {
|
ess.getScheduler().runTaskAsynchronously(ess, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -73,16 +80,18 @@ public class Commandseen extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showUserSeen(final User user) throws Exception {
|
private void showUserSeen(final User user) throws Exception {
|
||||||
showSeenMessage(sender, user, showBan, showIp, showLocation);
|
showSeenMessage(sender, user, searchAccounts, showBan, showIp, showLocation);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} 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) {
|
private void showSeenMessage(final CommandSource sender, final User player, final boolean searchAccounts, final boolean showBan, final boolean showIp, final boolean showLocation) {
|
||||||
if (player.getBase().isOnline() && canInteractWith(sender, player)) {
|
if (searchAccounts) {
|
||||||
|
seenIP(sender, player.getLastLoginAddress(), player.getDisplayName());
|
||||||
|
} else if (player.getBase().isOnline() && canInteractWith(sender, player)) {
|
||||||
seenOnline(sender, player, showIp);
|
seenOnline(sender, player, showIp);
|
||||||
} else {
|
} else {
|
||||||
seenOffline(sender, player, showBan, showIp, showLocation);
|
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();
|
final UserMap userMap = ess.getUserMap();
|
||||||
|
|
||||||
if (ess.getServer().getBanList(BanList.Type.IP).isBanned(ipAddress)) {
|
sender.sendMessage(tl("runningPlayerMatch", display));
|
||||||
sender.sendMessage(tl("isIpBanned", ipAddress));
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(tl("runningPlayerMatch", ipAddress));
|
|
||||||
|
|
||||||
ess.runTaskAsynchronously(() -> {
|
ess.runTaskAsynchronously(() -> {
|
||||||
final List<String> matches = new ArrayList<>();
|
final List<String> matches = new ArrayList<>();
|
||||||
|
@ -391,7 +391,7 @@ commands:
|
|||||||
seen:
|
seen:
|
||||||
description: Shows the last logout time of a player.
|
description: Shows the last logout time of a player.
|
||||||
usage: /<command> <playername>
|
usage: /<command> <playername>
|
||||||
aliases: [eseen]
|
aliases: [eseen, ealts, alts]
|
||||||
sell:
|
sell:
|
||||||
description: Sells the item currently in your hand.
|
description: Sells the item currently in your hand.
|
||||||
usage: /<command> <<itemname>|<id>|hand|inventory|blocks> [-][amount]
|
usage: /<command> <<itemname>|<id>|hand|inventory|blocks> [-][amount]
|
||||||
|
Loading…
Reference in New Issue
Block a user