mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-25 18:48:24 +01:00
Fix recipe NPE/failed display in game
This commit is contained in:
parent
b5dd0fc671
commit
5c9d3c6b1a
@ -97,11 +97,18 @@ public class Commandrecipe extends EssentialsCommand
|
|||||||
final User user = ess.getUser(sender);
|
final User user = ess.getUser(sender);
|
||||||
user.setRecipeSee(true);
|
user.setRecipeSee(true);
|
||||||
final InventoryView view = user.openWorkbench(null, true);
|
final InventoryView view = user.openWorkbench(null, true);
|
||||||
final String shapeMap = recipe.getShape().length == 2 ? " abecdfghi" : " abcdefghi";
|
for (int j = 0; j < recipe.getShape().length; j++)
|
||||||
for (Entry<Character, ItemStack> e : ((ShapedRecipe)recipe).getIngredientMap().entrySet())
|
{
|
||||||
{
|
for (int k = 0; k < recipe.getShape()[j].length(); k++)
|
||||||
e.getValue().setAmount(0);
|
{
|
||||||
view.setItem(shapeMap.indexOf(e.getKey()), e.getValue());
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user