Solved Giving items to all players on one server?

Discussion in 'Plugin Development' started by ThePandaPlayer, Aug 4, 2017.

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

    ThePandaPlayer

    OMG! I'm such a Bukkit newb! (This is my 3rd help thread in like 3 days) I need some help again. I am trying to give 64 of any item specified to all players on the server. So, I tried using the getOnlinePlayers() method on a player object. Eclipse said it was only for use with a Collection object. So, I need to know how to address the players once I get all of the player data. Here is the code:
    Code:
    Collection players = Bukkit.getOnlinePlayers();
    How would I address the players using this method?
     
  2. Offline

    Reflxction

    Use a for-loop and loop through all the online players, after this, all the players can be treated like a single player.
    For example:

    Code:
    for(Player p : Bukkit.getOnlinePlayers()) {
        p.sendMessage("Hello");
    }
    This would send all the online players "Hello". Instead of the sendMessage method, just put whatever action you want.
     
  3. Offline

    ThePandaPlayer

    Oh, okay nice. Thank you for your help!
     
Thread Status:
Not open for further replies.

Share This Page