Util SimpleScoreboard - Make pretty scoreboards with ease!

Discussion in 'Resources' started by RainoBoy97, Apr 30, 2014.

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

    RainoBoy97

    Hello!

    Today I made a simple class to easily create scoreboards! You can add text with custom scores, or dont set a score and it will display the scores in the order you add them in. You can also add blank lines, and have lines with up to 48 characters!

    Example usage: Link
    Code: Link (if you use this, credit would be appreciated :))

    Example (from the code above):
    [​IMG]

    If you want a feature added, you can always suggest the idea below and I may or may not add it :)

    -Raino
     
    cococow123, Sneling, Skyost and 10 others like this.
  2. Offline

    ImPhantom

    RainoBoy97
    Maybe scrolling text, i think mineplex has it?
     
    GrandmaJam likes this.
  3. Offline

    RainoBoy97

    Chinwe likes this.
  4. Offline

    ImPhantom

    RainoBoy97 If you wanted to, you could ask Chinwe and implement it, just to make it a bit easier for beginners.
     
  5. Offline

    RainoBoy97

    ImPhantom
    Once I get home I'll add an update method so you can update a specific score :)
     
    GrandmaJam likes this.
  6. Offline

    Toni

    RainoBoy97

    This is fantastic. Being able to display text > 16 characters is an amazing opening window for more detailed score boards, thank you for this.

    I have some issues that I'd like to try to resolve with this though: I currently want to set variables within the scoreboard, i.e. a timer variable that is consistently counting down every second. However when I try to update the scoreboard every second, there is an conflicting issue with scoreboard.build(); -- it rebuilds the scoreboard over again even when it already exists and then creates this stack trace:

    https://gist.github.com/ToniTang/9d4df1f06c61011b0190 (scoreboard.build().txt)

    So I figured, why not just reset the scoreboard and create it again (terrible idea, I assumed it'd be very resource unfriendly). When I did this, I resulted in an NPE instead which can be seen again in the gist link above under the second report (scoreboard.reset().txt).

    Hope to get this resolved soon, thanks again for such an easy and simple scoreboard manager to use. I love the fact that you can add lines without having to set a score and it'll automatically sort them. Big plus.
     
  7. Thank you, sir! :)
     
  8. Offline

    RainoBoy97

    Toni
    Don't do .reset() then .build() again, if you're using this and updates it each second, do .reset() then create a completely new one (new SimpleScoreboard()).
     
  9. Offline

    Toni


    So that's getting me somewhere, thank you :). The only issue now is that the scoreboard is very...flashy. It glitches out and comes back every time there's an reset and new scoreboard made.

    Would you be able to have an update allowing scoreboard modification to a certain score? I.e. instead of destroying and recreating the entire thing, would I be able to just simply edit an objective/score instead?
     
  10. Offline

    RainoBoy97

    Toni
    I'll look into that :) This was just something I threw together for fun!
     
    Toni likes this.
  11. Offline

    Toni


    Thanks so much, I really appreciate it. And your fun made something fantastic! I'm still obsessing over the fact that you can have more than 16 characters, it makes the scoreboard like how it should be.
     
  12. Offline

    Lolmewn

    Fancy. Imma try using this now.
     
  13. Offline

    gony157

    Thank you so much, Raino!
     
  14. Offline

    Stilldabomb

    One thing I'd like to see-not that big of a feature, and not that impacting-is the ability to use an ampersand instead of a section symbol, it's not that hard, but it would make it easier so you don't have to use alt codes and stuff. Also makes it easier for people that don't have the alt code for the section symbol memorized. Other than that, this library is really nice :)
     
  15. Offline

    RainoBoy97

    Stilldabomb
    You can use ChatColor.COLOR :)

    Due to the feedback I will update this with some other cool features :)
     
  16. Offline

    Stilldabomb

    Oh yeah, I know, but being able to just parse "&2This is a message!" is a lot easier. There's ChatColor.translateAlternateColorCodes('&', message), it's literally just one line haha.
     
    GrandmaJam likes this.
  17. Offline

    RainoBoy97

    Oh, I missread your post. I thought you ment you didn't want to use §<color code> :p Sorry!
     
  18. Offline

    Stilldabomb

    Haha, it's all good! :)
     
  19. Offline

    Ba7marker

    RainoBoy97
    Works ok but any idea why it's making the strings 'score' to 'Sc0re' and 'Stats' to 'StaTS'. Also any chance to support spigot because it wasn't working with it when I tried.;)
    [​IMG]
    I know the kills and such are null

    Thanks
     
    GrandmaJam likes this.
  20. Offline

    mine-care

    Ah thanks!,was bored to use dummies!
    :D u awesome!
     
  21. Offline

    Gater12

    You kind sir, have just made my life easier. Will start incorporating this into all my scoreboard-based plugins.
     
  22. Offline

    mine-care

    Well i get a error each time a second player joins...
    here:
    PHP:
    [21:03:26 ERROR]: Could not pass event PlayerJoinEvent to Teams v1.5
    org
    .bukkit.event.EventException
            at org
    .bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va
    :320) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a
    :62) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava
    :486) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava
    :471) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at net.minecraft.server.v1_7_R1.PlayerList.c(PlayerList.java:225) [craft
    bukkit
    -1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at net.minecraft.server.v1_7_R1.PlayerList.a(PlayerList.java:116) [craft
    bukkit
    -1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at net.minecraft.server.v1_7_R1.LoginListener.c(LoginListener.java:78) [
    craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at net.minecraft.server.v1_7_R1.LoginListener.a(LoginListener.java:42) [
    craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:149
    ) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit
    -1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    55
    ) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50
    ) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45
    ) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17
    ) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    Caused byjava.lang.IllegalArgumentExceptionAn objective of name 'πaπlScore'
    already exists
            at org
    .apache.commons.lang.Validate.isTrue(Validate.java:157) ~[craftbuk
    kit
    -1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            
    at org.bukkit.craftbukkit.v1_7_R1.scoreboard.CraftScoreboard.registerNew
    Objective
    (CraftScoreboard.java:40) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2
    -R0.3-b3020jnks]
            
    at org.bukkit.craftbukkit.v1_7_R1.scoreboard.CraftScoreboard.registerNew
    Objective
    (CraftScoreboard.java:20) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2
    -R0.3-b3020jnks]
            
    at me.fillpant.pvp.SimpleScoreboard.build(SimpleScoreboard.java:72) ~[?:
    ?]
            
    at me.fillpant.pvp.Scoreboard.displayscore(Scoreboard.java:17) ~[?:?]
            
    at me.fillpant.pvp.teams.pje(teams.java:202) ~[?:?]
            
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0
    _51
    ]
            
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0
    _51
    ]
            
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .7.0_51
    ]
            
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51]
            
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va
    :318) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    EDIT: im ur code i added a if obj != null then create the objective but still hasnt worked
     
  23. Offline

    viper_monster

  24. Offline

    RainoBoy97

    mine-care
    Dont call .build() on the same scoreboard more than once.
     
  25. Offline

    mine-care

    Nvm i got to make it my own meanwhile, but nice work!

    Havent, instead i did only once

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 9, 2015
  26. Offline

    TedTheTechie

    Beautiful.
     
    GrandmaJam likes this.
  27. Offline

    mazentheamazin

    RainoBoy97
    Great job on this! I thought I'd might add a few methods to help simplify things and add some JavaDoc comments for users to understand the methods, and that's exactly what I did! Here is the gist ;)

    EDIT: If you were wondering why I keep returning the current instance instead of returning void it is so you can do this:
    Code:java
    1. SimpleScoreboard ss = new SimpleScoreboard("Title").add("test1").blankLine();
    2. //So on and so on...
     
  28. Offline

    macboinc

    How would I update a scoreboard?
     
  29. Offline

    maved145

    RainoBoy97 I love this little library! It’d be soooo good if you could add a update feature so the scoreboard doesn’t glitch it! Thanks! :)
     
  30. Offline

    Squid_Boss

    Alright, so first of all, I really love this. Second, I've been messing around with it and I've added an update method.

    * IMPORTANT *
    In order for this to work, at the top of the class add this:
    Code:java
    1. private Objective obj;

    And you should get an error in the build() method, you need to change "Objective obj = scoreboard.WHATEVER" into "obj = scoreboard.WHATEVER".

    Now for the update method (No flashing):
    Code:java
    1. @SuppressWarnings("deprecation")
    2. public void update(String text, Integer score) {
    3. if (scores.containsKey(text)) {
    4. scores.put(text, score);
    5. for (Team t : teams) {
    6. if (t.getName() == text) {
    7. t.unregister();
    8. }
    9. }
    10.  
    11. Map.Entry<Team, String> team = createTeam(text);
    12. OfflinePlayer player = Bukkit.getOfflinePlayer(team.getValue());
    13. if (team.getKey() != null)
    14. team.getKey().addPlayer(player);
    15. obj.getScore(player).setScore(score);
    16.  
    17. }
    18. }
     
Thread Status:
Not open for further replies.

Share This Page