PrepareItemCraftEvent Help?

Discussion in 'Plugin Development' started by Solaba, Aug 5, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Solaba

    In my main class I have:

    Code:java
    1. ShapedRecipe chainboot = new ShapedRecipe (new ItemStack(Material.CHAINMAIL_BOOTS, 1));
    2. chainboot.shape(" ","L L","L L");
    3.  
    4. server.addRecipe(chainboot);
    5.  


    Then in my Listener, I have:
    Code:java
    1. @EventHandler
    2. public void onPlayerCraftPrepare(PrepareItemCraftEvent e){
    3.  
    4.  
    5. ShapedRecipe chainboot = new ShapedRecipe (new ItemStack(Material.CHAINMAIL_BOOTS, 1));
    6. chainboot.shape(" ","L L","L L");
    7. Player p = (Player) e.getView().getPlayer();
    8. boolean equal = RecipeUtil.areEqual(e.getRecipe(), chainboot);
    9. ItemStack chainboots = new ItemStack(Material.CHAINMAIL_BOOTS);
    10. ItemStack chain = new ItemStack(Material.IRON_FENCE);
    11. ItemMeta chainmeta = chain.getItemMeta();
    12. chain.setItemMeta(chainmeta);
    13. chainmeta.setDisplayName(ChatColor.GRAY + "Chain Link");
    14. List<String> chainlore = new ArrayList<String>();
    15. chainlore.add(ChatColor.ITALIC + "Used for Chainmail.");
    16. chainmeta.setLore(chainlore);
    17. chain.setItemMeta(chainmeta);
    18. {
    19. if(e.getInventory().contains(chain)){
    20. if(chain.hasItemMeta()){
    21. if(chainmeta.getDisplayName().contains("Chain Link")){
    22. e.getInventory().addItem(chainboots);
    23.  
    24. }else{
    25. e.getInventory().setResult(null);
    26. }
    27. }else{
    28. e.getInventory().setResult(null);
    29.  
    30. }
    31.  
    32. }
    33. }
    34. }
    35. }


    The problem is, there is no errors but whenever I just open up the crafting bench, nothing in it, there is already chainmail boots in there. I believe this is because of the ShapedRecipe having no ingredients, but I have to add the recipe, so how do I add the 'Chain Link' name to the ingredients from here?
     
Thread Status:
Not open for further replies.

Share This Page