Solved Help with sending a message to a player using Schedulers.

Discussion in 'Plugin Development' started by _hunter, Mar 25, 2015.

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

    _hunter

    Hello Bukkit Community!

    I am trying to make a plugin where it sends a message to the player every three seconds, and I need help figuring out how to get the player when I'm not using an event or a command. Sorry if this is sort of a newbish question. I just started learning bukkit again. : )

    Here is a paste of the code I have currently. I will appreciate any help I can get here, even if it doesn't work in the situation I have. http://pastebin.com/KYuvsgry
     
  2. Offline

    Funergy

    @_hunter use a for loop with Bukkit.getOnlinePlayers() and then you get every player on the server

    EDIT: in Java 8 you can do Bukkit.getOnlinePlayers().forEach(Player::sendMessage(""));
     
  3. Offline

    mine-care

    @_hunter @Funergy pretty much solved your thread, I want to recommend the use of a simple for loop to send the empty messages (in order to clear chat) to skip 6 lines.
    Edit: it would be more efficient sending a message with \n 's instead of multiple messages.
     
    _hunter likes this.
  4. Offline

    _hunter

    Sorry for my late reply. I am now getting errors on my endings for my events and class. upload_2015-3-25_20-7-25.png
     
  5. Offline

    mine-care

    You're missing a bracket somewhere I assume its a closing one (not sure, image won't fully load...) also another thing I noticed, don't cast sender to Player without checking, it is the best way for huge errors. See my signature for more info :- )
     
  6. Offline

    _hunter

    I'm going to attempt to clean up the code alot and see where I can get with this. For now, my plugin is busted...
     
  7. Offline

    nverdier

    @_hunter Why is this thread marked as solved? Is it?
     
  8. Offline

    Funergy

    @nverdier Well he got the answer for his question. So its solved
     
  9. Offline

    nverdier

    Well his plugin isn't really fixed... :p
     
  10. Offline

    _hunter

    I fixed it. I wasn't putting the code in the onEnable()... Silly me. Thank you for all the support! : )
     
Thread Status:
Not open for further replies.

Share This Page