Permalink
Browse files

Removed debug line from /enchant and fixed NPE bug

  • Loading branch information...
1 parent be87d9b commit aa0b60ac23ca3aef6a6b4f9e50c57cd4236498c3 @GuntherDW committed Nov 26, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/com/guntherdw/bukkit/tweakcraft/Commands/General/CommandEnchant.java
@@ -87,9 +87,12 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
if(enchantment!=null) {
ItemStack is = ((Player)sender).getItemInHand();
- is.clearEnchantments();
- is.addEnchantment(enchantment, enchantmentLevel);
- sender.sendMessage(ChatColor.YELLOW+"Adding "+enchantment.name()+" level "+enchantmentLevel);
+ if(is==null) {
+ sender.sendMessage(ChatColor.YELLOW+"You're not holding anything");
+ } else {
+ is.addEnchantment(enchantment, enchantmentLevel);
+ sender.sendMessage(ChatColor.YELLOW+"Adding "+enchantment.name()+" level "+enchantmentLevel);
+ }
} else {
sender.sendMessage(ChatColor.YELLOW+"Couldn't find Enchantment with id "+enchantmentId+"!");
}

0 comments on commit aa0b60a

Please sign in to comment.