getOnlinePlayers() Won't work!

Discussion in 'Plugin Development' started by SpiyCrap, Jun 29, 2014.

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

    SpiyCrap

    Hi, I want my plugin to broadcast jukebox music to all players. I've been trying to loop on all the players, but it doesn't seem to work, I wrote the code:

    Code:java
    1. for(Player players : Bukkit.getOnlinePlayers())
    2. {
    3. players.playSound(players.getLocation(),Sound.GHAST_SCREAM2, 500, 1);
    4. }


    but from what I've checked it doesn't enter the for, and I get this error when it happens:
    [Server] INFO Caused by: java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
    :(
     
  2. Offline

    mactown21

    SpiyCrap Bukkit.getServer().getOnlinePlayers()
     
  3. Offline

    xize

    SpiyCrap
    thats really strange for me it should work whilst I know that method is changed from Player[] to Collection in the latest version only .length should now be called .size(), are you sure the error is from that plugin?, and you don't have any npc like plugins running at that moment just in case that may modifies the CraftServer's dedicated player list?
     
  4. Offline

    SpiyCrap

    mactown21
    already tried it, not difference.
    RenegadeEagle
    The thing is, I cant even call for getonlineplayers, I tried to move it into a collection, but it seems like it fails to call for it and everything that happens is a crash.
    xize
    well, by the error it clearly says that "there is no such Method" - [Server] INFO Caused by: java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
    the only plugin the server is running is mine. also it says:
    29.06 16:19:44 [Server] INFO org.bukkit.event.EventException
    29.06 16:19:44 [Server] ERROR Could not pass event PlayerMoveEvent to SpookCraft v1.0
    29.06 16:19:44 [Server] INFO ... 13 more
    29.06 16:19:44 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]

    (the getonlineplayers is triggered by playermoveevent - I know I shouldn't have done it like that, its just an experiment).

    @mactown21
    @RenegadeEagle
    @xize
    please help, I haven't found anyone with similar error to mine and I really need to use it for my plugin, maybe I'm using the wrong javadoc or bukkit verison? everything else in the plugins works just fine...

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

    Garris0n

    Update the server.
     
    teej107 and xTigerRebornx like this.
  6. Offline

    mactown21

    SpiyCrap Theres nothing wrong with getting all players on player movement but i think it may cause the server to spam that event and maybe prevent lag? im not for sure and try updating your server like Garris0n said. It should help a little bit.
    and im not for sure you supposed to use java/util/collections ? Kindof curios. but i have no clue
     
  7. Offline

    SpiyCrap

    I feel kind of stupid now, that was the fix. The host was running on R2 build [sheep]
     
  8. mactown21 1. Bukkit.getOnlinePlayers() and Bukkit.getServer().getOnlinePlayers() is basically the same thing.
    2. Getting all players on all movement could easily be wrong - the event gets fired a lot and most of the time people use it needlessly, thus wasting resources. :) Also, not sure what you meant by "prevent lag"
     
Thread Status:
Not open for further replies.

Share This Page