Package one.tranic.t.base.message
Class Message
java.lang.Object
one.tranic.t.base.message.Message
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetMessage(Object key) Retrieves the message associated with the provided key from the internal messages map.static MessageImplRetrieves the map of messages associated with their respective keys.Retrieves a list of supported locales.booleanisSupportedLocale(Locale locale) Checks if the specified locale is supported.static voidloadAllMessage(@NotNull Object object) booleanregisterLocale(Locale locale) Registers a new locale to the list of supported locales.static voidvoidClears all the messages stored in the internal messages map.voidClears all currently supported locales from the list of registered locales.static voidsetMessage(Object key, String message) Sets a message for the given key.static voidsetMessageImpl(MessageImpl messageImpl) static net.md_5.bungee.api.chat.BaseComponent[]toBaseComponent(@NotNull String message) Converts a legacy text string into an array of BaseComponent objects.static net.md_5.bungee.api.chat.BaseComponent[]toBaseComponent(@NotNull net.kyori.adventure.text.Component component) Converts aComponentto an array ofBaseComponent.static StringtoString(@NotNull net.kyori.adventure.text.Component component) Converts aComponentinto its string representation using the legacy section serialization format.
-
Constructor Details
-
Message
public Message()
-
-
Method Details
-
getMessageImpl
-
setMessageImpl
-
getMessages
Retrieves the map of messages associated with their respective keys.- Returns:
- a map where the keys are of type T and the values are message strings
-
getSupportedLocales
Retrieves a list of supported locales.- Returns:
- a list of
Localeobjects representing the supported locales
-
setMessage
Sets a message for the given key.- Parameters:
key- the key associated with the message; must not be nullmessage- the message to be associated with the key; must not be null
-
getMessage
Retrieves the message associated with the provided key from the internal messages map.- Parameters:
key- the key whose associated message is to be retrieved; must not be null- Returns:
- the message string associated with the specified key, or null if no message is found
-
loadAllMessage
-
reloadMessages
public static void reloadMessages() -
toString
Converts aComponentinto its string representation using the legacy section serialization format.- Parameters:
component- theComponentto be serialized; must not be null- Returns:
- the serialized string representation of the given
Component
-
toBaseComponent
public static net.md_5.bungee.api.chat.BaseComponent[] toBaseComponent(@NotNull @NotNull String message) Converts a legacy text string into an array of BaseComponent objects. If the current platform is not BungeeCord, the method returns null.- Parameters:
message- the legacy text string to be converted; must not be null- Returns:
- an array of BaseComponent objects representing the converted text, or null if the platform is not BungeeCord
-
toBaseComponent
public static net.md_5.bungee.api.chat.BaseComponent[] toBaseComponent(@NotNull @NotNull net.kyori.adventure.text.Component component) Converts aComponentto an array ofBaseComponent.This method leverages the
toString(Component)method to serialize the inputComponentinto a legacy string format and then transforms it into BungeeCord'sComponentarray representation.- Parameters:
component- TheComponentto be converted. Must not be null.- Returns:
- An array of
BaseComponentrepresenting the providedComponent, or null if a non-BungeeCord platform is detected.
-
registerLocale
Registers a new locale to the list of supported locales.- Parameters:
locale- the locale to be registered; must not be null- Returns:
- true if the locale was successfully added to the list of supported locales, false if the locale is already present in the list
-
isSupportedLocale
Checks if the specified locale is supported.- Parameters:
locale- theLocaleto be checked; must not be null- Returns:
trueif the specified locale is supported,falseotherwise
-
resetMessages
public void resetMessages()Clears all the messages stored in the internal messages map.This method removes all key-value pairs from the map used to store messages, effectively resetting it to an empty state. It is typically used when a fresh start or reloading of messages is required.
-
resetSupportedLocales
public void resetSupportedLocales()Clears all currently supported locales from the list of registered locales. This method effectively resets the state of supported locales by removing all previously added entries from the internal list.It is useful in scenarios where a complete reconfiguration or reset of supported locales is required.
-