Get ItemMeta from an egg

Discussion in 'Plugin Development' started by CuzImInside, Feb 4, 2017.

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

    CuzImInside

    Hey guys,

    I want to make a plugin where an explosion occurs when a certain egg touches the ground. At first I gave the egg by ItemMeta the DisplayName "surprise". Now I want to ask, if the thrown egg has this DisplayName. How can I do that?
     
  2. Offline

    Zombie_Striker

    @CuzImInside
    You will have to listen for two events: ProjectileHitEvent and PlayerInteractEvent.
    • For PlayerInteractEvent, check if the player is throwing a certain egg. If so, cancel the event, remove 1 egg, and use Player#spawnProjectile(Egg.class) to throw an egg. Store that egg instance somewhere. After you call that method, get the egg and set its displayname to be equal to Surprise.
    • For projectile hit event. If the egg thrown has that displayname, create an explosion.
     
  3. Offline

    CuzImInside

    @Zombie_Striker

    But with witch command can i test, if it the thrown egg has my displayname?
     
  4. Offline

    Zombie_Striker

    @CuzImInside
    If you're making a plugin, you do not need to use commands. Just use
    Code:
    if(e.getDisplayName().equalsIgnoreCase("THE NAME"))
     
  5. Offline

    S1ant

    @CuzImInside If you request has been Filled then mark this thread as 'Solved'!
     
Thread Status:
Not open for further replies.

Share This Page