Skip to content

Commit

Permalink
Add ban reason to /banip
Browse files Browse the repository at this point in the history
  • Loading branch information
khobbits committed Jul 12, 2014
1 parent 093a1f6 commit 575a814
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 16 additions & 3 deletions Essentials/src/com/earth2me/essentials/commands/Commandbanip.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.logging.Level;
import org.bukkit.BanList;
import org.bukkit.Bukkit;
import org.bukkit.Server;


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

ess.getServer().banIP(ipAddress);
server.getLogger().log(Level.INFO, tl("playerBanIpAddress", senderName, ipAddress));
String banReason;
if (args.length > 1)
{
banReason = FormatUtil.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n"));
}
else
{
banReason = tl("defaultBanReason");
}

Bukkit.getBanList(BanList.Type.IP).addBan(ipAddress, banReason, null, senderName);
server.getLogger().log(Level.INFO, tl("playerBanIpAddress", senderName, ipAddress, banReason));

ess.broadcastMessage("essentials.ban.notify", tl("playerBanIpAddress", senderName, ipAddress));
ess.broadcastMessage("essentials.ban.notify", tl("playerBanIpAddress", senderName, ipAddress, banReason));
}
}
4 changes: 2 additions & 2 deletions Essentials/src/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ pWeatherPlayers=\u00a76These players have their own weather\:\u00a7r
pWeatherReset=\u00a76Player weather has been reset for\: \u00a7c{0}
pWeatherSet=\u00a76Player weather is set to \u00a7c{0}\u00a76 for\: \u00a7c{1}.
pendingTeleportCancelled=\u00a74Pending teleportation request cancelled.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address\:\u00a7c {1}\u00a76.
playerBanned=\u00a76Player\u00a7c {0} \u00a76banned\u00a7c {1} \u00a76for \u00a7c{2}\u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address\u00a7c {1} \u00a76for\: \u00a7c{2}\u00a76.
playerBanned=\u00a76Player\u00a7c {0} \u00a76banned\u00a7c {1} \u00a76for\: \u00a7c{2}\u00a76.
playerInJail=\u00a74Player is already in jail\u00a7c {0}\u00a74.
playerJailed=\u00a76Player\u00a7c {0} \u00a76jailed.
playerJailedFor=\u00a76Player\u00a7c {0} \u00a76jailed for {1}.
Expand Down

0 comments on commit 575a814

Please sign in to comment.