Solved [1.7.9+] getOnlinePlayers() error

Discussion in 'Plugin Development' started by McMhz, Jul 20, 2014.

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

    McMhz

    I took a break from bukkit for like 3 months or more and when I come back getOnlinePlayers gives me an error.. and I'm pretty sure I'm just doing it the exact same way I did it last time..
    So yeah, was the method edited?..

    If anybody knows how to do this, I'd appreciate if you helped me out.
    Here is the code that has the error (at-least that's what the log tells me)
    Code:java
    1. for(Player p : getServer().getOnlinePlayers()){
    2. p.sendMessage("12345");
    3. }


    I can provide you with an error log if you want, but I don't think you need it, so tell me if you do.
     
  2. Offline

    Gater12

  3. Offline

    Garris0n

    You should always post the error.
     
  4. Offline

    Dragonphase

    McMhz

    Try Bukkit.getOnlinePlayers()
     
  5. Offline

    McMhz

    Garris0n Gater12
    Code:
    [19:37:37] [Server thread/INFO]: Starting minecraft server version 1.7.9
    [19:37:37] [Server thread/INFO]: Loading properties
    [19:37:37] [Server thread/INFO]: Default game type: SURVIVAL
    [19:37:37] [Server thread/INFO]: Generating keypair
    [19:37:37] [Server thread/INFO]: Starting Minecraft server on *:25565
    [19:37:38] [Server thread/INFO]: This server is running CraftBukkit version git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks (MC: 1.7.9) (Implementing API version 1.7.9-R0.2)
    [19:37:38] [Server thread/INFO]: [Report] Loading Report v1.0
    [19:37:38] [Server thread/INFO]: Preparing level "world"
    [19:37:38] [Server thread/INFO]: Preparing start region for level 0 (Seed: 1889092571241255969)
    [19:37:39] [Server thread/INFO]: Preparing spawn area: 52%
    [19:37:39] [Thread-7/INFO]: ----- Bukkit Auto Updater -----
    [19:37:39] [Thread-7/INFO]: It appears that you're running a Beta Build, when you've specified in bukkit.yml that you prefer to run Recommended Builds.
    [19:37:39] [Thread-7/INFO]: If you would like to be kept informed about new Beta Build releases, it is recommended that you change 'preferred-channel' in your bukkit.yml to 'beta'.
    [19:37:39] [Thread-7/INFO]: With that set, you will be told whenever a new version is available for download, so that you can always keep up to date and secure with the latest fixes.
    [19:37:39] [Thread-7/INFO]: If you would like to disable this warning, simply set 'suggest-channels' to false in bukkit.yml.
    [19:37:39] [Thread-7/INFO]: ----- ------------------- -----
    [19:37:40] [Server thread/INFO]: Preparing start region for level 1 (Seed: 1889092571241255969)
    [19:37:41] [Server thread/INFO]: Preparing spawn area: 79%
    [19:37:41] [Server thread/INFO]: Preparing start region for level 2 (Seed: 1889092571241255969)
    [19:37:42] [Server thread/INFO]: [Report] Enabling Report v1.0
    [19:37:42] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [19:37:42] [Server thread/INFO]: Done (3.528s)! For help, type "help" or "?"
    [19:37:51] [User Authenticator #1/INFO]: UUID of player teti100teti is e2b1ee44-9e0f-4373-9b1d-e9ea83137bf0
    [19:37:51] [Server thread/INFO]: teti100teti[/127.0.0.1:56354] logged in with entity id 373 at ([world] -158.06913618027187, 73.0, 281.2446725412197)
    [19:38:00] [Server thread/INFO]: teti100teti issued server command: /report teti100teti test
    [19:38:00] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'report' in plugin Report v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) ~[bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:701) ~[bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.PlayerConnection.handleCommand(PlayerConnection.java:956) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:817) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.PacketPlayInChat.a(PacketPlayInChat.java:28) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.PacketPlayInChat.handle(PacketPlayInChat.java:47) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:157) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    Caused by: java.lang.NoSuchMethodError: org.bukkit.Server.getOnlinePlayers()Ljava/util/Collection;
        at net.nexusnetwork.teti.Main.sendReport(Main.java:52) ~[?:?]
        at net.nexusnetwork.teti.Main.onCommand(Main.java:40) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        ... 13 more
    
    I'll try.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  6. Offline

    Gater12

    McMhz
    You're using a Bukkit API jar that contains the new getOnlinePlayers() method which returns a Collection of players instead of an array. But you craftbukkit jar is not up-to-date with the new getOnlinePlayers() method that returns a Collection hence the error of NoSuchMethod.
     
    McMhz and Garris0n like this.
  7. Offline

    Garris0n

    They do the same thing.

    @OP Make sure the version of CraftBukkit on your server is the same as the version of Bukkit you're building against. Or just update both to the latest version.
     
  8. Offline

    McMhz

    Dragonphase It didn't change anything, but thanks anyway.
    Also, It's definitely an error with the getOnlinePlayers()

    Yeah, This was what I was looking for, I already saw that it returned a collection and I didn't know what to do.
    Thanks.

    Okay, I updated it and it works.
    Thanks to Gater12 Garris0n, and Dragonphase

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page