Class LocaleAPI

java.lang.Object
net.joseplay.allianceutils.api.locale.LocaleAPI

public class LocaleAPI extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static Map<Locale,net.joseplay.allianceutils.api.locale.LocaleReader>
    Cache of loaded locale readers.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull List<String>
    getAllKey(@NotNull Locale locale)
    Returns all translation keys available in a locale.
    static @NotNull String
    getBiome(@NotNull Locale locale, @NotNull org.bukkit.block.Biome biome)
    Gets localized biome name.
    static @Nullable String
    getCustomValue(@NotNull String key, @NotNull Locale locale)
    Retrieves a custom value from the locale file.
    static @NotNull String
    getEffect(org.bukkit.potion.PotionEffectType effect)
    Shortcut using default locale (pt_br).
    static @NotNull String
    getEffect(org.bukkit.potion.PotionEffectType effect, Locale locale)
    Gets the localized name of a potion effect.
    static @NotNull String
    getEnchantment(org.bukkit.enchantments.Enchantment enchantment)
    Shortcut using default locale (pt_br).
    static @NotNull String
    getEnchantment(org.bukkit.enchantments.Enchantment enchantment, Locale locale)
    Gets localized enchantment name.
    static @NotNull String
    getEntity(org.bukkit.entity.EntityType type)
    Shortcut using default locale (pt_br).
    static @NotNull String
    getEntity(org.bukkit.entity.EntityType type, Locale locale)
    Gets localized entity name.
    static net.joseplay.allianceutils.api.locale.LocaleReader
    Retrieves or creates a cached LocaleReader.
    static @NotNull String
    getMaterial(@NotNull Locale locale, @NotNull org.bukkit.Material mat)
    Gets localized material name.
    static @NotNull String
    getMaterial(@NotNull org.bukkit.Material mat)
    Shortcut using default locale (pt_br).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CACHE

      protected static Map<Locale,net.joseplay.allianceutils.api.locale.LocaleReader> 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 key
      locale - 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 effect
      locale - locale
      Returns:
      localized name
    • getEffect

      @NotNull public static @NotNull String getEffect(org.bukkit.potion.PotionEffectType effect)
      Shortcut using default locale (pt_br).
    • getEntity

      @NotNull public static @NotNull String getEntity(org.bukkit.entity.EntityType type, Locale locale)
      Gets localized entity name.
      Parameters:
      type - entity type
      locale - locale
      Returns:
      localized name
    • getEntity

      @NotNull public static @NotNull String getEntity(org.bukkit.entity.EntityType type)
      Shortcut using default locale (pt_br).
    • getAllKey

      @NotNull public static @NotNull List<String> getAllKey(@NotNull @NotNull Locale locale)
      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 - locale
      biome - 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 - enchantment
      locale - locale
      Returns:
      localized name
    • getMaterial

      @NotNull public static @NotNull String getMaterial(@NotNull @NotNull org.bukkit.Material mat)
      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 - locale
      mat - material
      Returns:
      localized name
    • getLocaleReader

      public static net.joseplay.allianceutils.api.locale.LocaleReader getLocaleReader(Locale locale)
      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