2011-03-19 22:39:51 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2013-10-16 20:59:39 +01:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
2013-03-10 18:43:20 -04:00
|
|
|
import com.earth2me.essentials.Console;
|
2011-11-27 16:58:47 +01:00
|
|
|
import com.earth2me.essentials.User;
|
2013-06-08 22:31:19 +01:00
|
|
|
import com.earth2me.essentials.utils.FormatUtil;
|
2014-07-12 17:37:25 +01:00
|
|
|
import org.bukkit.BanList;
|
2011-03-19 22:39:51 +00:00
|
|
|
import org.bukkit.Server;
|
|
|
|
|
2015-04-14 23:06:16 -05:00
|
|
|
import java.util.logging.Level;
|
|
|
|
|
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
|
|
|
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 {
|
2020-10-03 18:46:05 +01:00
|
|
|
final User player = getPlayer(server, args, 0, true, true);
|
2015-04-14 23:06:16 -05:00
|
|
|
ipAddress = player.getLastLoginAddress();
|
2020-10-03 18:46:05 +01:00
|
|
|
} catch (final PlayerNotFoundException ex) {
|
2015-04-14 23:06:16 -05:00
|
|
|
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 03:32:07 -04:00
|
|
|
ess.broadcastMessage("essentials.banip.notify", tl("playerUnbanIpAddress", senderName, ipAddress));
|
2015-04-14 23:06:16 -05:00
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|