Give items to players in list

Discussion in 'Plugin Development' started by Huyka, Mar 1, 2018.

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

    Huyka

    Hello guys,
    I create a list or I store players. When I want to give an item to the players in the list it gives the item to 1 player in the list and not to all the players in the list
    Thank you for your help and sorry I'm french
    Here is my code:

    Code:
    private void give(ItemStack item) {
            this.players.stream().forEach(player -> {
                player.getInventory().addItem(item);
            });
        }
     
  2. Offline

    MattTheBeast

    Hi, Huyka have you checked your list to see if the players where added?
     
  3. Offline

    Plochem

    Code:
    for(Player p : nameOfTheList){
    
    p.getInventory.addItem(item);
    
    }
     
Thread Status:
Not open for further replies.

Share This Page