[CLOSED] Multiple Methods Help

Discussion in 'Programming' 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. If you use Java 8 use this.
    getPlayers().stream().forEach(lambda expression here)
  3. I'm still using Java 7 :/
  4. use a for loop.
    for(Player p : getplayers()) {
    p.sendMessage("hi") }
  5. or you can store the players in a array list as they login, then iterate through the list to send a message.
  6. So, I dont wanna use a loop like for(Player pp : Bukkit.getOnlinePlayers()) or Player p = (Player) Bukkit.getOnlinePlayers();
    I still wanna know how to create own multiple voids like 1.> System. 2.> out. 3.> println()
  7. In order to do that you need to understand classes and, methods.
    println() is a method of the out class, Which is initialized/referenced in the System class.

    In order to implement what you would want, You would have to overload the Server class of Bukkit with an alternate Broadcast method which would message all players online, rather then it's default purpose. Which would require you to edit the Spigot.jar everytime you updated. Even doing it like this, You have to perform a for loop an iterate over all online players.

    The best options are those previously mentioned. A for loop which iterates over a list of online players specifically in a plugin. Which wouldn't break everytime Spigot updated.
  8. You could create a new class that implements Collection<Player> then add the #sendMessage method to it and return it from your Chronic#getPlayers method.
  9. Never mind guys. I figured out how to do this:

    Code (Text):
    package net.melonia.Hauptpackage;

    public class MeloniaInitialize {

        public static final class getSystem{
            public static final class getInitializer{
                public static final void Initialize(){
                    System.out.println("[Melonia] Initializing Melonia System");

    Result: MeloniaInitialize.getSystem.getInitializer.Initialize();
    Thanks anyway for your help :)

    Thread closed

    And sorry for net.melonia.Hauptpackage; I'm German