diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-04-04 03:09:27 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-04-04 03:09:27 +0100 |
commit | e7a35a8e1f8086925d2b66fd2767e8e11e70443c (patch) | |
tree | fe2b82d199803979f5418d54f95a7eec8ec1e56d | |
parent | bc9c6d8f40ec64d464fe36384b62add8177ffb23 (diff) | |
download | Essentials-e7a35a8e1f8086925d2b66fd2767e8e11e70443c.tar Essentials-e7a35a8e1f8086925d2b66fd2767e8e11e70443c.tar.gz Essentials-e7a35a8e1f8086925d2b66fd2767e8e11e70443c.tar.lz Essentials-e7a35a8e1f8086925d2b66fd2767e8e11e70443c.tar.xz Essentials-e7a35a8e1f8086925d2b66fd2767e8e11e70443c.zip |
Report invalid enchantments in kits.
Improve error logging
9 files changed, 40 insertions, 19 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Kit.java b/Essentials/src/com/earth2me/essentials/Kit.java index 36a2e60b0..b6363b183 100644 --- a/Essentials/src/com/earth2me/essentials/Kit.java +++ b/Essentials/src/com/earth2me/essentials/Kit.java @@ -5,6 +5,7 @@ import static com.earth2me.essentials.I18n.capitalCase; import com.earth2me.essentials.commands.NoChargeException; import com.earth2me.essentials.craftbukkit.InventoryWorkaround; import java.util.*; +import java.util.logging.Level; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.enchantments.Enchantment; @@ -31,7 +32,7 @@ public class Kit } catch (Exception ex) { - throw new Exception(_("kitError")); + throw new Exception(_("kitError"), ex); } } @@ -76,7 +77,7 @@ public class Kit catch (Exception e) { user.sendMessage(_("kitError2")); - throw new Exception(_("kitErrorHelp")); + throw new Exception(_("kitErrorHelp"),e); } } @@ -104,6 +105,10 @@ public class Kit continue; } final Enchantment enchantment = Enchantments.getByName(split[0]); + if (enchantment == null) + { + throw new Exception("Enchantment not found: " + split[0]); + } int level; if (split.length > 1) { @@ -113,7 +118,14 @@ public class Kit { level = enchantment.getMaxLevel(); } - stack.addEnchantment(enchantment, level); + try + { + stack.addEnchantment(enchantment, level); + } + catch (Exception ex) + { + throw new Exception("Enchantment " + enchantment.getName() + ": " + ex.getMessage(), ex); + } } } @@ -141,7 +153,15 @@ public class Kit catch (Exception e) { user.updateInventory(); - throw new Exception(_("kitError2")); + if (ess.getSettings().isDebug()) + { + ess.getLogger().log(Level.WARNING, e.getMessage()); + } + else + { + ess.getLogger().log(Level.WARNING, e.getMessage()); + } + throw new Exception(_("kitError2"), e); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java b/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java index c0b47d20f..a455ccc20 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java @@ -61,7 +61,7 @@ public class Commandkillall extends EssentialsCommand } catch (NumberFormatException e) { - throw new Exception(_("numberRequired")); + throw new Exception(_("numberRequired"), e); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java index b16cbdc34..738b8db1a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java @@ -79,7 +79,7 @@ public class Commandptime extends EssentialsCommand } catch (NumberFormatException e) { - throw new NotEnoughArgumentsException(); + throw new NotEnoughArgumentsException(e); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java index d245d1239..912434f08 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java @@ -47,7 +47,7 @@ public class Commandremove extends EssentialsCommand } catch (NumberFormatException e) { - throw new Exception(_("numberRequired")); + throw new Exception(_("numberRequired"), e); } } @@ -57,7 +57,7 @@ public class Commandremove extends EssentialsCommand } catch (IllegalArgumentException e) { - throw new NotEnoughArgumentsException(); //TODO: translate and list types + throw new NotEnoughArgumentsException(e); //TODO: translate and list types } removeEntities(user, world, toRemove, radius); @@ -84,7 +84,7 @@ public class Commandremove extends EssentialsCommand } catch (IllegalArgumentException e) { - throw new NotEnoughArgumentsException(); //TODO: translate and list types + throw new NotEnoughArgumentsException(e); //TODO: translate and list types } removeEntities(sender, world, toRemove, 0); } @@ -92,8 +92,9 @@ public class Commandremove extends EssentialsCommand protected void removeEntities(final CommandSender sender, final World world, final ToRemove toRemove, int radius) throws Exception { int removed = 0; - if (radius > 0) { - radius*=radius; + if (radius > 0) + { + radius *= radius; } for (Chunk chunk : world.getLoadedChunks()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index fdaa0eb9e..2546a76dd 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -103,7 +103,7 @@ public class Commandspawnmob extends EssentialsCommand } catch (MobException e) { - throw new Exception(_("unableToSpawnMob")); + throw new Exception(_("unableToSpawnMob"), e); } if (mountType != null) @@ -129,7 +129,7 @@ public class Commandspawnmob extends EssentialsCommand } catch (MobException e) { - throw new Exception(_("unableToSpawnMob")); + throw new Exception(_("unableToSpawnMob"), e); } spawnedMob.setPassenger(spawnedMount); } @@ -164,7 +164,7 @@ public class Commandspawnmob extends EssentialsCommand } catch (MobException e) { - throw new Exception(_("unableToSpawnMob")); + throw new Exception(_("unableToSpawnMob"), e); } spawnedMob.setPassenger(spawnedMount); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java index c49f34fbd..f22d7d01f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java @@ -49,7 +49,7 @@ public class Commandtime extends EssentialsCommand } catch (NumberFormatException e) { - throw new NotEnoughArgumentsException(); + throw new NotEnoughArgumentsException(e); } setWorldsTime(sender, worlds, ticks); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java index 8bc3ad068..dda1475d0 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java @@ -29,7 +29,7 @@ public class Commandunban extends EssentialsCommand } catch (NoSuchFieldException e) { - throw new Exception(_("playerNotFound")); + throw new Exception(_("playerNotFound"), e); } } } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignEnchant.java b/Essentials/src/com/earth2me/essentials/signs/SignEnchant.java index 5907442d9..a50ce967a 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignEnchant.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignEnchant.java @@ -41,7 +41,7 @@ public class SignEnchant extends EssentialsSign } catch (NumberFormatException ex) { - throw new SignException(ex.getMessage()); + throw new SignException(ex.getMessage(), ex); } if (level < 1 || level > enchantment.getMaxLevel()) { @@ -57,7 +57,7 @@ public class SignEnchant extends EssentialsSign } catch (Throwable ex) { - throw new SignException(ex.getMessage()); + throw new SignException(ex.getMessage(), ex); } getTrade(sign, 3, ess); return true; diff --git a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java index 6ea4f5e80..41f9fb2a5 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java @@ -224,7 +224,7 @@ public class SignTrade extends EssentialsSign } catch (SignException e) { - throw new SignException(_("tradeSignEmpty")); + throw new SignException(_("tradeSignEmpty"), e); } } |