Skip to content

Commit 575a814

Browse files
committed
Add ban reason to /banip
1 parent 093a1f6 commit 575a814

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

Essentials/src/com/earth2me/essentials/commands/Commandbanip.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
import com.earth2me.essentials.User;
77
import com.earth2me.essentials.utils.FormatUtil;
88
import java.util.logging.Level;
9+
import org.bukkit.BanList;
10+
import org.bukkit.Bukkit;
911
import org.bukkit.Server;
1012

1113

14+
//TODO: Add kick to online players matching ip ban.
1215
public class Commandbanip extends EssentialsCommand
1316
{
1417
public Commandbanip()
@@ -49,9 +52,19 @@ public void run(final Server server, final CommandSource sender, final String co
4952
throw new PlayerNotFoundException();
5053
}
5154

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));
5467

55-
ess.broadcastMessage("essentials.ban.notify", tl("playerBanIpAddress", senderName, ipAddress));
68+
ess.broadcastMessage("essentials.ban.notify", tl("playerBanIpAddress", senderName, ipAddress, banReason));
5669
}
5770
}

Essentials/src/messages.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ pWeatherPlayers=\u00a76These players have their own weather\:\u00a7r
321321
pWeatherReset=\u00a76Player weather has been reset for\: \u00a7c{0}
322322
pWeatherSet=\u00a76Player weather is set to \u00a7c{0}\u00a76 for\: \u00a7c{1}.
323323
pendingTeleportCancelled=\u00a74Pending teleportation request cancelled.
324-
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address\:\u00a7c {1}\u00a76.
325-
playerBanned=\u00a76Player\u00a7c {0} \u00a76banned\u00a7c {1} \u00a76for \u00a7c{2}\u00a76.
324+
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address\u00a7c {1} \u00a76for\: \u00a7c{2}\u00a76.
325+
playerBanned=\u00a76Player\u00a7c {0} \u00a76banned\u00a7c {1} \u00a76for\: \u00a7c{2}\u00a76.
326326
playerInJail=\u00a74Player is already in jail\u00a7c {0}\u00a74.
327327
playerJailed=\u00a76Player\u00a7c {0} \u00a76jailed.
328328
playerJailedFor=\u00a76Player\u00a7c {0} \u00a76jailed for {1}.

0 commit comments

Comments
 (0)