2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2026-05-03 11:40:29 +00:00

* Don't shade in commons-lang anymore, replaced with SimpleDateFormat instead.

* Add IP address logging support.
 * Add /ip command with permission node redisbungee.command.ip.
 * Mark some stuff as final so that the JVM can optimize things a little more.
This commit is contained in:
Tux
2013-12-13 16:32:55 -05:00
parent 14aba0ffb3
commit cacea73f2e
4 changed files with 69 additions and 28 deletions

View File

@@ -14,10 +14,9 @@ import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.plugin.Command;
import org.apache.commons.lang3.time.FastDateFormat;
import java.util.Set;
import java.util.TreeSet;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.concurrent.TimeUnit;
/**
@@ -82,8 +81,6 @@ public class RedisBungeeCommands {
}
public static class LastSeenCommand extends Command {
FastDateFormat format = FastDateFormat.getInstance();
protected LastSeenCommand() {
super("lastseen", "redisbungee.command.lastseen");
}
@@ -95,7 +92,7 @@ public class RedisBungeeCommands {
if (secs == 0) {
sender.sendMessage(ChatColor.GREEN + args[0] + " is currently online.");
} else if (secs != -1) {
sender.sendMessage(ChatColor.BLUE + args[0] + " was last online on " + format.format(TimeUnit.SECONDS.toMillis(secs)) + ".");
sender.sendMessage(ChatColor.BLUE + args[0] + " was last online on " + new SimpleDateFormat().format(TimeUnit.SECONDS.toMillis(secs)) + ".");
} else {
sender.sendMessage(ChatColor.RED + args[0] + " has never been online.");
}
@@ -104,4 +101,24 @@ public class RedisBungeeCommands {
}
}
}
public static class IpCommand extends Command {
protected IpCommand() {
super("ip", "redisbungee.command.ip", "playerip");
}
@Override
public void execute(CommandSender sender, String[] args) {
if (args.length > 0) {
InetAddress ia = RedisBungee.getApi().getPlayerIp(args[0]);
if (ia != null) {
sender.sendMessage(ChatColor.GREEN + args[0] + " is connected from " + ia.toString() + ".");
} else {
sender.sendMessage(ChatColor.RED + "No such player found.");
}
} else {
sender.sendMessage(ChatColor.RED + "You must specify a player name.");
}
}
}
}