Git Product home page Git Product logo

scoreboardlib's Introduction

ScoreboardLib

A flicker-free scoreboard library with support of text up to 48 characters.

What is ScoreboardLib?

ScoreboardLib is a flexiable library for adding pretty, animated scoreboards to your plugin without requiring you to figure out how to get rid of random flickers or limitations. This library is introduced to dealt with following problems in the original API and similar libraries:

  • Scoreboards cannot display text of more than 16 characters.
  • Scoreboards cannot display the same text more than once.
  • The scoreboard is flickering all the time.
  • Random disappearance of lines.

Any screenshots?

Preview

Other reasons to use ScoreboardLib?

  • Simple to use. You just have to decide the user interface, ScoreboardLib already got the backend handled.
  • Displays up to 48 characters instead of 16.
  • Easy to implement animated text with help of ScrollableString and HighlightedString.
  • Designed to be scalable and flexible.
  • Performant. ScoreboardLib doesn't create a scoreboard every time the content is updated.
  • Can be used as a standalone plugin, or be shaded into your project.

How do I add it to my project?

Simply add the following to your pom.xml.

<repository>
  <id>tiger-repo</id>
  <url>http://repo.tigerhix.me/content/repositories/snapshots/</url>
</repository>

<dependency>
  <groupId>me.tigerhix.lib</groupId>
  <artifactId>scoreboard</artifactId>
  <version>1.0.1-SNAPSHOT</version>
</dependency>

Now you are able to create your own pretty scoreboards.

How do I use it?

First, you have to decide whether you use ScoreboardLib as a standalone plugin, or you just go shade it into your own plugin. For the latter case, you have to add following code to your onEnable():

ScoreboardLib.setPluginInstance(this);

To let ScoreboardLib holds a reference to your plugin and hence able to schedule tasks, register events, etc.

For the scoreboard itself, here is an usage example:

for (Player player: getServer().getOnlinePlayers()) {
	Scoreboard scoreboard = ScoreboardLib.createScoreboard(player)
		.setHandler(new ScoreboardHandler() {

    		private final ScrollableString scroll = new ScrollableString(Strings.format("&aThis string is scrollable!"), 40, 0);
    		private final HighlightedString highlighted = new HighlightedString("This string is highlighted!", "&6", "&e");
    
    		@Override
    		public String getTitle(Player player) {
    			return null;
    		}
    
    		@Override
    		public List<Entry> getEntries(Player player) {
    			return new EntryBuilder()
    				.next("    " + scroll.next())
    				.next("    " + highlighted.next())
    				.blank()
    				.next("    &b&lCURRENT TIME MILLIS")
    				.next("    " + System.currentTimeMillis())
    				.blank()
    				.next("    &c&lCURRENT NANO TIME")
    				.next("    " + System.nanoTime())
    				.blank()
    				.next("    &7This line is equivalent to another line")
    				.next("    &7This line is equivalent to another line")
    				.blank()
    				.build();
    		}

	    })
	    .setUpdateInterval(2l);
	scoreboard.activate();
}

Which would display a scoreboard as shown in the above gif to all online players.

To remove the scoreboard, use:

scoreboard.deactivate();

That's really much of it. If you want to extend the functionalities somehow, simply create a new class that extends SimpleScoreboard, and start overriding methods, creating constructors, etc.

License

ScoreboardLib is licensed under the GNU Lesser General Public License (Version 3).

scoreboardlib's People

Contributors

ddynamic avatar jingwenmc avatar tigerhix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

scoreboardlib's Issues

Dupe in tab!?

private void createScoreBoard(Player p, List<String> lines, String displayName) {
        Scoreboard scoreboard = ScoreboardLib.createScoreboard(p).setHandler(new ScoreboardHandler() {
            @Override
            public String getTitle(Player player) {
                return displayName;
            }

            @Override
            public List<Entry> getEntries(Player player) {
                EntryBuilder builder = new EntryBuilder();
                for(String l: lines) {
                    if(l == null || l.isEmpty()) builder.blank();
                    else builder.next(Utils.setDisplayString(p, l));
                }
                return builder.build();
            }
        }).setUpdateInterval(5);
        scoreboard.activate();
    }

This is my code... in Utils i replace my placeholders & placeholders of PlaceHolderAPI...
I shade the library into my plugin
now i see my name in tab, bruh
what happend?
images:
https://cdn.discordapp.com/attachments/1118607519057715250/1147370694087290910/image.png
https://cdn.discordapp.com/attachments/1118607519057715250/1147370694334750720/image.png

Scoreboard Flickers

The scoreboard flickers. I have a gif of it here: https://i.gyazo.com/c48b2259d3bd6bbe431eb6f75d3ff1e7.mp4

Here is my code:

public class ScoreboardManager implements ScoreboardHandler {
    public List<Entry> getEntries(Player player) {
        EntryBuilder eb = new EntryBuilder();

        eb.next("§8§l§m================");
        eb.next("§2§lFaction: §fMemes");
        eb.next(" §7► §aPlayers: §f1/1");
        eb.next(" §7► §aDTR: §f1/1");
        eb.next("§8§l§m================");
       
        return eb.build();
    }

    public String getTitle(Player player) {
        return "§e§lMCCubed§r §7(Map 1)§r";
    }
}

Some info that could be needed:

  • Running Spigot-1.7.9-R0.2-208-ge0f2e95 (MC: 1.7.10) (Implementing API version 1.7.10-R0.1-SNAPSHOT)
  • Code is just what is shown, I use some mechanics to get the values.
  • I have tried removing mechanics to see if it was somehow slowing it down to cause an issue.
  • It seems to only occur on the first line, and that it only removes a portion of the text. Is this possibly something to do with the slider texts even though I'm not using one?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.