Class BungeeLoader

java.lang.Object
one.tranic.t.i18n.BaseLoader
one.tranic.t.i18n.BungeeLoader

public class BungeeLoader extends BaseLoader
  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class BaseLoader
    • toBaseComponent

      @NotNull public @NotNull net.md_5.bungee.api.chat.BaseComponent[] toBaseComponent(@NotNull @NotNull String key)
      Converts a localized string corresponding to the given key into an array of BaseComponent objects.
      Parameters:
      key - the translation key used to fetch the corresponding localized string
      Returns:
      an array of BaseComponent objects representing the localized string, or the key itself as BaseComponents if no translation exists
    • toBaseComponent

      @NotNull public @NotNull net.md_5.bungee.api.chat.BaseComponent[] toBaseComponent(@NotNull @NotNull String key, @NotNull @NotNull Object... args)
      Converts a translation key and its formatted arguments into an array of BaseComponent.

      The format follows printf-style format strings, for example:

       "Hello %s" with arg "world" produces "Hello world"
       "%d items" with arg 5 produces "5 items"
       "Rate: %.2f" with arg 0.123 produces "Rate: 0.12"
       
      Parameters:
      key - the translation key used to fetch the corresponding localized string
      args - the arguments to format the localized string
      Returns:
      an array of BaseComponent representing the localized and formatted text
    • toBaseComponentBrace

      @NotNull public @NotNull net.md_5.bungee.api.chat.BaseComponent[] toBaseComponentBrace(@NotNull @NotNull String key, @NotNull @NotNull Object... args)
      Converts a localized and formatted string with placeholders replaced by the provided arguments into an array of BaseComponent.

      For example:

       "{} items in {}" with args ["5", "cart"] produces "5 items in cart"
       "Hello {}" with arg "world" produces "Hello world"
       "Rate: {}" with arg "0.12" produces "Rate: 0.12"
       
      Parameters:
      key - the translation key used to fetch the corresponding localized string
      args - the arguments to replace the "{}" placeholders within the localized string
      Returns:
      an array of BaseComponent representing the processed localized string
    • toBaseComponentBrace

      @NotNull public @NotNull net.md_5.bungee.api.chat.BaseComponent[] toBaseComponentBrace(@NotNull @NotNull String key, @NotNull @NotNull BaseLoader.SimpleComponent... args)
      Converts the provided key and arguments into an array of BaseComponent objects using a legacy text format with braces.

      For example:

       "{b1} items in {b2}" with args {"b1": "5", "b2", "cart"} produces "5 items in cart"
       "Hello {b1}" with arg {"b1", "world"} produces "Hello world"
       "Rate: {b1}" with arg {"b1", 0.12} produces "Rate: 0.12"
       
      Parameters:
      key - the key to be formatted, must not be null
      args - the array of SimpleComponent arguments to format, must not be null
      Returns:
      an array of BaseComponent objects representing the formatted text