How to use Item Metadata

Discussion in 'Plugin Development' started by ibWill, Jun 30, 2013.

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

    ibWill

    Hello, i'm new to plugin coding and i'm trying to make a plugin that makes a player explode when they eat a certain item. I just cant figure out how to make a custom item and have the plugin react to that specific item. I want to be able to customize this item with metadata, but as i said before, i have no clue. Thanks in advanced for explaining this to me.
     
  2. Offline

    CubixCoders

    Check when they eat the food, then use

    Code:java
    1.  
    2. if(item.hasMetaData()){
    3. if(item.getMetaData().getDisplayName().equalsIgnoreCase("Test")){
    4. //The item is named Test
    5. }
    6. }
    7.  
     
  3. Offline

    ibWill

    how would i check to see if they eat food? is there a function specifically for that?
     
  4. Offline

    MP5K

  5. Offline

    Omega Haxors

    Either use PlayerInteractEvent (if action = right click) or if you're smart/lazy just use the PlayerConsumeEvent. The PlayerInteractEvent will stop you from STARTING to eat while the consume event will fire just AFTER the food is eaten.
     
  6. Offline

    ibWill

    One last question, how do I set meta data?
     
  7. Offline

    ibWill

    CubixCoders, How would I make a timer in my Listener class?
     
  8. Offline

    CakePvP

    Wait.. Isn't there 'PlayerItemConsumeEvent'
     
  9. Offline

    ibWill

    Not that i know of
     
Thread Status:
Not open for further replies.

Share This Page