2011-03-19 22:39:51 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2013-10-16 19:59:39 +00:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
2013-03-10 22:43:20 +00:00
|
|
|
import com.earth2me.essentials.Console;
|
2011-11-27 15:58:47 +00:00
|
|
|
import com.earth2me.essentials.User;
|
2013-06-08 21:31:19 +00:00
|
|
|
import com.earth2me.essentials.utils.FormatUtil;
|
2014-07-12 16:37:25 +00:00
|
|
|
import org.bukkit.BanList;
|
2011-03-19 22:39:51 +00:00
|
|
|
import org.bukkit.Server;
|
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
import java.util.logging.Level;
|
|
|
|
|
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
2011-03-19 22:39:51 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
public class Commandunbanip extends EssentialsCommand {
|
|
|
|
public Commandunbanip() {
|
|
|
|
super("unbanip");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
|
|
|
if (args.length < 1) {
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
|
|
|
|
|
|
|
String ipAddress;
|
|
|
|
if (FormatUtil.validIP(args[0])) {
|
|
|
|
ipAddress = args[0];
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
User player = getPlayer(server, args, 0, true, true);
|
|
|
|
ipAddress = player.getLastLoginAddress();
|
|
|
|
} catch (PlayerNotFoundException ex) {
|
|
|
|
ipAddress = args[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ipAddress.isEmpty()) {
|
|
|
|
throw new PlayerNotFoundException();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ess.getServer().getBanList(BanList.Type.IP).pardon(ipAddress);
|
|
|
|
final String senderName = sender.isPlayer() ? sender.getPlayer().getDisplayName() : Console.NAME;
|
|
|
|
server.getLogger().log(Level.INFO, tl("playerUnbanIpAddress", senderName, ipAddress));
|
|
|
|
|
2019-09-04 07:32:07 +00:00
|
|
|
ess.broadcastMessage("essentials.banip.notify", tl("playerUnbanIpAddress", senderName, ipAddress));
|
2015-04-15 04:06:16 +00:00
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|