Class LocaleAPI
java.lang.Object
net.joseplay.allianceutils.api.locale.LocaleAPI
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns all translation keys available in a locale.static @NotNull StringGets localized biome name.static @Nullable StringgetCustomValue(@NotNull String key, @NotNull Locale locale) Retrieves a custom value from the locale file.static @NotNull StringgetEffect(org.bukkit.potion.PotionEffectType effect) Shortcut using default locale (pt_br).static @NotNull StringGets the localized name of a potion effect.static @NotNull StringgetEnchantment(org.bukkit.enchantments.Enchantment enchantment) Shortcut using default locale (pt_br).static @NotNull StringgetEnchantment(org.bukkit.enchantments.Enchantment enchantment, Locale locale) Gets localized enchantment name.static @NotNull StringgetEntity(org.bukkit.entity.EntityType type) Shortcut using default locale (pt_br).static @NotNull StringGets localized entity name.static net.joseplay.allianceutils.api.locale.LocaleReadergetLocaleReader(Locale locale) Retrieves or creates a cached LocaleReader.static @NotNull StringgetMaterial(@NotNull Locale locale, @NotNull org.bukkit.Material mat) Gets localized material name.static @NotNull StringgetMaterial(@NotNull org.bukkit.Material mat) Shortcut using default locale (pt_br).
-
Field Details
-
CACHE
Cache of loaded locale readers. Key: Locale Value: LocaleReader instance Side effects: - Grows over time (no eviction strategy)
-
-
Constructor Details
-
LocaleAPI
public LocaleAPI()
-
-
Method Details
-
getCustomValue
@Nullable public static @Nullable String getCustomValue(@NotNull @NotNull String key, @NotNull @NotNull Locale locale) Retrieves a custom value from the locale file. Use when: - Accessing arbitrary translation keys Avoid when: - You need strict guarantees (can return null)- Parameters:
key- translation keylocale- target locale- Returns:
- translated value or null if not found
-
getEffect
@NotNull public static @NotNull String getEffect(org.bukkit.potion.PotionEffectType effect, Locale locale) Gets the localized name of a potion effect. Side effects: - Depends on Minecraft translation key format- Parameters:
effect- potion effectlocale- locale- Returns:
- localized name
-
getEffect
Shortcut using default locale (pt_br). -
getEntity
Gets localized entity name.- Parameters:
type- entity typelocale- locale- Returns:
- localized name
-
getEntity
Shortcut using default locale (pt_br). -
getAllKey
Returns all translation keys available in a locale. Use when: - Debugging or listing available translations Side effects: - Returns internal data (should be immutable from reader)- Parameters:
locale- target locale- Returns:
- list of keys
-
getBiome
@NotNull public static @NotNull String getBiome(@NotNull @NotNull Locale locale, @NotNull @NotNull org.bukkit.block.Biome biome) Gets localized biome name. Special case: - "custom" biome returns hardcoded value- Parameters:
locale- localebiome- biome- Returns:
- localized name
-
getEnchantment
@NotNull public static @NotNull String getEnchantment(org.bukkit.enchantments.Enchantment enchantment) Shortcut using default locale (pt_br). -
getEnchantment
@NotNull public static @NotNull String getEnchantment(org.bukkit.enchantments.Enchantment enchantment, Locale locale) Gets localized enchantment name.- Parameters:
enchantment- enchantmentlocale- locale- Returns:
- localized name
-
getMaterial
Shortcut using default locale (pt_br). -
getMaterial
@NotNull public static @NotNull String getMaterial(@NotNull @NotNull Locale locale, @NotNull @NotNull org.bukkit.Material mat) Gets localized material name. Behavior: - Automatically detects block vs item - Removes "wall_" prefix (Minecraft inconsistency workaround) Side effects: - Relies on naming conventions from Mojang- Parameters:
locale- localemat- material- Returns:
- localized name
-
getLocaleReader
Retrieves or creates a cached LocaleReader. Use when: - Accessing locale data repeatedly Side effects: - Caches reader permanently (no cleanup)- Parameters:
locale- locale- Returns:
- cached reader
-