diff options
author | KHobbits <rob@khobbits.co.uk> | 2013-01-09 20:59:27 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-01-09 21:04:58 +0000 |
commit | 341cb89bb7cacfed3ea2f106cc55eea312c80fd2 (patch) | |
tree | 489db830af22616732ffa139d420dc8bbd088a90 | |
parent | 79004c7098f96247f798d9f04d26cb0d9594d65d (diff) | |
download | Essentials-341cb89bb7cacfed3ea2f106cc55eea312c80fd2.tar Essentials-341cb89bb7cacfed3ea2f106cc55eea312c80fd2.tar.gz Essentials-341cb89bb7cacfed3ea2f106cc55eea312c80fd2.tar.lz Essentials-341cb89bb7cacfed3ea2f106cc55eea312c80fd2.tar.xz Essentials-341cb89bb7cacfed3ea2f106cc55eea312c80fd2.zip |
Multiline kick messages and tempban countdown.
4 files changed, 25 insertions, 10 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 9b4585112..93b793e49 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -6,7 +6,6 @@ import com.earth2me.essentials.textreader.KeywordReplacer; import com.earth2me.essentials.textreader.TextInput; import com.earth2me.essentials.textreader.TextPager; import java.io.IOException; -import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -307,8 +306,17 @@ public class EssentialsPlayerListener implements Listener if (!banExpired && (user.isBanned() || event.getResult() == Result.KICK_BANNED)) { - final String banReason = user.getBanReason(); - event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason")); + String banReason = user.getBanReason(); + if (banReason == null || banReason.isEmpty() || banReason.equalsIgnoreCase("ban")) + { + banReason = _("defaultBanReason"); + } + if (user.getBanTimeout() > 0) + { + //TODO: TL This + banReason += "\n\n" + "Expires in " + Util.formatDateDiff(user.getBanTimeout()); + } + event.disallow(Result.KICK_BANNED, banReason); return; } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java index c05c66ad0..c84441ac4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java @@ -25,9 +25,11 @@ public class Commandkick extends EssentialsCommand } final User target = getPlayer(server, args, 0, true); - if (sender instanceof Player) { + if (sender instanceof Player) + { User user = ess.getUser(sender); - if (target.isHidden() && !user.isAuthorized("essentials.list.hidden")) { + if (target.isHidden() && !user.isAuthorized("essentials.list.hidden")) + { throw new PlayerNotFoundException(); } if (target.isAuthorized("essentials.kick.exempt")) @@ -35,10 +37,13 @@ public class Commandkick extends EssentialsCommand throw new Exception(_("kickExempt")); } } - final String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault"); + + String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault"); + kickReason = kickReason.replace("\\n", "\n"); + target.kickPlayer(kickReason); final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; - + server.getLogger().log(Level.INFO, _("playerKicked", senderName, target.getName(), kickReason)); for (Player onlinePlayer : server.getOnlinePlayers()) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java index 4722b7d68..36b2c7e15 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java @@ -16,6 +16,9 @@ public class Commandkickall extends EssentialsCommand @Override public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { + String kickReason = args.length > 0 ? getFinalArg(args, 0) : _("kickDefault"); + kickReason = kickReason.replace("\\n", "\n"); + for (Player onlinePlayer : server.getOnlinePlayers()) { if (sender instanceof Player && onlinePlayer.getName().equalsIgnoreCase(((Player)sender).getName())) @@ -24,7 +27,7 @@ public class Commandkickall extends EssentialsCommand } else { - onlinePlayer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : _("kickDefault")); + onlinePlayer.kickPlayer(kickReason); } } sender.sendMessage(_("kickedAll")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java index fd959472c..cf706aa8b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java @@ -4,7 +4,6 @@ import com.earth2me.essentials.Console; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; -import java.util.Calendar; import java.util.GregorianCalendar; import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -47,7 +46,7 @@ public class Commandtempban extends EssentialsCommand final long banTimestamp = Util.parseDateDiff(time, true); final long maxBanLength = ess.getSettings().getMaxTempban() * 1000; - if(maxBanLength > 0 && ((banTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxBanLength) && !(ess.getUser(sender).isAuthorized("essentials.tempban.unlimited"))) + if (maxBanLength > 0 && ((banTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxBanLength) && !(ess.getUser(sender).isAuthorized("essentials.tempban.unlimited"))) { sender.sendMessage(_("oversizedTempban")); throw new NoChargeException(); |