Make sure to shorten long ability and skill names

(cherry picked from commit 236ccd6ebdd0834f87b373794e1597ef36fb2ff6)
This commit is contained in:
TfT_02 2014-04-14 15:54:50 +02:00
parent bfebbd0095
commit 5825eb1696

View File

@ -77,13 +77,13 @@ public class ScoreboardManager {
int i = 0;
for (SkillType type : SkillType.values()) {
// Include child skills
skillLabelBuilder.put(type, colors.get(i) + type.getName());
skillLabelBuilder.put(type, getShortenedName(colors.get(i) + type.getName(), false));
if (type.getAbility() != null) {
abilityLabelBuilder.put(type.getAbility(), colors.get(i) + type.getAbility().getName());
abilityLabelBuilder.put(type.getAbility(), getShortenedName(colors.get(i) + type.getAbility().getName()));
if (type == SkillType.MINING) {
abilityLabelBuilder.put(AbilityType.BLAST_MINING, colors.get(i) + AbilityType.BLAST_MINING.getName());
abilityLabelBuilder.put(AbilityType.BLAST_MINING, getShortenedName(colors.get(i) + AbilityType.BLAST_MINING.getName()));
}
}
@ -95,20 +95,20 @@ public class ScoreboardManager {
else {
for (SkillType type : SkillType.values()) {
// Include child skills
skillLabelBuilder.put(type, ChatColor.GREEN + type.getName());
skillLabelBuilder.put(type, getShortenedName(ChatColor.GREEN + type.getName()));
if (type.getAbility() != null) {
abilityLabelBuilder.put(type.getAbility(), ChatColor.AQUA + type.getAbility().getName());
abilityLabelBuilder.put(type.getAbility(), getShortenedName(ChatColor.AQUA + type.getAbility().getName()));
if (type == SkillType.MINING) {
abilityLabelBuilder.put(AbilityType.BLAST_MINING, ChatColor.AQUA + AbilityType.BLAST_MINING.getName());
abilityLabelBuilder.put(AbilityType.BLAST_MINING, getShortenedName(ChatColor.AQUA + AbilityType.BLAST_MINING.getName()));
}
}
}
}
for (AbilityType type : AbilityType.values()) {
abilityLabelSkillBuilder.put(type, (type == AbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA) + type.getName());
abilityLabelSkillBuilder.put(type, getShortenedName((type == AbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA) + type.getName()));
}
skillLabels = skillLabelBuilder.build();
@ -127,6 +127,18 @@ public class ScoreboardManager {
TOP_BOARD;
}
private static String getShortenedName(String name) {
return getShortenedName(name, true);
}
private static String getShortenedName(String name, boolean useDots) {
if (name.length() > 16) {
name = useDots ? name.substring(0, 14) + ".." : name.substring(0, 16);
}
return name;
}
// **** Listener call-ins **** //
// Called by PlayerJoinEvent listener