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 21:07:30 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2011-11-21 01:55:26 +00:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
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 21:07:30 +00:00
|
|
|
import com.earth2me.essentials.User;
|
2013-02-24 03:55:20 +00:00
|
|
|
import com.earth2me.essentials.UserMap;
|
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 21:07:30 +00:00
|
|
|
import com.earth2me.essentials.Util;
|
2013-02-24 03:55:20 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2012-04-04 00:18:21 +00:00
|
|
|
import org.bukkit.Location;
|
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 21:07:30 +00:00
|
|
|
import org.bukkit.Server;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
|
|
|
|
|
|
|
|
public class Commandseen extends EssentialsCommand
|
|
|
|
{
|
|
|
|
public Commandseen()
|
|
|
|
{
|
|
|
|
super("seen");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-12-01 13:42:39 +00:00
|
|
|
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
2012-03-12 15:00:44 +00:00
|
|
|
{
|
2013-02-24 03:55:20 +00:00
|
|
|
seen(server, sender, args, true, true, true);
|
2012-03-12 15:00:44 +00:00
|
|
|
}
|
2012-03-21 23:54:57 +00:00
|
|
|
|
2012-03-12 15:00:44 +00:00
|
|
|
@Override
|
|
|
|
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
|
|
|
{
|
2013-02-24 03:55:20 +00:00
|
|
|
seen(server, user, args, user.isAuthorized("essentials.seen.banreason"), user.isAuthorized("essentials.seen.extra"), user.isAuthorized("essentials.seen.ipsearch"));
|
2012-03-12 15:00:44 +00:00
|
|
|
}
|
2012-03-21 23:54:57 +00:00
|
|
|
|
2013-02-24 03:55:20 +00:00
|
|
|
protected void seen(final Server server, final CommandSender sender, final String[] args, final boolean showBan, final boolean extra, final boolean ipLookup) throws Exception
|
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 21:07:30 +00:00
|
|
|
{
|
|
|
|
if (args.length < 1)
|
|
|
|
{
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
2012-12-20 20:37:04 +00:00
|
|
|
User user = getPlayer(server, args, 0);
|
2013-02-24 03:55:20 +00:00
|
|
|
seenOnline(server, sender, user, showBan, extra);
|
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 21:07:30 +00:00
|
|
|
}
|
|
|
|
catch (NoSuchFieldException e)
|
|
|
|
{
|
2012-03-12 15:00:44 +00:00
|
|
|
User player = ess.getOfflineUser(args[0]);
|
|
|
|
if (player == null)
|
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 21:07:30 +00:00
|
|
|
{
|
2013-02-24 03:55:20 +00:00
|
|
|
if (ipLookup && Util.validIP(args[0]))
|
|
|
|
{
|
|
|
|
seenIP(server, sender, args[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new Exception(_("playerNotFound"));
|
|
|
|
}
|
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 21:07:30 +00:00
|
|
|
}
|
2013-02-24 03:55:20 +00:00
|
|
|
seenOffline(server, sender, player, showBan, extra);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void seenOnline(final Server server, final CommandSender sender, final User user, final boolean showBan, final boolean extra) throws Exception
|
|
|
|
{
|
|
|
|
|
|
|
|
user.setDisplayNick();
|
|
|
|
sender.sendMessage(_("seenOnline", user.getDisplayName(), Util.formatDateDiff(user.getLastLogin())));
|
|
|
|
if (user.isAfk())
|
|
|
|
{
|
|
|
|
sender.sendMessage(_("whoisAFK", _("true")));
|
|
|
|
}
|
|
|
|
if (user.isJailed())
|
|
|
|
{
|
|
|
|
sender.sendMessage(_("whoisJail", (user.getJailTimeout() > 0
|
|
|
|
? Util.formatDateDiff(user.getJailTimeout())
|
|
|
|
: _("true"))));
|
|
|
|
}
|
|
|
|
if (user.isMuted())
|
|
|
|
{
|
|
|
|
sender.sendMessage(_("whoisMuted", (user.getMuteTimeout() > 0
|
|
|
|
? Util.formatDateDiff(user.getMuteTimeout())
|
|
|
|
: _("true"))));
|
|
|
|
}
|
|
|
|
if (extra)
|
|
|
|
{
|
|
|
|
sender.sendMessage(_("whoisIPAddress", user.getAddress().getAddress().toString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void seenOffline(final Server server, final CommandSender sender, User player, final boolean showBan, final boolean extra) throws Exception
|
|
|
|
{
|
|
|
|
player.setDisplayNick();
|
|
|
|
if (player.getLastLogout() > 0)
|
|
|
|
{
|
|
|
|
sender.sendMessage(_("seenOffline", player.getName(), Util.formatDateDiff(player.getLastLogout())));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sender.sendMessage(_("userUnknown", player.getName()));
|
|
|
|
}
|
|
|
|
if (player.isBanned())
|
|
|
|
{
|
|
|
|
sender.sendMessage(_("whoisBanned", showBan ? player.getBanReason() : _("true")));
|
|
|
|
}
|
|
|
|
if (extra)
|
|
|
|
{
|
|
|
|
if (!player.getLastLoginAddress().isEmpty())
|
2013-02-17 01:18:50 +00:00
|
|
|
{
|
2013-02-24 03:55:20 +00:00
|
|
|
sender.sendMessage(_("whoisIPAddress", player.getLastLoginAddress()));
|
2013-02-17 01:18:50 +00:00
|
|
|
}
|
2013-02-24 03:55:20 +00:00
|
|
|
final Location loc = player.getLogoutLocation();
|
|
|
|
if (loc != null)
|
2011-12-07 11:00:01 +00:00
|
|
|
{
|
2013-02-24 03:55:20 +00:00
|
|
|
sender.sendMessage(_("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
2012-04-04 00:18:21 +00:00
|
|
|
}
|
2013-02-24 03:55:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void seenIP(final Server server, final CommandSender sender, final String ipAddress) throws Exception
|
|
|
|
{
|
|
|
|
final UserMap userMap = ess.getUserMap();
|
|
|
|
sender.sendMessage(_("runningPlayerMatch", ipAddress));
|
|
|
|
|
|
|
|
ess.runTaskAsynchronously(new Runnable()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void run()
|
2012-04-04 00:18:21 +00:00
|
|
|
{
|
2013-02-24 03:55:20 +00:00
|
|
|
final List<String> matches = new ArrayList<String>();
|
|
|
|
for (final String u : userMap.getAllUniqueUsers())
|
|
|
|
{
|
|
|
|
final User user = ess.getUserMap().getUser(u);
|
|
|
|
if (user == null)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
final String uIPAddress = user.getLastLoginAddress();
|
|
|
|
|
|
|
|
if (!uIPAddress.isEmpty() && uIPAddress.equalsIgnoreCase(ipAddress))
|
|
|
|
{
|
|
|
|
matches.add(user.getName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (matches.size() > 0)
|
2013-02-17 01:18:50 +00:00
|
|
|
{
|
2013-02-24 03:55:20 +00:00
|
|
|
sender.sendMessage(_("matchingIPAddress"));
|
|
|
|
sender.sendMessage(Util.joinList(matches));
|
2013-02-17 01:18:50 +00:00
|
|
|
}
|
2013-02-24 03:55:20 +00:00
|
|
|
else
|
2012-12-20 22:47:49 +00:00
|
|
|
{
|
2013-02-24 03:55:20 +00:00
|
|
|
sender.sendMessage(_("noMatchingPlayers"));
|
2012-04-14 14:57:47 +00:00
|
|
|
}
|
2013-02-24 03:55:20 +00:00
|
|
|
|
2011-12-07 11:00:01 +00:00
|
|
|
}
|
2013-02-24 03:55:20 +00:00
|
|
|
});
|
|
|
|
|
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 21:07:30 +00:00
|
|
|
}
|
|
|
|
}
|