Boss Bars

Discussion in 'Plugin Development' started by maxben34, Oct 29, 2013.

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

    maxben34

    I've been messing with the boss bars and after not getting them to work, I've resorted to using a plugin and then making another plugin that makes the player say commands from it.

    I'm aware this is extremely inefficient and I really don't want to do it like this, however I don't know how to do it otherwise.

    Here is what I have:

    Code:java
    1. package me.maxben34.boss;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerJoinEvent;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class boss extends JavaPlugin implements Listener{
    11.  
    12. public void onEnable(){
    13. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    14. }
    15. public void Boss(){
    16. for(final Player p : Bukkit.getOnlinePlayers()){
    17. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    18. public void run(){
    19. p.chat("/bm 1 &9&lProjectMayhem");}},20);
    20. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    21. public void run(){
    22. p.chat("/bm 1 &d&lProjectMayhem");}},20);
    23. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    24. public void run(){
    25. p.chat("/bm 1 &a&lProjectMayhem");}},20);
    26. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    27. public void run(){
    28. p.chat("/bm 1 &c&lProjectMayhem");}},20);
    29. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    30. public void run(){
    31. p.chat("/bm 1 &b&lProjectMayhem");}},20);
    32. }
    33. }
    34. @EventHandler
    35. public void onPlayerJoin(final PlayerJoinEvent e){
    36. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
    37. public void run(){
    38. Boss();
    39. }
    40. ;}, 20, 6*20);}
    41. }
    42.  

    Right now this isn't currently working :p

    I can't seem to figure out why. Maybe you guys could help, or just tell me how to do this without any other plugins (as I said it's really stupid how I have it right now). Although I was having trouble doing it without a plugin before.

    Bump :/

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

    reider45

    Try changing the
    Code:java
    1. 20

    at the end of each line so that it goes from maybe 20 to 40 to 60 etc. Other than that I'm not totally sure :) Good luck
     
  3. Offline

    RealDope

  4. Offline

    negative_codezZ

    By the way, see how you are doing:

    Code:java
    1. p.chat("/bm 1 &b&lProjectMayhem");}},20);


    and such? What if the player's command key is not a "/"? I would recommend changing it to:

    Code:java
    1. Bukkit.getServer().dispatchCommand(p, "command");
     
  5. Huh?
     
  6. Offline

    _Filip

    negative_codezZ
    You are so lost.
    A command key doesn't change based on the client......
    You also cannot change the command key you use. Please. If you don't know the material yourself don't go around telling people how to improve.
     
  7. Offline

    RealDope

    Regardless of his reasoning, it is really still better to use .dispatchCommand(), as it won't be influenced by chat plugins which could otherwise interfere.
     
Thread Status:
Not open for further replies.

Share This Page