Solved Item's lore in PrepareItemCraftEvent

Discussion in 'Spigot Plugin Development' started by piratjsk, May 18, 2016.

Thread Status:
Not open for further replies.
  1. Spigot version: git-Spigot-4af49dc-4e19de1 (MC: 1.9.4)

    I put in crafting a saddle like this
    but in PrepareItemCraftEvent it doesn't have the lore.

    My code:
    Code (Java):
    public class Horses extends JavaPlugin implements Listener {

        public void onEnable() {
            getServer().getPluginManager().registerEvents(this, this);
            ShapelessRecipe recipe = new ShapelessRecipe(new ItemStack(Material.SADDLE));

        public void onSaddleSign(PrepareItemCraftEvent event) {
            final Player player = (Player) event.getView().getPlayer();
            if (event.getInventory().contains(Material.SADDLE)) {
                ItemStack saddle = event.getInventory().getContents()[0];
                player.sendMessage("hasLore: " + saddle.getItemMeta().hasLore() );
                player.sendMessage("lore!=null: " + ( saddle.getItemMeta().getLore() != null ) );

  2. My guess is that
    Code (Text):
    ItemStack saddle = event.getInventory().getContents()[0];
    is returning the item in the result slot. Try printing out all of the contents to see which slots contain the ingredients and go from there.
    • Like Like x 1
  3. Yes, that was it. Thanks.
Thread Status:
Not open for further replies.