TF-EssentialsX/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java

50 lines
1.3 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
2013-03-10 22:43:20 +00:00
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
2013-06-08 21:31:19 +00:00
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.logging.Level;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
2013-03-10 22:43:20 +00:00
import org.bukkit.entity.Player;
public class Commandunbanip extends EssentialsCommand
{
public Commandunbanip()
{
super("unbanip");
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
2013-03-10 22:43:20 +00:00
String ipAddress;
2013-06-08 21:31:19 +00:00
if (FormatUtil.validIP(args[0]))
2013-03-10 22:43:20 +00:00
{
ipAddress = args[0];
}
else
{
final User user = getPlayer(server, args, 0, true, true);
2013-03-10 22:43:20 +00:00
ipAddress = user.getLastLoginAddress();
if (ipAddress.isEmpty())
{
throw new PlayerNotFoundException();
}
}
2013-03-10 22:43:20 +00:00
ess.getServer().unbanIP(ipAddress);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
server.getLogger().log(Level.INFO, _("playerUnbanIpAddress", senderName, ipAddress));
2013-05-26 16:58:04 +00:00
ess.broadcastMessage(sender, "essentials.ban.notify", _("playerUnbanIpAddress", senderName, ipAddress));
}
}