mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 20:00:46 +00:00
Kick players in /banip
The four-year-old to-do has finally been done! Closes #2143.
This commit is contained in:
parent
959c788f22
commit
e642192461
1 changed files with 9 additions and 1 deletions
|
@ -6,6 +6,7 @@ import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.utils.FormatUtil;
|
import com.earth2me.essentials.utils.FormatUtil;
|
||||||
import org.bukkit.BanList;
|
import org.bukkit.BanList;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -14,7 +15,6 @@ import java.util.logging.Level;
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
|
||||||
//TODO: Add kick to online players matching ip ban.
|
|
||||||
public class Commandbanip extends EssentialsCommand {
|
public class Commandbanip extends EssentialsCommand {
|
||||||
public Commandbanip() {
|
public Commandbanip() {
|
||||||
super("banip");
|
super("banip");
|
||||||
|
@ -51,9 +51,17 @@ public class Commandbanip extends EssentialsCommand {
|
||||||
banReason = tl("defaultBanReason");
|
banReason = tl("defaultBanReason");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String banDisplay = tl("banFormat", banReason, senderName);
|
||||||
|
|
||||||
ess.getServer().getBanList(BanList.Type.IP).addBan(ipAddress, banReason, null, senderName);
|
ess.getServer().getBanList(BanList.Type.IP).addBan(ipAddress, banReason, null, senderName);
|
||||||
server.getLogger().log(Level.INFO, tl("playerBanIpAddress", senderName, ipAddress, banReason));
|
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));
|
ess.broadcastMessage("essentials.banip.notify", tl("playerBanIpAddress", senderName, ipAddress, banReason));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue