Kick players in /banip

The four-year-old to-do has finally been done!

Closes #2143.
This commit is contained in:
md678685 2018-08-26 22:54:00 +01:00
parent 959c788f22
commit e642192461
1 changed files with 9 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.BanList;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import java.util.Collections;
import java.util.List;
@ -14,7 +15,6 @@ import java.util.logging.Level;
import static com.earth2me.essentials.I18n.tl;
//TODO: Add kick to online players matching ip ban.
public class Commandbanip extends EssentialsCommand {
public Commandbanip() {
super("banip");
@ -51,9 +51,17 @@ public class Commandbanip extends EssentialsCommand {
banReason = tl("defaultBanReason");
}
String banDisplay = tl("banFormat", banReason, senderName);
ess.getServer().getBanList(BanList.Type.IP).addBan(ipAddress, banReason, null, senderName);
server.getLogger().log(Level.INFO, tl("playerBanIpAddress", senderName, ipAddress, banReason));
for (Player player : ess.getServer().getOnlinePlayers()) {
if (player.getAddress().getAddress().getHostAddress().equalsIgnoreCase(ipAddress)) {
player.kickPlayer(banDisplay);
}
}
ess.broadcastMessage("essentials.banip.notify", tl("playerBanIpAddress", senderName, ipAddress, banReason));
}