Solved Recipe Troubles

Discussion in 'Plugin Development' started by Onlineids, Jun 1, 2014.

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

    Onlineids

    Why doesn't this work o.0
    When I try to craft the item nothing comes up
    Code:java
    1. package me.online.GoldenHeads;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Material;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.inventory.ItemStack;
    10. import org.bukkit.inventory.ShapedRecipe;
    11. import org.bukkit.inventory.meta.ItemMeta;
    12. import org.bukkit.plugin.java.JavaPlugin;
    13.  
    14. public class Main extends JavaPlugin implements Listener{
    15. public ItemStack goldenHead = createItem(Material.GOLDEN_APPLE, 1, ChatColor.AQUA + "Golden Head", ChatColor.GOLD + "New And Improved Golden Apple!");
    16. public void onEnable() {
    17. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    18. goldenHead.setDurability((short) 1);
    19. addRecipe();
    20.  
    21. }
    22. @SuppressWarnings("deprecation")
    23. public void addRecipe()
    24. {
    25. ShapedRecipe recipe = new ShapedRecipe(goldenHead);
    26. recipe.shape(new String[] { "AAA", "ABA", "AAA" });
    27. recipe.setIngredient('A', Material.GOLD_INGOT).setIngredient('B', Material.SKULL_ITEM, 3);
    28. Bukkit.addRecipe(recipe);
    29. }
    30.  
    31. public static ItemStack createItem(Material material, int amount,String name, String lore) {
    32. ItemStack item = new ItemStack(material, amount);
    33. ItemMeta meta = item.getItemMeta();
    34. ArrayList<String> Lore = new ArrayList<String>();
    35. Lore.add(lore);
    36. meta.setLore(Lore);
    37. meta.setDisplayName(name);
    38. item.setItemMeta(meta);
    39. return item;
    40. }
    41.  
    42. }
    43.  
     
  2. Offline

    br456

    Onlineids
    What is the problem, you need to specify what is wrong or what the error is
     
  3. Offline

    Onlineids

    br456
     
  4. Offline

    NathanWolf

    Where do you actually call your addRecipe method?
     
  5. Offline

    Onlineids

    Code:java
    1. public void onEnable() {
    2. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    3. goldenHead.setDurability((short) 1);
    4. addRecipe();
    5.  
    6. }
     
  6. Offline

    NathanWolf

    Oh, derp, missed it, sorry.

    And unfortunately I don't see anything wrong, either :(
     
  7. Offline

    Onlineids

    NathanWolf Im dumb ignore me -_- exported plugin to wrong place it works perfectly xD
     
    NathanWolf likes this.
Thread Status:
Not open for further replies.

Share This Page