Created
January 2, 2014 16:12
-
-
Save lualzockt/8221573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ScoreboardHelper { | |
public static void displayObjective(Player player, String id, String title, DisplaySlot slot ,Map<String, Integer> values) { | |
Scoreboard board = player.getScoreboard(); | |
if(board == null) { | |
board = Bukkit.getScoreboardManager().getNewScoreboard(); | |
} | |
Objective obj = board.getObjective(id); | |
if(obj == null) { | |
obj = board.registerNewObjective(id, "dummy"); | |
} | |
if(title.length > 32) { | |
title = title.substring(0, 31); | |
} | |
obj.setDisplaySlot(slot); | |
obj.setDisplayName(title); | |
for(String s : values.keySet()) { | |
if(s.length > 16) { | |
s = s.substring(0, 15); | |
} | |
OfflinePlayer op = Bukkit.getOfflinePlayer(s); | |
obj.getScore(op).setScore(values.get(s)); | |
} | |
player.setScoreboard(board); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment