Item not appearing?

Discussion in 'Plugin Development' started by GEETAFF, Aug 3, 2014.

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

    GEETAFF

    I'm so confused. When I add this item to a player's inventory, it adds it but its invisable until you relog. Can anyone help me with this?

    Code:
    package me.geetaff.CrafterCraft;
     
    import org.bukkit.Material;
    import org.bukkit.block.Sign;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.block.SignChangeEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
     
    public class SignListeners implements Listener
    {
        //Wizard
        @EventHandler
        public void classSign(SignChangeEvent e)
        {
            if(e.getLine(0).equalsIgnoreCase("[class]"))
            {
                if(e.getLine(1).equalsIgnoreCase("wizard"))
                {
                    e.setLine(0, "§4[Class]");
                    e.setLine(1, "§cWizard");
                }
            }
        }
        @SuppressWarnings("deprecation")
        @EventHandler
        public void onClickWizard(PlayerInteractEvent e)
        {
            Player p = e.getPlayer();
     
            if(e.getAction() == Action.RIGHT_CLICK_BLOCK)
            {
                if(e.getClickedBlock().getState() instanceof Sign)
                {
                    Sign s = (Sign) e.getClickedBlock().getState();
                    if(s.getLine(0).equalsIgnoreCase("§4[Class]"))
                    {
                        if(s.getLine(1).equalsIgnoreCase("§cWizard"))
                        {
                            ItemStack bob = new ItemStack(Material.BLAZE_ROD, 1);
                            p.getInventory().addItem(bob);
                            p.updateInventory();
                        }
                    }
                }
            }
        }
    }
     
  2. Offline

    michael566

    GEETAFF hmm maybe try remove the p.updateinventory?
     
  3. Offline

    GEETAFF

    michael566 I already tried, same problem. I also found out it only updates if your hand is on the same slot as the slot that the item is getting added too
     
Thread Status:
Not open for further replies.

Share This Page