BarAPI not showing for players

Discussion in 'Plugin Development' started by micrlink, Jul 15, 2014.

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


    Right now I have it so their is a loop onEnable that sets the boss bar to a random message in a user set list. works perfectly fine, except when a player joins it doesn't show it. It shows the boss bar they had when they were previously on but after a second it goes away. I tried scheduling a syncdelayed task after they joined to set a message but it didn't show up.

    When I do BarAPI.hasBar(player) it says true.
  2. Offline


    I belive you should report to BarAPI's maintainer :l

    Or at least tell us how you use it
  3. Offline



    Code would be helpful, as rfsantos1996 said.

    Also, this sounds like more an issue for the BarAPI comment sections, or a ticket on the GitHub, or something similar.
  4. Offline


    Instead of looping on onEnable(), try setting it after the player joins (PlayerJoinEvent).
  5. Offline


    TheMcScavenger but then you would have multiple running at a time
  6. Offline


    Oh, you want multiple messages. Hmm...

    The following seems to be working fine for me:
    1. @Override
    2. public void onEnable() {
    3. final String[] messages = {"Message One", "Message Two", "Message Three"};
    4. final Random random = new Random();
    6. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
    7. public void run(){
    8. for(Player player : Bukkit.getOnlinePlayers()){
    9. int randInt = random.nextInt(messages.length);
    10. BarAPI.setMessage(player, messages[randInt], 3);
    11. }
    12. }
    13. }, 0, 60);
    14. }
Thread Status:
Not open for further replies.

Share This Page