Class ServerTranslator
java.lang.Object
com.github.darksoulq.abyssallib.server.translation.ServerTranslator
Utility class for managing server-side component translations and MiniMessage parsing.
This system decouples entirely from Adventure's standard GlobalTranslator to avert Server-Side Rendering conflicts. It manually resolves formatting indexes, nested localized tags, and custom item-specific components prior to evaluating the raw string through the overarching MiniMessage implementation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.github.darksoulq.abyssallib.server.translation.internal.CustomTranslatorReturns the master translation interface acting as fundamental repository controlling formatting operations.static voidinit()Initializes the server translation module and invokes the primary language loading sequence.static voidIntegrates raw translation properties parsed strictly from externally registered storage allocations.static voidloadResource(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull String resourcePath) Incorporates raw property details derived inherently from a specific compiled project resource payload.static voidregisterGlobalProvider(@NotNull GlobalTranslationProvider provider) Registers a global translation provider empowering dynamic resolution of component keys system-wide.static voidregisterGlobalResolver(@NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver resolver) Registers a global TagResolver that will be applied to all translated components.static voidregisterItemProvider(@NotNull ItemTranslationProvider provider) Registers a custom item translation provider empowering dynamic resolution of item-bound translatable component keys.static voidreload()Reloads all active translation configurations traversing registered system files and internally bundled plugin resources.static net.kyori.adventure.text.Componentrender(@NotNull String key, @Nullable org.bukkit.entity.Player player, @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... extraResolvers) Instigates singular execution interpreting unique translation targets directly avoiding generalized component generation.static net.kyori.adventure.text.ComponentTranslates a provided raw component directly utilizing the specified system locale.static net.kyori.adventure.text.Componenttranslate(@Nullable net.kyori.adventure.text.Component component, @Nullable org.bukkit.entity.Player player) Translates a provided raw component adapting directly to an observing player's locale and placeholder contexts.static net.kyori.adventure.text.ComponenttranslateItemComponent(@Nullable net.kyori.adventure.text.Component component, @Nullable org.bukkit.entity.Player player, @NotNull org.bukkit.inventory.ItemStack item, @NotNull ItemTranslationContext context) Contextually evaluates an item's specific translatable component conditionally applying registered item translation providers.
-
Constructor Details
-
ServerTranslator
public ServerTranslator()
-
-
Method Details
-
init
public static void init()Initializes the server translation module and invokes the primary language loading sequence. -
reload
public static void reload()Reloads all active translation configurations traversing registered system files and internally bundled plugin resources. -
registerItemProvider
Registers a custom item translation provider empowering dynamic resolution of item-bound translatable component keys.- Parameters:
provider- The provider implementation added to the internal resolution registry.
-
registerGlobalProvider
Registers a global translation provider empowering dynamic resolution of component keys system-wide.- Parameters:
provider- The provider implementation added to the global resolution registry.
-
registerGlobalResolver
public static void registerGlobalResolver(@NotNull @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver resolver) Registers a global TagResolver that will be applied to all translated components.- Parameters:
resolver- The TagResolver to add to the global registry.
-
translate
public static net.kyori.adventure.text.Component translate(@Nullable @Nullable net.kyori.adventure.text.Component component, @Nullable @Nullable Locale locale) Translates a provided raw component directly utilizing the specified system locale.- Parameters:
component- The raw translatable component requiring localization resolution.locale- The language locale identifying the corresponding target dictionary entries.- Returns:
- A localized component resolving all internally mapped keys and parameters.
-
translate
public static net.kyori.adventure.text.Component translate(@Nullable @Nullable net.kyori.adventure.text.Component component, @Nullable @Nullable org.bukkit.entity.Player player) Translates a provided raw component adapting directly to an observing player's locale and placeholder contexts.- Parameters:
component- The raw translatable component requiring localization resolution.player- The viewing player whose client locale and active placeholders execute against the text.- Returns:
- A localized component resolving mapped parameters accurately assigned to the viewer.
-
translateItemComponent
public static net.kyori.adventure.text.Component translateItemComponent(@Nullable @Nullable net.kyori.adventure.text.Component component, @Nullable @Nullable org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull ItemTranslationContext context) Contextually evaluates an item's specific translatable component conditionally applying registered item translation providers.- Parameters:
component- The raw item component requiring immediate localization processing.player- The target viewer currently examining the inventory item stack.item- The interactive item stack directly associated with the specific component context.context- The specific area categorical classification rendering the component.- Returns:
- A natively localized component resolving keys distinctively relative to the encompassing item.
-
render
public static net.kyori.adventure.text.Component render(@NotNull @NotNull String key, @Nullable @Nullable org.bukkit.entity.Player player, @NotNull @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... extraResolvers) Instigates singular execution interpreting unique translation targets directly avoiding generalized component generation.- Parameters:
key- The singular translation identifier accessing active application dictionary resources.player- The viewing target allocating accurate visual logic placeholders against variables.extraResolvers- Sequential array storing externally mandated resolution mappings executed during translation.- Returns:
- Formatted static text structure mirroring underlying system configurations effectively.
-
loadFile
Integrates raw translation properties parsed strictly from externally registered storage allocations.- Parameters:
path- The operating system file target navigating specifically to the language properties.
-
loadResource
public static void loadResource(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull String resourcePath) Incorporates raw property details derived inherently from a specific compiled project resource payload.- Parameters:
plugin- The compiled java module acting as root target for path acquisition algorithms.resourcePath- The internally nested pathway mapped cleanly against the desired asset array.
-
getSource
public static com.github.darksoulq.abyssallib.server.translation.internal.CustomTranslator getSource()Returns the master translation interface acting as fundamental repository controlling formatting operations.- Returns:
- The translation structure mapped against active project variables determining overall strings.
-