Skip to content

Commit

Permalink
Fix the issues on unit test
Browse files Browse the repository at this point in the history
Complete Enchantment part
  • Loading branch information
Krasjet committed Jul 31, 2015
1 parent 69fb8f7 commit 2f4e9eb
Show file tree
Hide file tree
Showing 8 changed files with 291 additions and 267 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply plugin: 'maven-publish'

group = 'com.meowj'
archivesBaseName = 'LangUtils'
version = '1.2.0'
version = '1.3.0'

final def EULA_ACCEPT = true

Expand Down
99 changes: 60 additions & 39 deletions src/main/java/com/meowj/langutils/lang/LanguageHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static String getItemDisplayName(ItemStack item, String locale) {
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName())
return item.getItemMeta().getDisplayName();
else
return LanguageHelper.getItemName(item, locale);
return getItemName(item, locale);
}

/**
Expand Down Expand Up @@ -192,30 +192,30 @@ public static String getEntityName(EntityType entityType, Player player) {
* Return the unlocalized name of the enchantment level(Minecraft convention)
*
* @param level The enchantment level
* @return The unlocalized name.
* @return The unlocalized name.(if level is greater than 10, it will only return the number of the level)
*/
public static String getEnchantmentLevelUnlocalizedName(int level) {
EnumEnchantementLevel enumEnchLevel = EnumEnchantementLevel.get(level);
return (enumEnchLevel != null ? enumEnchLevel.getUnlocalizedName() : Integer.toString(level));
EnumEnchantmentLevel enumEnchLevel = EnumEnchantmentLevel.get(level);
return enumEnchLevel != null ? enumEnchLevel.getUnlocalizedName() : Integer.toString(level);
}

/**
* Return the unlocalized name of the enchantment level(Minecraft convention)
* Return the name of the enchantment level
*
* @param level The enchantment level
* @param level The enchantment level
* @param player The language of the level
* @return The unlocalized name.
* @return The name of the level.(if level is greater than 10, it will only return the number of the level)
*/
public static String getEnchantmentLevelName(int level, Player player) {
return translateToLocal(getEnchantmentLevelUnlocalizedName(level), LocaleHelper.getPlayerLanguage(player));
}

/**
* Return the unlocalized name of the enchantment level(Minecraft convention)
* Return the name of the enchantment level
*
* @param level The enchantment level
* @param level The enchantment level
* @param locale The language of the level
* @return The unlocalized name.
* @return The name of the level.(if level is greater than 10, it will only return the number of the level)
*/
public static String getEnchantmentLevelName(int level, String locale) {
return translateToLocal(getEnchantmentLevelUnlocalizedName(level), locale);
Expand All @@ -224,62 +224,83 @@ public static String getEnchantmentLevelName(int level, String locale) {
/**
* Return the unlocalized name of the enchantment(Minecraft convention)
*
* @param ench The enchantment
* @param enchantment The enchantment
* @return The unlocalized name.
*/
public static String getEnchantmentUnlocalizedName(Enchantment ench) {
EnumEnchantement enumEnch = EnumEnchantement.get(ench);
return (enumEnch != null ? enumEnch.getUnlocalizedName() : ench.getName());
public static String getEnchantmentUnlocalizedName(Enchantment enchantment) {
EnumEnchantment enumEnch = EnumEnchantment.get(enchantment);
return (enumEnch != null ? enumEnch.getUnlocalizedName() : enchantment.getName());
}

/**
* Return the display name of the enchantement.
* Return the name of the enchantment.
*
* @param ench The enchantment
* @param player The receiver of the name
* @return The name of the item
* @param enchantment The enchantment
* @param player The receiver of the name
* @return The name of the enchantment
*/
public static String getEnchantmentName(Enchantment ench, Player player) {
return getEnchantmentName(ench, LocaleHelper.getPlayerLanguage(player));
public static String getEnchantmentName(Enchantment enchantment, Player player) {
return getEnchantmentName(enchantment, LocaleHelper.getPlayerLanguage(player));
}

/**
* Return the display name of the item.
* Return the name of the enchantment.
*
* @param ench The enchantment
* @param locale The language of the item(if the item doesn't have a customized name, the method will return the name of the item in this language)
* @return The name of the item
* @param enchantment The enchantment
* @param locale The language of the name
* @return The name of the enchantment
*/
public static String getEnchantmentName(Enchantment ench, String locale) {
return translateToLocal(getEnchantmentUnlocalizedName(ench), locale);
public static String getEnchantmentName(Enchantment enchantment, String locale) {
return translateToLocal(getEnchantmentUnlocalizedName(enchantment), locale);
}

/**
* Return the display name of the enchantement.
* Return the display name of the enchantment(with level).
*
* @param ench The enchantment
* @param level The enchantment level
* @param player The receiver of the name
* @param enchantment The enchantment
* @param level The enchantment level
* @param player The receiver of the name
* @return The name of the item
*/
public static String getEnchantmentName(Enchantment ench, int level, Player player) {
return getEnchantmentName(ench, level, LocaleHelper.getPlayerLanguage(player));
public static String getEnchantmentDisplayName(Enchantment enchantment, int level, Player player) {
return getEnchantmentDisplayName(enchantment, level, LocaleHelper.getPlayerLanguage(player));
}

/**
* Return the display name of the item.
* Return the display name of the enchantment(with level).
*
* @param ench The enchantment
* @param level The enchantment level
* @param locale The language of the item(if the item doesn't have a customized name, the method will return the name of the item in this language)
* @param enchantment The enchantment
* @param level The enchantment level
* @param locale The language of the name
* @return The name of the item
*/
public static String getEnchantmentName(Enchantment ench, int level, String locale) {
String enchantment = getEnchantmentName(ench, locale);
public static String getEnchantmentDisplayName(Enchantment enchantment, int level, String locale) {
String name = getEnchantmentName(enchantment, locale);
String enchLevel = getEnchantmentLevelName(level, locale);
return enchantment + (enchLevel.length()>0 ? " " + enchLevel : "");
return name + (enchLevel.length() > 0 ? " " + enchLevel : "");
}

/**
* Return the display name of the enchantment(with level).
*
* @param entry The Entry of an enchantment with level The type is {@code Map.Entry<Enchantment, Integer>}
* @param locale The language of the name
* @return The name of the item
*/
public static String getEnchantmentDisplayName(Map.Entry<Enchantment, Integer> entry, String locale) {
return getEnchantmentDisplayName(entry.getKey(), entry.getValue(), locale);
}

/**
* Return the display name of the enchantment(with level).
*
* @param entry The Entry of an enchantment with level The type is {@code Map.Entry<Enchantment, Integer>}
* @param player The receiver of the name
* @return The name of the item
*/
public static String getEnchantmentDisplayName(Map.Entry<Enchantment, Integer> entry, Player player) {
return getEnchantmentDisplayName(entry.getKey(), entry.getValue(), player);
}

/**
* Translate unlocalized field to localized field.
Expand Down
107 changes: 0 additions & 107 deletions src/main/java/com/meowj/langutils/lang/convert/EnumEnchantement.java

This file was deleted.

This file was deleted.

Loading

0 comments on commit 2f4e9eb

Please sign in to comment.