From 353fb80957b2b6a1d6a7cc361c628413e3085433 Mon Sep 17 00:00:00 2001 From: Ineusia Date: Sat, 25 Jul 2020 12:13:54 -0500 Subject: [PATCH] Use localized names for SuperAbility names --- .../commands/player/MccooldownCommand.java | 4 +-- .../datatypes/skills/SuperAbilityType.java | 33 ++++++++++++++----- .../util/scoreboards/ScoreboardManager.java | 10 +++--- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java index 7cf6d7589..74011a39c 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java @@ -56,9 +56,9 @@ public class MccooldownCommand implements TabExecutor { int seconds = mcMMOPlayer.calculateTimeRemaining(ability); if (seconds <= 0) { - player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName())); + player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getLocalizedName())); } else { - player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds)); + player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getLocalizedName(), seconds)); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java index cb4b0b10e..66c4957a9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.datatypes.skills; import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.Permissions; @@ -15,49 +16,56 @@ public enum SuperAbilityType { "Unarmed.Skills.Berserk.Off", "Unarmed.Skills.Berserk.Other.On", "Unarmed.Skills.Berserk.Refresh", - "Unarmed.Skills.Berserk.Other.Off"), + "Unarmed.Skills.Berserk.Other.Off", + "Unarmed.SubSkill.Berserk.Name"), SUPER_BREAKER( "Mining.Skills.SuperBreaker.On", "Mining.Skills.SuperBreaker.Off", "Mining.Skills.SuperBreaker.Other.On", "Mining.Skills.SuperBreaker.Refresh", - "Mining.Skills.SuperBreaker.Other.Off"), + "Mining.Skills.SuperBreaker.Other.Off", + "Mining.SubSkill.SuperBreaker.Name"), GIGA_DRILL_BREAKER( "Excavation.Skills.GigaDrillBreaker.On", "Excavation.Skills.GigaDrillBreaker.Off", "Excavation.Skills.GigaDrillBreaker.Other.On", "Excavation.Skills.GigaDrillBreaker.Refresh", - "Excavation.Skills.GigaDrillBreaker.Other.Off"), + "Excavation.Skills.GigaDrillBreaker.Other.Off", + "Excavation.SubSkill.GigaDrillBreaker.Name"), GREEN_TERRA( "Herbalism.Skills.GTe.On", "Herbalism.Skills.GTe.Off", "Herbalism.Skills.GTe.Other.On", "Herbalism.Skills.GTe.Refresh", - "Herbalism.Skills.GTe.Other.Off"), + "Herbalism.Skills.GTe.Other.Off", + "Herbalism.SubSkill.GreenTerra.Name"), SKULL_SPLITTER( "Axes.Skills.SS.On", "Axes.Skills.SS.Off", "Axes.Skills.SS.Other.On", "Axes.Skills.SS.Refresh", - "Axes.Skills.SS.Other.Off"), + "Axes.Skills.SS.Other.Off", + "Axes.SubSkill.SkullSplitter.Name"), TREE_FELLER( "Woodcutting.Skills.TreeFeller.On", "Woodcutting.Skills.TreeFeller.Off", "Woodcutting.Skills.TreeFeller.Other.On", "Woodcutting.Skills.TreeFeller.Refresh", - "Woodcutting.Skills.TreeFeller.Other.Off"), + "Woodcutting.Skills.TreeFeller.Other.Off", + "Woodcutting.SubSkill.TreeFeller.Name"), SERRATED_STRIKES( "Swords.Skills.SS.On", "Swords.Skills.SS.Off", "Swords.Skills.SS.Other.On", "Swords.Skills.SS.Refresh", - "Swords.Skills.SS.Other.Off"), + "Swords.Skills.SS.Other.Off", + "Swords.SubSkill.SerratedStrikes.Name"), /** * Has cooldown - but has to share a skill with Super Breaker, so needs special treatment @@ -67,7 +75,8 @@ public enum SuperAbilityType { null, "Mining.Blast.Other.On", "Mining.Blast.Refresh", - null), + null, + "Mining.SubSkill.BlastMining.Name"), ; /* @@ -91,13 +100,15 @@ public enum SuperAbilityType { private final String abilityRefresh; private final String abilityPlayerOff; private SubSkillType subSkillTypeDefinition; + private final String localizedName; - SuperAbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) { + SuperAbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff, String localizedName) { this.abilityOn = abilityOn; this.abilityOff = abilityOff; this.abilityPlayer = abilityPlayer; this.abilityRefresh = abilityRefresh; this.abilityPlayerOff = abilityPlayerOff; + this.localizedName = localizedName; } public int getCooldown() { @@ -132,6 +143,10 @@ public enum SuperAbilityType { return StringUtils.getPrettyAbilityString(this); } + public String getLocalizedName() { + return LocaleLoader.getString(localizedName); + } + @Override public String toString() { String baseString = name(); diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java index 7e5aa65b5..0bce7f5b5 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -90,10 +90,10 @@ public class ScoreboardManager { skillLabelBuilder.put(type, getShortenedName(colors.get(i) + type.getName(), false)); if (type.getAbility() != null) { - abilityLabelBuilder.put(type.getAbility(), getShortenedName(colors.get(i) + type.getAbility().getName())); + abilityLabelBuilder.put(type.getAbility(), getShortenedName(colors.get(i) + type.getAbility().getLocalizedName())); if (type == PrimarySkillType.MINING) { - abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, getShortenedName(colors.get(i) + SuperAbilityType.BLAST_MINING.getName())); + abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, getShortenedName(colors.get(i) + SuperAbilityType.BLAST_MINING.getLocalizedName())); } } @@ -112,17 +112,17 @@ public class ScoreboardManager { skillLabelBuilder.put(type, getShortenedName(ChatColor.GREEN + type.getName())); if (type.getAbility() != null) { - abilityLabelBuilder.put(type.getAbility(), formatAbility(type.getAbility().getName())); + abilityLabelBuilder.put(type.getAbility(), formatAbility(type.getAbility().getLocalizedName())); if (type == PrimarySkillType.MINING) { - abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, formatAbility(SuperAbilityType.BLAST_MINING.getName())); + abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, formatAbility(SuperAbilityType.BLAST_MINING.getLocalizedName())); } } } } for (SuperAbilityType type : SuperAbilityType.values()) { - abilityLabelSkillBuilder.put(type, formatAbility((type == SuperAbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA), type.getName())); + abilityLabelSkillBuilder.put(type, formatAbility((type == SuperAbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA), type.getLocalizedName())); } skillLabels = skillLabelBuilder.build();