|
6 | 6 | import com.earth2me.essentials.User;
|
7 | 7 | import com.earth2me.essentials.utils.FormatUtil;
|
8 | 8 | import java.util.logging.Level;
|
| 9 | +import org.bukkit.BanList; |
| 10 | +import org.bukkit.Bukkit; |
9 | 11 | import org.bukkit.Server;
|
10 | 12 |
|
11 | 13 |
|
| 14 | +//TODO: Add kick to online players matching ip ban. |
12 | 15 | public class Commandbanip extends EssentialsCommand
|
13 | 16 | {
|
14 | 17 | public Commandbanip()
|
@@ -49,9 +52,19 @@ public void run(final Server server, final CommandSource sender, final String co
|
49 | 52 | throw new PlayerNotFoundException();
|
50 | 53 | }
|
51 | 54 |
|
52 |
| - ess.getServer().banIP(ipAddress); |
53 |
| - server.getLogger().log(Level.INFO, tl("playerBanIpAddress", senderName, ipAddress)); |
| 55 | + String banReason; |
| 56 | + if (args.length > 1) |
| 57 | + { |
| 58 | + banReason = FormatUtil.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n")); |
| 59 | + } |
| 60 | + else |
| 61 | + { |
| 62 | + banReason = tl("defaultBanReason"); |
| 63 | + } |
| 64 | + |
| 65 | + Bukkit.getBanList(BanList.Type.IP).addBan(ipAddress, banReason, null, senderName); |
| 66 | + server.getLogger().log(Level.INFO, tl("playerBanIpAddress", senderName, ipAddress, banReason)); |
54 | 67 |
|
55 |
| - ess.broadcastMessage("essentials.ban.notify", tl("playerBanIpAddress", senderName, ipAddress)); |
| 68 | + ess.broadcastMessage("essentials.ban.notify", tl("playerBanIpAddress", senderName, ipAddress, banReason)); |
56 | 69 | }
|
57 | 70 | }
|
0 commit comments