I am trying to create a Stable plugin that will store horses in spawn eggs. Players who possess the eggs will be able to spawn that specified horse. The problem I am having is that I do not know how to retrieve the Lore from the held Horse Egg. Does anyone know how I can do this? Any help is appreciated!
player interact event check if item isn't null, and item has lore read and diagnose lore run certain code based on diagnosis
Here's a few links to the Java docs that may be of use: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/ItemStack.html#getItemMeta() https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/meta/ItemMeta.html#getLore()
Thank you guys So you think I should go the route of listening for PlayerInteractEvent instead of CreatureSpawnEvent to get the ItemStack (then cancel the Spawn event)?
CreatureSpawnEvent is for detecting when a creature spawns. you will need a interact event to detect a right click and get the item in the hand of the player.If the hand contains the horse,then add what you like.