Solved getOnlinePlayers Error

Discussion in 'Plugin Development' started by Skrubzy, Nov 21, 2015.

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

    Skrubzy

    Hey, I'm attempting to make a healing plugin but whenever I type in this code:
    for (Player playerToHeal : Bukkit.getServer().getOnlinePlayers()) {
    It crosses out the ".getOnlinePlayers" part, it says "The method getOnlinePlayers() from the type Server is deprecated" which I don't know how to fix because I'm fairly new to coding. Here's my code:
    Code:
    boolean playerFound = false;
                   
                    for (Player playerToHeal : Bukkit.getServer().getOnlinePlayers()) {
                        if(playerToHeal.getName().equalsIgnoreCase(args[0])) {
                            playerToHeal.setHealth(20.0);
                            playerToHeal.sendMessage(ChatColor.GREEN + "You have been healed be " + player.getName() + "!");
                            player.sendMessage(ChatColor.GREEN + playerToHeal.getName() + " was healed succeessfully");
                            playerFound = true;
                            break;
                        }
                    }
    https://gyazo.com/846de069c00a4b6e3708a2fae37a9375
     
  2. Offline

    mcdorli

    it is deprecated, if you don't know what it is, then learn a bit more java. It means, that it will probably be removed in the future.
     
  3. Offline

    Skrubzy

    Is there any way to fix this? Should I try updating my external Jar build path file?
     
  4. Offline

    mcdorli

    *facepalm* No, you can use this, there is no problem with that, but be aware, that it can be removed in 1 of the future spigot updates (because bukkit is apparently not in developement). And still, learn java
     
  5. Offline

    Skrubzy

    Oh ok thank you, and sorry I'm very new to coding xD
     
  6. Offline

    mcdorli

    Then learn java, and don't do bukkit before that. It is essential for it.
     
Thread Status:
Not open for further replies.

Share This Page