Multiple Methods??

Discussion in 'Spigot Plugin Development' started by Apexectr, Jun 15, 2015.

  1. Hey. In recent times I was wondering how to do that which one for example can call several methods ...
    So what is meant is, for example, this: Chronic.getPlayers([return all players]).sendMessage("Text");.

    Can someone help me please? Prefer not to use Bukkit.getOnlinePlayers ().... Thanks :)
     
  2. konsolas

    Supporter

    You can't, create your own helper function if you really need to.

    Code (Text):
    private void sendToPlayers(Collection<Player> players, String message) {
    for(Player p : players)
    p.sendMessage(message);
    }
     
  3. You can use java 8:

    Code (Text):
    Bukkit.getOnlinePlayers().forEach(p -> p.sendMessage("Text"));
    Symantically the same as a for loop.
     
    #5 1Rogue, Jun 15, 2015
    Last edited: Jun 15, 2015
  4. bro do u even format? <3