diff options
author | Chris Ward <chris@chrisgward.com> | 2013-01-01 02:26:04 +1100 |
---|---|---|
committer | Chris Ward <chris@chrisgward.com> | 2013-01-01 02:26:04 +1100 |
commit | 5c9d3c6b1aa8b19ec5223226ea1859509483b3c0 (patch) | |
tree | 14f7878e34c2d5e95188ac24fc7d472af419baaf | |
parent | b5dd0fc67127b7f7011cc30c5b37312879a2021a (diff) | |
download | Essentials-5c9d3c6b1aa8b19ec5223226ea1859509483b3c0.tar Essentials-5c9d3c6b1aa8b19ec5223226ea1859509483b3c0.tar.gz Essentials-5c9d3c6b1aa8b19ec5223226ea1859509483b3c0.tar.lz Essentials-5c9d3c6b1aa8b19ec5223226ea1859509483b3c0.tar.xz Essentials-5c9d3c6b1aa8b19ec5223226ea1859509483b3c0.zip |
Fix recipe NPE/failed display in game
-rwxr-xr-x | Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java b/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java index e5c69a88b..4325f13d8 100755 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java @@ -97,11 +97,18 @@ public class Commandrecipe extends EssentialsCommand final User user = ess.getUser(sender);
user.setRecipeSee(true);
final InventoryView view = user.openWorkbench(null, true);
- final String shapeMap = recipe.getShape().length == 2 ? " abecdfghi" : " abcdefghi";
- for (Entry<Character, ItemStack> e : ((ShapedRecipe)recipe).getIngredientMap().entrySet())
- {
- e.getValue().setAmount(0);
- view.setItem(shapeMap.indexOf(e.getKey()), e.getValue());
+ for (int j = 0; j < recipe.getShape().length; j++)
+ {
+ for (int k = 0; k < recipe.getShape()[j].length(); k++)
+ {
+ ItemStack item = recipe.getIngredientMap().get(recipe.getShape()[j].toCharArray()[k]);
+ if(item == null)
+ {
+ continue;
+ }
+ item.setAmount(0);
+ view.getTopInventory().setItem(j * 3 + k + 1, item);
+ }
}
}
|