From 8aab57e86b3c3fa2b890273893e63e6c840f2b5d Mon Sep 17 00:00:00 2001 From: KHobbits Date: Fri, 10 Aug 2012 02:26:23 +0100 Subject: [PATCH] Fix yaml issue with /kit --- Essentials/src/com/earth2me/essentials/Kit.java | 1 + .../com/earth2me/essentials/commands/Commandkit.java | 11 ++++++++--- .../src/com/earth2me/essentials/signs/SignKit.java | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Kit.java b/Essentials/src/com/earth2me/essentials/Kit.java index 5a907beb3..136c1d6f5 100644 --- a/Essentials/src/com/earth2me/essentials/Kit.java +++ b/Essentials/src/com/earth2me/essentials/Kit.java @@ -78,6 +78,7 @@ public class Kit { throw new Exception(_("kitError2")); } + try { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java index baa8ba014..fe2f49292 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java @@ -26,12 +26,12 @@ public class Commandkit extends EssentialsCommand else if (args.length > 1 && user.isAuthorized("essentials.kit.others")) { final User userTo = getPlayer(server, args, 1, true); - final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)); + final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim(); giveKit(userTo, user, kitName); } else { - final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)); + final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim(); giveKit(user, user, kitName); } } @@ -59,7 +59,12 @@ public class Commandkit extends EssentialsCommand } private void giveKit(User userTo, User userFrom, String kitName) throws Exception - { + { + if (kitName.isEmpty()) + { + throw new Exception(_("kitError2")); + } + final Map kit = ess.getSettings().getKit(kitName); if (!userFrom.isAuthorized("essentials.kit." + kitName)) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignKit.java b/Essentials/src/com/earth2me/essentials/signs/SignKit.java index 148854010..aee1d7dea 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignKit.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignKit.java @@ -19,7 +19,7 @@ public class SignKit extends EssentialsSign { validateTrade(sign, 3, ess); - final String kitName = sign.getLine(1).toLowerCase(Locale.ENGLISH); + final String kitName = sign.getLine(1).toLowerCase(Locale.ENGLISH).trim(); if (kitName.isEmpty()) { @@ -48,7 +48,7 @@ public class SignKit extends EssentialsSign @Override protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException { - final String kitName = sign.getLine(1).toLowerCase(Locale.ENGLISH); + final String kitName = sign.getLine(1).toLowerCase(Locale.ENGLISH).trim(); final String group = sign.getLine(2); if ((!group.isEmpty() && ("ยง2Everyone".equals(group) || player.inGroup(group))) || (group.isEmpty() && (player.isAuthorized("essentials.kit." + kitName))))