Problem with custom item

Discussion in 'Plugin Development' started by PluginMan100, May 23, 2014.

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

    PluginMan100

    Hello. I want to make smaller my code, and I made this function:
    Code:java
    1. public ItemStack customItem(String name, String lore, Material type) {
    2. ItemStack temper = new ItemStack(type);
    3. ItemMeta temper_m = temper.getItemMeta();
    4. temper_m.setDisplayName(name);
    5. if (!(lore == null)) {
    6. tlore.clear();
    7. tlore.add(lore);
    8. temper_m.setLore(tlore);
    9. }
    10. temper.setItemMeta(temper_m);
    11. return temper;
    12. }


    But it doesn't works. No errors on loading server, but in shaped/shapeless recipe it won't works. What's wrong?
     
  2. Offline

    Chlorek

    If I understood well you mean than received ItemStack does not work in recipe crafting?
    Show us more code. I mean your recipe adding code.
    By the way, instead of
    Code:
    !(lore == null)
    you can simply write
    Code:
    lore != null && !lore.isEmpty()
    .
     
  3. Offline

    PluginMan100

    Here you are:
    Code:java
    1. public void steelRecipe() {
    2. ItemStack steel = customItem(ChatColor.AQUA+"Steel Ingot",null,Material.IRON_INGOT);
    3. ShapelessRecipe steelrecipe = new ShapelessRecipe(steel).addIngridient(Material.IRON_INGOT);
    4. getServer().addRecipe(steelrecipe);
    5. }
     
Thread Status:
Not open for further replies.

Share This Page