Fix NPE in /repair

This commit is contained in:
snowleo 2011-10-08 19:41:41 +02:00
parent 06900e19f0
commit 313df9988d

View File

@ -30,6 +30,10 @@ public class Commandrepair extends EssentialsCommand
if (args[0].equalsIgnoreCase("hand")) if (args[0].equalsIgnoreCase("hand"))
{ {
final ItemStack item = user.getItemInHand(); final ItemStack item = user.getItemInHand();
if (item == null)
{
throw new Exception(Util.i18n("repairInvalidType"));
}
final String itemName = item.getType().toString().toLowerCase(); final String itemName = item.getType().toString().toLowerCase();
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess); final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
@ -84,6 +88,10 @@ public class Commandrepair extends EssentialsCommand
{ {
for (ItemStack item : items) for (ItemStack item : items)
{ {
if (item == null)
{
continue;
}
final String itemName = item.getType().toString().toLowerCase(); final String itemName = item.getType().toString().toLowerCase();
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess); final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
try try