This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2013-10-16 21:59:39 +02:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
import com.earth2me.essentials.User;
|
2013-02-24 04:55:20 +01:00
|
|
|
import com.earth2me.essentials.UserMap;
|
2014-08-14 02:48:08 +02:00
|
|
|
import com.earth2me.essentials.craftbukkit.BanLookup;
|
2013-06-08 23:31:19 +02:00
|
|
|
import com.earth2me.essentials.utils.DateUtil;
|
|
|
|
import com.earth2me.essentials.utils.FormatUtil;
|
2013-10-11 04:44:41 +02:00
|
|
|
import com.earth2me.essentials.utils.StringUtil;
|
2015-04-15 06:06:16 +02:00
|
|
|
import org.bukkit.BanEntry;
|
|
|
|
import org.bukkit.BanList;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Server;
|
|
|
|
|
2013-02-24 04:55:20 +01:00
|
|
|
import java.util.ArrayList;
|
2020-10-03 19:46:05 +02:00
|
|
|
import java.util.Collections;
|
2014-07-14 22:23:56 +02:00
|
|
|
import java.util.Date;
|
2013-02-24 04:55:20 +01:00
|
|
|
import java.util.List;
|
2014-04-13 07:53:11 +02:00
|
|
|
import java.util.UUID;
|
2015-04-15 06:06:16 +02:00
|
|
|
|
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
public class Commandseen extends EssentialsCommand {
|
|
|
|
public Commandseen() {
|
|
|
|
super("seen");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
|
|
|
if (args.length < 1) {
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
2021-01-28 15:29:50 +01:00
|
|
|
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);
|
|
|
|
|
2016-01-02 11:46:42 +01:00
|
|
|
User player;
|
|
|
|
// Check by uuid, if it fails check by name.
|
|
|
|
try {
|
2020-10-03 19:46:05 +02:00
|
|
|
final UUID uuid = UUID.fromString(args[0]);
|
2016-01-02 11:46:42 +01:00
|
|
|
player = ess.getUser(uuid);
|
2020-10-03 19:46:05 +02:00
|
|
|
} catch (final IllegalArgumentException ignored) { // Thrown if invalid UUID from string, check by name.
|
2016-01-02 11:46:42 +01:00
|
|
|
player = ess.getOfflineUser(args[0]);
|
|
|
|
}
|
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
if (player == null) {
|
2021-01-28 15:29:50 +01:00
|
|
|
if (!searchAccounts) {
|
|
|
|
if (sender.isAuthorized("essentials.seen.ipsearch", ess) && FormatUtil.validIP(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]));
|
|
|
|
return;
|
|
|
|
} else if (BanLookup.isBanned(ess, args[0])) {
|
|
|
|
sender.sendMessage(tl("whoisBanned", showBan ? BanLookup.getBanEntry(ess, args[0]).getReason() : tl("true")));
|
|
|
|
return;
|
|
|
|
}
|
2016-03-01 16:36:41 +01:00
|
|
|
}
|
|
|
|
ess.getScheduler().runTaskAsynchronously(ess, new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2020-10-03 19:46:05 +02:00
|
|
|
final User userFromBukkit = ess.getUserMap().getUserFromBukkit(args[0]);
|
2015-12-02 01:32:53 +01:00
|
|
|
try {
|
2016-03-01 16:36:41 +01:00
|
|
|
if (userFromBukkit != null) {
|
|
|
|
showUserSeen(userFromBukkit);
|
|
|
|
} else {
|
Use playerNeverOnServer message where appropriate (#3489)
### Use `playerNeverOnServer` message where it should be used:
### https://github.com/EssentialsX/Essentials/pull/3489/commits/309e1c470d4bcfe2a2186f9720ce33f26441b802
`playerNeverOnServer=\u00a74Player\u00a7c {0} \u00a74was never on this server.` is currently used in the **Commandmail** class at [Line 61](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/Commandmail.java#L61), [Line 116](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/Commandmail.java#L116) and [Line 129](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/Commandmail.java#L129) however is **not called** as PlayerNotFoundException is thrown by `#getPlayer` breaking current execution (below).
```
Commandmail#run() throws Exception {
...
User u = getPlayer(server, args[1], true, true); // throws PlayerNotFoundException
if (u == null) {
throw new Exception(tl("playerNeverOnServer", args[1]));
}
...
}
```
Before changes:
![bm](https://user-images.githubusercontent.com/24858857/87236993-6b679180-c3e8-11ea-83a7-002194f5c467.png)
After changes:
![mailafter](https://user-images.githubusercontent.com/24858857/87237060-3576dd00-c3e9-11ea-8020-d5a80a958ca0.png)
--------------------------
**Commandseen** currently throws the default PlayerNotFoundException `playerNotFound` message for players that have not logged on to the server where it would be more appropriate to use the `playerNeverOnServer` message.
```
Commandseen#run throws Exception {
...
AsyncRunnable#run() {
User userFromBukkit = ess.getUserMap().getUserFromBukkit(args[0]); <-- ***
try {
if (userFromBukkit != null) { <--- ***
showUserSeen(userFromBukkit);
} else {
showUserSeen(getPlayer(server, sender, args, 0)); <--- ***
}
} catch (Exception e) {
ess.showError(sender, e, commandLabel);
}
}
private void showUserSeen(User user) throws Exception {
if (user == null) { <--- ***
throw new PlayerNotFoundException();
}
showSeenMessage(server, sender, user, showBan, showIp, showLocation);
}
...
}
```
**`<-- ***`:**
`usersFromBukkit` null check is performed before `#showUserSeen` so there is no need for another null check.
`EssentialsCommand#getPlayer` throws **NotEnoughArguementsException** or **PlayerNotFoundException** after [arg checks](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java#L88) and [player checks](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java#L103). https://github.com/EssentialsX/Essentials/pull/3489#issuecomment-657138524
Before changes:
![sb](https://user-images.githubusercontent.com/24858857/87237038-e9c43380-c3e8-11ea-8294-8f91e8b6f25d.png)
After changes:
![seenafter](https://user-images.githubusercontent.com/24858857/87237067-53444200-c3e9-11ea-92c5-1784b4dcd739.png)
----------------
### 725128e
Catch more specfic exception `PlayerNotFoundException`.
Before changes:
![banbefore](https://user-images.githubusercontent.com/24858857/87237021-c1d4d000-c3e8-11ea-99e4-eb97b5a5ba6d.png)
After changes:
![afterunban](https://user-images.githubusercontent.com/24858857/87237081-8d154880-c3e9-11ea-9d35-a25b8c105969.png)
2020-08-04 16:30:05 +02:00
|
|
|
try {
|
|
|
|
showUserSeen(getPlayer(server, sender, args, 0));
|
2020-10-03 19:46:05 +02:00
|
|
|
} catch (final PlayerNotFoundException e) {
|
Use playerNeverOnServer message where appropriate (#3489)
### Use `playerNeverOnServer` message where it should be used:
### https://github.com/EssentialsX/Essentials/pull/3489/commits/309e1c470d4bcfe2a2186f9720ce33f26441b802
`playerNeverOnServer=\u00a74Player\u00a7c {0} \u00a74was never on this server.` is currently used in the **Commandmail** class at [Line 61](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/Commandmail.java#L61), [Line 116](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/Commandmail.java#L116) and [Line 129](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/Commandmail.java#L129) however is **not called** as PlayerNotFoundException is thrown by `#getPlayer` breaking current execution (below).
```
Commandmail#run() throws Exception {
...
User u = getPlayer(server, args[1], true, true); // throws PlayerNotFoundException
if (u == null) {
throw new Exception(tl("playerNeverOnServer", args[1]));
}
...
}
```
Before changes:
![bm](https://user-images.githubusercontent.com/24858857/87236993-6b679180-c3e8-11ea-83a7-002194f5c467.png)
After changes:
![mailafter](https://user-images.githubusercontent.com/24858857/87237060-3576dd00-c3e9-11ea-8020-d5a80a958ca0.png)
--------------------------
**Commandseen** currently throws the default PlayerNotFoundException `playerNotFound` message for players that have not logged on to the server where it would be more appropriate to use the `playerNeverOnServer` message.
```
Commandseen#run throws Exception {
...
AsyncRunnable#run() {
User userFromBukkit = ess.getUserMap().getUserFromBukkit(args[0]); <-- ***
try {
if (userFromBukkit != null) { <--- ***
showUserSeen(userFromBukkit);
} else {
showUserSeen(getPlayer(server, sender, args, 0)); <--- ***
}
} catch (Exception e) {
ess.showError(sender, e, commandLabel);
}
}
private void showUserSeen(User user) throws Exception {
if (user == null) { <--- ***
throw new PlayerNotFoundException();
}
showSeenMessage(server, sender, user, showBan, showIp, showLocation);
}
...
}
```
**`<-- ***`:**
`usersFromBukkit` null check is performed before `#showUserSeen` so there is no need for another null check.
`EssentialsCommand#getPlayer` throws **NotEnoughArguementsException** or **PlayerNotFoundException** after [arg checks](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java#L88) and [player checks](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java#L103). https://github.com/EssentialsX/Essentials/pull/3489#issuecomment-657138524
Before changes:
![sb](https://user-images.githubusercontent.com/24858857/87237038-e9c43380-c3e8-11ea-8294-8f91e8b6f25d.png)
After changes:
![seenafter](https://user-images.githubusercontent.com/24858857/87237067-53444200-c3e9-11ea-92c5-1784b4dcd739.png)
----------------
### 725128e
Catch more specfic exception `PlayerNotFoundException`.
Before changes:
![banbefore](https://user-images.githubusercontent.com/24858857/87237021-c1d4d000-c3e8-11ea-99e4-eb97b5a5ba6d.png)
After changes:
![afterunban](https://user-images.githubusercontent.com/24858857/87237081-8d154880-c3e9-11ea-9d35-a25b8c105969.png)
2020-08-04 16:30:05 +02:00
|
|
|
throw new Exception(tl("playerNeverOnServer", args[0]));
|
|
|
|
}
|
2016-03-01 16:36:41 +01:00
|
|
|
}
|
2020-10-03 19:46:05 +02:00
|
|
|
} catch (final Exception e) {
|
2016-03-01 16:36:41 +01:00
|
|
|
ess.showError(sender, e, commandLabel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-03 19:46:05 +02:00
|
|
|
private void showUserSeen(final User user) throws Exception {
|
2021-01-28 15:29:50 +01:00
|
|
|
showSeenMessage(sender, user, searchAccounts, showBan, showIp, showLocation);
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
2016-03-01 16:36:41 +01:00
|
|
|
});
|
|
|
|
} else {
|
2021-01-28 15:29:50 +01:00
|
|
|
showSeenMessage(sender, player, searchAccounts, showBan, showIp, showLocation);
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
2016-03-01 16:36:41 +01:00
|
|
|
}
|
|
|
|
|
2021-01-28 15:29:50 +01:00
|
|
|
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)) {
|
2020-08-11 20:09:22 +02:00
|
|
|
seenOnline(sender, player, showIp);
|
2015-04-15 06:06:16 +02:00
|
|
|
} else {
|
2020-08-11 20:09:22 +02:00
|
|
|
seenOffline(sender, player, showBan, showIp, showLocation);
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-11 20:09:22 +02:00
|
|
|
private void seenOnline(final CommandSource sender, final User user, final boolean showIp) {
|
2015-04-15 06:06:16 +02:00
|
|
|
|
|
|
|
user.setDisplayNick();
|
|
|
|
sender.sendMessage(tl("seenOnline", user.getDisplayName(), DateUtil.formatDateDiff(user.getLastLogin())));
|
|
|
|
|
2020-10-03 19:46:05 +02:00
|
|
|
final List<String> history = ess.getUserMap().getUserHistory(user.getBase().getUniqueId());
|
2015-04-15 06:06:16 +02:00
|
|
|
if (history != null && history.size() > 1) {
|
|
|
|
sender.sendMessage(tl("seenAccounts", StringUtil.joinListSkip(", ", user.getName(), history)));
|
|
|
|
}
|
|
|
|
|
2021-11-06 21:50:56 +01:00
|
|
|
if (sender.isAuthorized("essentials.seen.uuid", ess)) {
|
|
|
|
sender.sendMessage(tl("whoisUuid", user.getBase().getUniqueId().toString()));
|
|
|
|
}
|
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
if (user.isAfk()) {
|
|
|
|
sender.sendMessage(tl("whoisAFK", tl("true")));
|
|
|
|
}
|
|
|
|
if (user.isJailed()) {
|
2021-01-23 23:41:24 +01:00
|
|
|
sender.sendMessage(tl("whoisJail", user.getJailTimeout() > 0 ? user.getFormattedJailTime() : tl("true")));
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
|
|
|
if (user.isMuted()) {
|
2020-10-03 19:46:05 +02:00
|
|
|
final long muteTimeout = user.getMuteTimeout();
|
2017-12-27 01:09:46 +01:00
|
|
|
if (!user.hasMuteReason()) {
|
2020-10-03 19:46:05 +02:00
|
|
|
sender.sendMessage(tl("whoisMuted", muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true")));
|
2017-12-27 01:09:46 +01:00
|
|
|
} else {
|
2020-10-03 19:46:05 +02:00
|
|
|
sender.sendMessage(tl("whoisMutedReason", muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true"), user.getMuteReason()));
|
2017-12-27 01:09:46 +01:00
|
|
|
}
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
|
|
|
final String location = user.getGeoLocation();
|
2020-10-03 19:46:05 +02:00
|
|
|
if (location != null && (!sender.isPlayer() || ess.getUser(sender.getPlayer()).isAuthorized("essentials.geoip.show"))) {
|
2015-04-15 06:06:16 +02:00
|
|
|
sender.sendMessage(tl("whoisGeoLocation", location));
|
|
|
|
}
|
2018-03-21 05:50:42 +01:00
|
|
|
if (showIp) {
|
2015-04-15 06:06:16 +02:00
|
|
|
sender.sendMessage(tl("whoisIPAddress", user.getBase().getAddress().getAddress().toString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-03 19:46:05 +02:00
|
|
|
private void seenOffline(final CommandSource sender, final User user, final boolean showBan, final boolean showIp, final boolean showLocation) {
|
2015-04-15 06:06:16 +02:00
|
|
|
user.setDisplayNick();
|
|
|
|
if (user.getLastLogout() > 0) {
|
|
|
|
sender.sendMessage(tl("seenOffline", user.getName(), DateUtil.formatDateDiff(user.getLastLogout())));
|
2021-11-06 21:50:56 +01:00
|
|
|
final List<String> history = ess.getUserMap().getUserHistory(user.getBase().getUniqueId());
|
|
|
|
if (history != null && history.size() > 1) {
|
|
|
|
sender.sendMessage(tl("seenAccounts", StringUtil.joinListSkip(", ", user.getName(), history)));
|
|
|
|
}
|
|
|
|
|
2021-09-28 15:13:50 +02:00
|
|
|
if (sender.isAuthorized("essentials.seen.uuid", ess)) {
|
|
|
|
sender.sendMessage(tl("whoisUuid", user.getBase().getUniqueId()));
|
|
|
|
}
|
2015-04-15 06:06:16 +02:00
|
|
|
} else {
|
|
|
|
sender.sendMessage(tl("userUnknown", user.getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BanLookup.isBanned(ess, user)) {
|
|
|
|
final BanEntry banEntry = BanLookup.getBanEntry(ess, user.getName());
|
|
|
|
final String reason = showBan ? banEntry.getReason() : tl("true");
|
|
|
|
sender.sendMessage(tl("whoisBanned", reason));
|
|
|
|
if (banEntry.getExpiration() != null) {
|
2020-10-03 19:46:05 +02:00
|
|
|
final Date expiry = banEntry.getExpiration();
|
2015-04-15 06:06:16 +02:00
|
|
|
String expireString = tl("now");
|
|
|
|
if (expiry.after(new Date())) {
|
|
|
|
expireString = DateUtil.formatDateDiff(expiry.getTime());
|
|
|
|
}
|
|
|
|
sender.sendMessage(tl("whoisTempBanned", expireString));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-27 01:09:46 +01:00
|
|
|
if (user.isMuted()) {
|
2020-10-03 19:46:05 +02:00
|
|
|
final long muteTimeout = user.getMuteTimeout();
|
2017-12-27 01:09:46 +01:00
|
|
|
if (!user.hasMuteReason()) {
|
2020-10-03 19:46:05 +02:00
|
|
|
sender.sendMessage(tl("whoisMuted", muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true")));
|
2017-12-27 01:09:46 +01:00
|
|
|
} else {
|
2020-10-03 19:46:05 +02:00
|
|
|
sender.sendMessage(tl("whoisMutedReason", muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true"), user.getMuteReason()));
|
2017-12-27 01:09:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
final String location = user.getGeoLocation();
|
2020-10-03 19:46:05 +02:00
|
|
|
if (location != null && (!sender.isPlayer() || ess.getUser(sender.getPlayer()).isAuthorized("essentials.geoip.show"))) {
|
2015-04-15 06:06:16 +02:00
|
|
|
sender.sendMessage(tl("whoisGeoLocation", location));
|
|
|
|
}
|
2018-03-21 05:50:42 +01:00
|
|
|
if (showIp) {
|
2015-04-15 06:06:16 +02:00
|
|
|
if (!user.getLastLoginAddress().isEmpty()) {
|
|
|
|
sender.sendMessage(tl("whoisIPAddress", user.getLastLoginAddress()));
|
|
|
|
}
|
2018-03-21 05:50:42 +01:00
|
|
|
}
|
|
|
|
if (showLocation) {
|
2015-04-15 06:06:16 +02:00
|
|
|
final Location loc = user.getLogoutLocation();
|
|
|
|
if (loc != null) {
|
|
|
|
sender.sendMessage(tl("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-28 15:29:50 +01:00
|
|
|
private void seenIP(final CommandSource sender, final String ipAddress, final String display) {
|
2015-04-15 06:06:16 +02:00
|
|
|
final UserMap userMap = ess.getUserMap();
|
|
|
|
|
2021-01-28 15:29:50 +01:00
|
|
|
sender.sendMessage(tl("runningPlayerMatch", display));
|
2015-04-15 06:06:16 +02:00
|
|
|
|
2020-04-25 14:08:57 +02:00
|
|
|
ess.runTaskAsynchronously(() -> {
|
|
|
|
final List<String> matches = new ArrayList<>();
|
|
|
|
for (final UUID u : userMap.getAllUniqueUsers()) {
|
|
|
|
final User user = ess.getUserMap().getUser(u);
|
|
|
|
if (user == null) {
|
|
|
|
continue;
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
|
|
|
|
2020-04-25 14:08:57 +02:00
|
|
|
final String uIPAddress = user.getLastLoginAddress();
|
|
|
|
|
|
|
|
if (!uIPAddress.isEmpty() && uIPAddress.equalsIgnoreCase(ipAddress)) {
|
|
|
|
matches.add(user.getName());
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
2020-04-25 14:08:57 +02:00
|
|
|
}
|
2015-04-15 06:06:16 +02:00
|
|
|
|
2020-04-25 14:08:57 +02:00
|
|
|
if (matches.size() > 0) {
|
|
|
|
sender.sendMessage(tl("matchingIPAddress"));
|
|
|
|
sender.sendMessage(StringUtil.joinList(matches));
|
|
|
|
} else {
|
|
|
|
sender.sendMessage(tl("noMatchingPlayers"));
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
2020-04-25 14:08:57 +02:00
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
}
|
2017-08-12 15:42:57 +02:00
|
|
|
|
|
|
|
@Override
|
2020-10-03 19:46:05 +02:00
|
|
|
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
2017-08-12 15:42:57 +02:00
|
|
|
if (args.length == 1) {
|
|
|
|
return getPlayers(server, sender);
|
|
|
|
} else {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
}
|