瀏覽代碼

Make sure to shorten long ability and skill names

(cherry picked from commit 236ccd6ebdd0834f87b373794e1597ef36fb2ff6)
TfT_02 11 年之前
父節點
當前提交
5825eb1696
共有 1 個文件被更改,包括 19 次插入7 次删除
  1. 19 7
      src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java

+ 19 - 7
src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java

@@ -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