Scheduler and Playerlists

Discussion in 'Plugin Development' started by Fallen_Advent, Sep 25, 2011.

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

    Fallen_Advent

    Ok so what I need to be able to accomplish is,

    1. Get a list of online players from the server
    2. Get those players hunger level
    3. Schedule their hunger level to be set to 20 every X seconds
     
  2. And what do you need?
     
  3. Offline

    Fallen_Advent

    @Pandemoneus I need to know how to pull it off, I cant seem to figure out how to get the list of players, and then change their hunger levels, I am brand new to java programming and I am still lost on how to accomplish this.

    Origionally I had it setplayer food level to 20 onPlayerMoveEvent but I can imagine it lagging the server out quite a bit when your player count gets higher.

    Here is a link to my project files if you want to take a look

    Project Files -- http://dl.dropbox.com/u/37965173/FallenHungerSRC.rar
     
  4. Offline

    Nitnelave

    When you start your plugin, you can create a ScheduledSyncTask with the BukkitScheduler, programmed to run every x seconds, and in that task you get the list of online players (getServer().getPlayers() or something like that) and you loop through the list and set each level to 20.
     
  5. Offline

    Fallen_Advent

    @Nitnelave Would I just put that in the onEnable or in the player listener

    *Edit* Nevermind, read your post again and I think I know what to do now
     
Thread Status:
Not open for further replies.

Share This Page