Cool little scoreboard broadcasting

Discussion in 'Bukkit Discussion' started by RingOfStorms, Apr 17, 2013.

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

    RingOfStorms

    TL;DR - Just look at the bold

    Tonight I looked into the new scoreboard api and whipped a small thing up just to see what I could do with it. After much tinkering I found the only good place to display info is on the sidebar, the player-list and under name areas just don't allow a lot of customization. The coolest thing I did with those is display the rank under their name (could be used for classes). But soon after I looked at some previous plugins and saw the ScoreBoardAnnouncer plugin. Seemed like a cool idea, but people were complaining about the 16 character max for their messages, which does seem pretty dumb for a broadcast that has lots of info. So I made this little thing:

    (Look at the scoreboard)


    Seems like a good idea, and if needed, I could do a version where multiple messages are going across, they would just be smaller, and therefore set at a lower scroll speed.

    Things working now:
    • Displays the broadcaster (aka person who sent the message) under the broadcast.
    • Shows the broadcast in the 32 char line and scrolls across it.
    • Scroll speed and delay can be customized.
    • Players are not kicked for string sizes
    Anyways, reason for my posting is basically, do you want a plugin like this?Respond with your thoughts below. I also don't normally do open source, but I think with this project I will so some others can learn from it.

    Edit: I don't actually have time to do this and maintain it. If someone else could do it that would be cool.

    Code: This is literally just a class I made in a few minutes to test this idea. Only thing you should really be using from this is maybe the scheduled task and how that works, but you should probably not use the main server scoreboard, and instead make a new one (allows different viewers as well).
    Show Spoiler

    Code:java
    1.  
    2. package net.goa.plugins.gunsofaurora;
    3.  
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.OfflinePlayer;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.scoreboard.DisplaySlot;
    9. import org.bukkit.scoreboard.Objective;
    10. import org.bukkit.scoreboard.Scoreboard;
    11.  
    12. public class TestScoreBoard {
    13.  
    14. private final GOA plugin;
    15. public final Scoreboard s;
    16. public TestScoreBoard (GOA plugin) {
    17. this.plugin = plugin;
    18. this.s = plugin.getServer().getScoreboardManager().getMainScoreboard();
    19. quickInit();
    20. }
    21.  
    22. public GOA getPlugin() {
    23. return plugin;
    24. }
    25.  
    26. int sBIndex = 0;
    27. int sLength = 1;
    28. int sDelay = 4;
    29. int taskid = 0;
    30.  
    31. public void quickInit () {
    32. for(DisplaySlot ds : DisplaySlot.values())
    33. s.clearSlot(ds);
    34. sideBar();
    35. }
    36.  
    37. public void sideBar () {
    38. if(s.getObjective(DisplaySlot.SIDEBAR) != null)
    39. s.getObjective(DisplaySlot.SIDEBAR).unregister();
    40. if(s.getObjective("cool") != null)
    41. s.getObjective("cool").unregister();
    42. final Objective hb = s.registerNewObjective("cool", "dummy");
    43. hb.setDisplayName(ChatColor.GRAY+"[No New Messages] ");
    44. hb.setDisplaySlot(DisplaySlot.SIDEBAR);
    45.  
    46. final OfflinePlayer def = Bukkit.getOfflinePlayer(ChatColor.GRAY+"Broadcaster");
    47.  
    48. hb.getScore(def).setScore(1);
    49.  
    50. final String mO = " [::]New Message Incomming[::] "+"This is a test message to all players. We are going to be restarting the server within the hour. Please take note and don't do anything extreme. Another warning will apear in about thirty minutes!" + " ";
    51. String authorDsip = ChatColor.BLUE+"RingOfStorms";
    52. final OfflinePlayer author = Bukkit.getOfflinePlayer(authorDsip.substring(0, Math.min(16, authorDsip.length())));
    53. final String color = ChatColor.GOLD.toString();
    54.  
    55. taskid = Bukkit.getScheduler().scheduleSyncRepeatingTask(getPlugin(), new Runnable () {
    56. public void run () {
    57. String m = mO.substring(sBIndex, Math.min(sBIndex+32-color.length(), mO.length()-color.length()));
    58. m = color+m;
    59. if(m.length() <= color.length()) {
    60. hb.setDisplayName(ChatColor.GRAY+"[No New Messages]");
    61. hb.getScore(def).setScore(1);
    62. s.resetScores(author);
    63. cancelTask();
    64. }else{
    65. sBIndex += sLength;
    66. hb.setDisplayName(m);
    67. hb.getScore(author).setScore(1);
    68. s.resetScores(def);
    69. }
    70. }
    71. }, 20L * 3, sDelay);
    72. }
    73.  
    74. public void cancelTask () {
    75. Bukkit.getScheduler().cancelTask(taskid);
    76. taskid = 0;
    77. }
    78. }
    79.  


     
  2. Offline

    Stevensaurus

    That's pretty awesome. You can bet I'll be getting this.
     
  3. Offline

    cloak_fox

    That's Awesome
     
  4. Offline

    Burnett1

    It looks good. Does it just overlay the current scoreboard? I would defiantly make this but make sure it wont conflict with other scoreboard plugins.
     
  5. Offline

    jorisk322

    Awesome! Would like this a lot.
     
  6. Offline

    RingOfStorms

    With this little look it just uses the main scoreboard, so currently it would. But you could make a new one and send it to the players to not override other boards.

    Edit: Do you want to make this plugin? Or do you want me to make it?
     
  7. Offline

    Burnett1

    Ill let you, i am not experienced with scoreboards.
     
  8. Offline

    SimplyNolan

    Could u send me a private message of the plugin on my server please? =D
     
  9. Offline

    bitWolfy

    Well, that is one of the two big problems with the scoreboards fixed. Great job!
     
  10. Offline

    RingOfStorms

    Well I'll probably get around and do this within a week or two. Not a huge project but I don't have a lot of time on my hands for public plugins anymore. I'll tell you guys when I have it on bukkit dev.
     
  11. Offline

    chaseoes

    I considered doing this but my OCD hates that there has to be a number there.
     
    RingOfStorms likes this.
  12. Offline

    RingOfStorms

    I don't actually have time to do this and maintain it. If someone else could do it that would be cool.

    Code: This is literally just a class I made in a few minutes to test this idea. Only thing you should really be using from this is maybe the scheduled task and how that works, but you should probably not use the main server scoreboard, and instead make a new one (allows different viewers as well).

     
  13. Offline

    MiniDigger

    RingOfStorms I am working with your code and changed a lot of things. But now I get this error:
    20:43:35 [WARNUNG] [TestPlug] Task #58 for TestPlug v1.0.82 generated an exception
    java.lang.IllegalStateException: Unregistered scoreboard component
    at org.bukkit.craftbukkit.v1_6_R3.scoreboard.CraftScoreboardComponent.checkState(CraftScoreb
    oardComponent.java:13)
    at org.bukkit.craftbukkit.v1_6_R3.scoreboard.CraftObjective.setDisplayName(CraftObjective.ja
    va:43)
    at de.MiniDigger.TestPlug.API.ScrollingScoreBoard$1.run(ScrollingScoreBoard.java:79)
    at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftTask.run(CraftTask.java:53)
    at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftSchedule
    r.java:345)
    at net.minecraft.server.v1_6_R3.MinecraftServer.t(MinecraftServer.java:524)
    at net.minecraft.server.v1_6_R3.DedicatedServer.t(DedicatedServer.java:227)
    at net.minecraft.server.v1_6_R3.MinecraftServer.s(MinecraftServer.java:488)
    at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java:421)
    at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:583)
    while trying to set the displayname. Do you know wy?
     
  14. Offline

    Bobcat00

    Perhaps set it to the background color?
     
  15. Offline

    TomTheDeveloper

    Is thinking about another awesome idea! Thx
     
  16. Offline

    MiniDigger

Thread Status:
Not open for further replies.

Share This Page