Fixing SuperAbility strings

This commit is contained in:
nossr50 2019-09-30 16:11:06 -07:00
parent 4437f419cb
commit d2028321d4
5 changed files with 39 additions and 18 deletions

View File

@ -929,11 +929,11 @@ public class McMMOPlayer {
} }
if (useChatNotifications()) { if (useChatNotifications()) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUPER_ABILITY, pluginRef.getSkillTools().getSuperAbilityOn(superAbility)); pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUPER_ABILITY, pluginRef.getSkillTools().getSuperAbilityOnLocaleKey(superAbility));
} }
pluginRef.getSkillTools().sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, pluginRef.getSkillTools().sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS,
pluginRef.getSkillTools().getSuperAbilityOtherPlayerActivationStr(superAbility)); pluginRef.getSkillTools().getSuperAbilityOtherPlayerActivationLocaleKey(superAbility));
//Sounds //Sounds
pluginRef.getSoundManager().worldSendSound(player.getWorld(), player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC); pluginRef.getSoundManager().worldSendSound(player.getWorld(), player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC);

View File

@ -25,7 +25,7 @@ public class AbilityCooldownTask extends BukkitRunnable {
mcMMOPlayer.setAbilityInformed(superAbilityType, true); mcMMOPlayer.setAbilityInformed(superAbilityType, true);
pluginRef.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.ABILITY_REFRESHED, pluginRef.getSkillTools().getSuperAbilityRefreshedStr(superAbilityType)); pluginRef.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.ABILITY_REFRESHED, pluginRef.getSkillTools().getSuperAbilityRefreshedLocaleKey(superAbilityType));
//mcMMOPlayer.getPlayer().sendMessage(ability.getAbilityRefresh()); //mcMMOPlayer.getPlayer().sendMessage(ability.getAbilityRefresh());
} }
} }

View File

@ -50,12 +50,12 @@ public class AbilityDisableTask extends BukkitRunnable {
if (mcMMOPlayer.useChatNotifications()) { if (mcMMOPlayer.useChatNotifications()) {
//player.sendMessage(ability.getAbilityOff()); //player.sendMessage(ability.getAbilityOff());
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_OFF, pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_OFF,
pluginRef.getSkillTools().getSuperAbilityOff(superAbilityType)); pluginRef.getSkillTools().getSuperAbilityOffLocaleKey(superAbilityType));
} }
pluginRef.getSkillTools().sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, pluginRef.getSkillTools().sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS,
pluginRef.getSkillTools().getSuperAbilityOtherPlayerDeactivationStr(superAbilityType)); pluginRef.getSkillTools().getSuperAbilityOtherPlayerDeactivationLocaleKey(superAbilityType));
new AbilityCooldownTask(pluginRef, mcMMOPlayer, superAbilityType).runTaskLater(pluginRef, new AbilityCooldownTask(pluginRef, mcMMOPlayer, superAbilityType).runTaskLater(pluginRef,
pluginRef.getPerkUtils().handleCooldownPerks(player, pluginRef.getPerkUtils().handleCooldownPerks(player,
pluginRef.getSkillTools().getSuperAbilityCooldown(superAbilityType) * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR)); pluginRef.getSkillTools().getSuperAbilityCooldown(superAbilityType) * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR));

View File

@ -37,7 +37,7 @@ public class StringUtils {
return createPrettyString(entity.toString()); return createPrettyString(entity.toString());
} }
public static String getPrettyAbilityString(SuperAbilityType ability) { public static String getPrettySuperAbilityString(SuperAbilityType ability) {
return createPrettyString(ability.toString()); return createPrettyString(ability.toString());
} }
@ -86,6 +86,24 @@ public class StringUtils {
return createPrettyString(partyFeature.toString()); return createPrettyString(partyFeature.toString());
} }
public static String convertToCamelCaseString(String baseString, String splitBy) {
String[] substrings = baseString.split(splitBy);
String prettyString = "";
int size = 1;
for (String string : substrings) {
prettyString = prettyString.concat(getCapitalized(string));
if (size < substrings.length) {
prettyString = prettyString.concat("");
}
size++;
}
return prettyString;
}
private static String createPrettyString(String baseString) { private static String createPrettyString(String baseString) {
String[] substrings = baseString.split("_"); String[] substrings = baseString.split("_");
String prettyString = ""; String prettyString = "";

View File

@ -770,31 +770,34 @@ public class SkillTools {
return pluginRef.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(pluginRef, superAbilityType); return pluginRef.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(pluginRef, superAbilityType);
} }
public String getSuperAbilityOn(SuperAbilityType superAbilityType) { public String getSuperAbilityOnLocaleKey(SuperAbilityType superAbilityType) {
return pluginRef.getLocaleManager().getString("SuperAbility." + superAbilityType.toString() + ".On"); return "SuperAbility." + getPrettyCamelCaseName(superAbilityType) + ".On";
} }
public String getSuperAbilityOff(SuperAbilityType superAbilityType) { public String getSuperAbilityOffLocaleKey(SuperAbilityType superAbilityType) {
return pluginRef.getLocaleManager().getString("SuperAbility." + superAbilityType.toString() + ".Off"); return "SuperAbility." + getPrettyCamelCaseName(superAbilityType) + ".Off";
} }
public String getSuperAbilityOtherPlayerActivationStr(SuperAbilityType superAbilityType) { public String getSuperAbilityOtherPlayerActivationLocaleKey(SuperAbilityType superAbilityType) {
return pluginRef.getLocaleManager().getString("SuperAbility." + superAbilityType.toString() + ".Other.On"); return "SuperAbility." + getPrettyCamelCaseName(superAbilityType) + ".Other.On";
} }
public String getSuperAbilityOtherPlayerDeactivationStr(SuperAbilityType superAbilityType) { public String getSuperAbilityOtherPlayerDeactivationLocaleKey(SuperAbilityType superAbilityType) {
return pluginRef.getLocaleManager().getString("SuperAbility." + superAbilityType.toString() + "Other.Off"); return "SuperAbility." + getPrettyCamelCaseName(superAbilityType) + "Other.Off";
} }
public String getSuperAbilityRefreshedStr(SuperAbilityType superAbilityType) { public String getSuperAbilityRefreshedLocaleKey(SuperAbilityType superAbilityType) {
return pluginRef.getLocaleManager().getString("SuperAbility." + superAbilityType.toString() + ".Refresh"); return "SuperAbility." + getPrettyCamelCaseName(superAbilityType) + ".Refresh";
}
public String getPrettyCamelCaseName(Enum en) {
return StringUtils.convertToCamelCaseString(en.toString(), "_");
} }
public String getPrettySuperAbilityName(SuperAbilityType superAbilityType) { public String getPrettySuperAbilityName(SuperAbilityType superAbilityType) {
return StringUtils.getPrettyAbilityString(superAbilityType); return StringUtils.getPrettySuperAbilityString(superAbilityType);
} }
/** /**
* Get the permissions for this ability. * Get the permissions for this ability.
* *