From d20aa0504ef13fef52d60caa91f131dc9de760d2 Mon Sep 17 00:00:00 2001 From: Riaku Date: Thu, 4 Apr 2013 08:01:02 -0500 Subject: regex check on banip command format if player name is not found --- Essentials/src/messages.properties | 1 + Essentials/src/net/ess3/commands/Commandbanip.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index ea55baaf7..45c6a2e41 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -505,5 +505,6 @@ recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 to see other recipes for \u00a7c{2} recipeWhere=\u00a76Where: {0} +invalidIpAddress=\u00a74Invalid IP address #, java-format Hello\ {0},\ how\ are\ you?=\u00a7fHello \u00a74{0}\u00a7f, how are you? diff --git a/Essentials/src/net/ess3/commands/Commandbanip.java b/Essentials/src/net/ess3/commands/Commandbanip.java index a7f66016b..f08d08843 100644 --- a/Essentials/src/net/ess3/commands/Commandbanip.java +++ b/Essentials/src/net/ess3/commands/Commandbanip.java @@ -19,8 +19,15 @@ public class Commandbanip extends EssentialsCommand if (player == null) { - ess.getServer().banIP(args[0]); - sender.sendMessage(_("banIpAddress")); + if(args[0].matches("\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b")) + { + ess.getServer().banIP(args[0]); + sender.sendMessage(_("banIpAddress")); + } + else + { + sender.sendMessage(_("invalidIpAddress")); + } } else { -- cgit v1.2.3