Get a crafted items display name

Discussion in 'Plugin Development' started by BrushPainter, Mar 12, 2014.

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

    BrushPainter

    Hey everyone, I've been searching the API and Google but I can't find anything about getting the display name of a crafted item. So far I have this:
    Code:java
    1. @EventHandler
    2. public void onStaffCraft(CraftItemEvent e) {
    3.  
    4. ItemStack c = ??????
    5. ItemMeta im = c.getItemMeta();
    6.  
    7. if (im.getDisplayName().equalsIgnoreCase("Staff")) {
    8.  
    9. }
    10. }


    But how can I get the crafted item?
     
  2. Offline

    Wolfey

    Code:java
    1. e.getCurrentItem()
     
  3. Offline

    BrushPainter

    Wolfey -.- Sorry for even asking that, going to kill myself now. Lmao....

    Wolfey Do you know how I would get the player who crafted the item? I've tried:
    Code:java
    1. Player crafter = e.getWhoClicked();

    But it doesn't work, it's the only thing I could find about getting who the crafter was.
    Will this work:
    Code:java
    1. HumanEntity crafter = e.getWhoClicked();


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    Wolfey

    Code:java
    1. Player crafter = (Player) e.getWhoClicked();

    Just to be safe, check if the getWhoClicked() is an instanceof Player. I don't really know if this will matter, but its always good to check.
     
    BrushPainter likes this.
  5. Offline

    BrushPainter

    Wolfey Alright thanks man, will do. :)
     
  6. Offline

    Garris0n

    BrushPainter likes this.
Thread Status:
Not open for further replies.

Share This Page