Skip to content

Instantly share code, notes, and snippets.

@securitygab
Created August 7, 2019 10:48
Show Gist options
  • Save securitygab/add855be527430e3849972df1e6e70a0 to your computer and use it in GitHub Desktop.
Save securitygab/add855be527430e3849972df1e6e70a0 to your computer and use it in GitHub Desktop.
How to scoreboard refresh - Tutorial for Tyler.
Hey Tyler, basically to explain u how to refresh a scoreboard is todo this:
To update every second, you need create a new Runnable. Or you can update the scoreboard per line.
Explain code:
Update every second:
new BukkitRunnable() {
@Override
public void run() {
//set player scoreboard;
}
}.runTaskTimer(MAIN, <initial-time>, <delay>);
U also need a update_line center.
Update per line:
public void updatePerLine(Player player, String line, int scoreSlot) {
if (!Bukkit.getOnlinePlayers().contains(player) || (player.getScoreboard() == null)) {
return;
}
for (String str : player.getScoreboard().getEntries()) {
if (str.contains(line) || str.equals(line)) {
player.getScoreboard().resetScores(str);
}
}
Scoreboard score = player.getScoreboard();
score.getObjective(DisplaySlot.SIDEBAR).getScore(line).setScore(scoreSlot);
}
Use a runnable in your onEnable method updating everyone's scoreboards simultaneously or you can update a specific persons.
May want to change your time as updating every second can be quite intensive.
Making the ticks in your timer Tyler:
Change the first 20 to either 40, 60, or 80.
These are ticks.
20 - 1 second.
40 - 2 seconds.
60 - 3 seconds.
80 - 4 seconds.
100 - 5 seconds.
And btw to be honestly, you can change this one to suit your needs.
ew BukkitRunnable() {
public void run() {
for(Player p : Bukkit.getOnlinePlayers()){
BoardManager.setupStandardBoard(p);
}
}
}.runTaskTimer(main, 60L, 20L);
}
If you want a non-flicker scoreboard.
You can do things with teams and scoreboard strings.
So you don't have to reconstruct the player's scoreboard each time.
But that can be found with an easy google search.
And how to loop your scoreboard perfectly: Run it in your onEnable method to start it.
Hope u understand it, and I hope u meant this in case. And that I understood u good. Thanks for reading and taking time buddy :)
- Regards
Securitygab - KuroiSH
@securitygab
Copy link
Author

You're welcome ! I hope it works well.
I quit creating those such a things for Minecraft. Active in other category's

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment