Solved Custom Items

Discussion in 'Plugin Development' started by Onlineids, Feb 12, 2014.

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

    Onlineids

    So I am making a custom recipes plugin where you surround a god apple in golden blocks to get a god apple plus. Making the recipe is easy as well as name/lore however there are two things I wish to do that I have no idea how to. Add a potion effect to the item, I want to add a upgraded regen to the god apple plus. Give it an ID, I don't know if this is possible but could I give my new item a custom ID or give it an existing one? I want to do this so I can /give players said item. Please Help!
     
  2. Offline

    Malatak1

    Onlineids Nope, IDs aren't changeable (without external modifications). You could just set the display name of the item, and set up a Listener for a PlayerItemConsumeEvent, check the display name of the item in hand and then execute code based on that.
     
  3. Offline

    Onlineids

    Alright yea that could work, but how would I give players said item?
     
  4. Offline

    xTrollxDudex

    Onlineids
    Get player inventory and add item.
     
  5. Offline

    Malatak1

    Add a command for it that accepts an argument for a player, then create a new ItemStack with the ItemMeta you want on it (custom display name, lore, etc.) and then put in target player's inventory.
     
  6. Offline

    Onlineids

    Alright im not that advanced at coding how would you go about doing this?
     
  7. Offline

    xTrollxDudex

    If you don't know how to do something, go look at the API spec.
     
  8. Offline

    Onlineids

    Link?
     
  9. Offline

    xTrollxDudex

  10. Offline

    Onlineids

  11. Offline

    Malatak1

    You can look here for commands. As of display names:

    Code:java
    1. ItemStack item = new ItemStack(Material.GOLDEN_APPLE);
    2. ItemMeta meta = item.getItemMeta();
    3. meta.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "GOD APPLE");
    4. item.setItemMeta(meta);
    5. p.getInventory().addItem(item);
     
Thread Status:
Not open for further replies.

Share This Page