Solved Item Giving

Discussion in 'Plugin Development' started by dlange, Jun 7, 2015.

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

    dlange

    I have a method to give the required items to a player.
    Code:
        public void giveItems(Player p) {
            p.getInventory().setItem(0, new ItemStack(Material.IRON_SWORD));
            p.getInventory().setItem(1, new ItemStack(Material.FLINT_AND_STEEL, 1, (byte) 63));
            p.getInventory().setItem(2, new ItemStack(Material.FISHING_ROD));
            p.getInventory().setItem(3, new ItemStack(Material.BOW));
            p.getInventory().setItem(4, new ItemStack(Material.GOLDEN_APPLE));
            p.getInventory().setItem(8, new ItemStack(Material.ARROW, 16));
            p.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET));
            p.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
            p.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
            p.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS));
            p.updateInventory();
            p.getInventory().setHeldItemSlot(0);
        }
    
    I do this:
    Code:
            giveItems(p2);
            giveItems(p1);
    to give the items to 2 players. But it only gives it to the first player. No error, nothing.
    The second player (p2) only get's the armor, the inventory stays the same.

    [SOLVED] I added a 1 tick delay, and it seemed to work.
     
    Last edited by a moderator: Jun 7, 2015
Thread Status:
Not open for further replies.

Share This Page