From e6421924619a560b35f15e19cbaf2dd2df720f36 Mon Sep 17 00:00:00 2001 From: md678685 Date: Sun, 26 Aug 2018 22:54:00 +0100 Subject: [PATCH] Kick players in /banip The four-year-old to-do has finally been done! Closes #2143. --- .../com/earth2me/essentials/commands/Commandbanip.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java index 395ff173f..1ba6bb56e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java @@ -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)); }