Package net.realdarkstudios.commons.util
Record Class LocalizedMessages.Key
java.lang.Object
java.lang.Record
net.realdarkstudios.commons.util.LocalizedMessages.Key
- Record Components:
localization- TheLocalizationthis key will usepath- The path of the key (such as "plugin.update.fail")styleOptions- TheLocalizedMessages.StyleOptionsthis key will use
- Enclosing class:
- LocalizedMessages
public static record LocalizedMessages.Key(Localization localization, String path, LocalizedMessages.StyleOptions styleOptions)
extends Record
Creates a new Localization Message Key
- Since:
- 0.3.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionKey(Localization localization, String path, LocalizedMessages.StyleOptions styleOptions) Creates an instance of aKeyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionA dedicated version oftranslateComponent(Object...)that removes all formatting codes from the outputconsoleWithPrefix(boolean withPrefix, Object... formatArgs) final booleanIndicates whether some other object is "equal to" this one.Returns the localization that this key will usegetMessage(Object... formatArgs) Gets the messagegetPath()Returns the path inside the localization this key usesnet.md_5.bungee.api.chat.TextComponentGets the raw message (no formatting)Returns this key's style optionsfinal inthashCode()Returns a hash code value for this object.Returns the value of thelocalizationrecord component.booleanChecks if theLocalizationhas this path in itpath()Returns the value of thepathrecord component.Returns the value of thestyleOptionsrecord component.final StringtoString()Returns a string representation of this record class.Translates thisLocalizedMessages.Keyinto a stringnet.md_5.bungee.api.chat.TextComponenttranslateComponent(Object... formatArgs) Translates thisLocalizedMessages.Keyinto a TextComponentnet.md_5.bungee.api.chat.TextComponenttranslateComponentWithOtherStyle(LocalizedMessages.StyleOptions styleOptions, Object... formatArgs) Translates thisLocalizedMessages.Keyinto a TextComponent with differentLocalizedMessages.StyleOptionsnet.md_5.bungee.api.chat.TextComponenttranslateComponentWithPrefix(boolean withPrefix, Object... formatArgs) Translates thisLocalizedMessages.Keyinto a TextComponenttranslateWithOtherStyle(LocalizedMessages.StyleOptions styleOptions, Object... formatArgs) Translates thisLocalizedMessages.Keyinto a string with differentLocalizedMessages.StyleOptions
-
Constructor Details
-
Key
Creates an instance of aKeyrecord class.- Parameters:
localization- the value for thelocalizationrecord componentpath- the value for thepathrecord componentstyleOptions- the value for thestyleOptionsrecord component
-
-
Method Details
-
getLocalization
Returns the localization that this key will use- Returns:
- The
Localizationof this key
-
getPath
Returns the path inside the localization this key uses- Returns:
- The path of this key
-
getStyleOptions
Returns this key's style options- Returns:
- The
LocalizedMessages.StyleOptionsof this key
-
getRawMessage
Gets the raw message (no formatting)- Returns:
- The raw message
- Since:
- 0.3.1.0
-
getMessage
Gets the message- Parameters:
formatArgs- The format arguments- Returns:
- The message
- Since:
- 0.3.1.0
-
getPrefix
public net.md_5.bungee.api.chat.TextComponent getPrefix() -
translateComponent
Translates thisLocalizedMessages.Keyinto a TextComponent- Parameters:
formatArgs- The format arguments- Returns:
- The translated
TextComponent - Since:
- 0.3.1.0
-
translateComponentWithPrefix
public net.md_5.bungee.api.chat.TextComponent translateComponentWithPrefix(boolean withPrefix, Object... formatArgs) Translates thisLocalizedMessages.Keyinto a TextComponent- Parameters:
formatArgs- The format arguments- Returns:
- The translated
TextComponent - Since:
- 0.3.1.0
-
translate
Translates thisLocalizedMessages.Keyinto a string- Parameters:
formatArgs- The format arguments- Returns:
- The translated string
- Since:
- 0.3.1.0
-
translateComponentWithOtherStyle
public net.md_5.bungee.api.chat.TextComponent translateComponentWithOtherStyle(LocalizedMessages.StyleOptions styleOptions, Object... formatArgs) Translates thisLocalizedMessages.Keyinto a TextComponent with differentLocalizedMessages.StyleOptions- Parameters:
styleOptions- The overridingLocalizedMessages.StyleOptionsformatArgs- The format arguments- Returns:
- The translated
TextComponent - Since:
- 0.3.1.0
-
translateWithOtherStyle
public String translateWithOtherStyle(LocalizedMessages.StyleOptions styleOptions, Object... formatArgs) Translates thisLocalizedMessages.Keyinto a string with differentLocalizedMessages.StyleOptions- Parameters:
styleOptions- The overridingLocalizedMessages.StyleOptionsformatArgs- The format arguments- Returns:
- The translated string
- Since:
- 0.3.1.0
-
console
A dedicated version oftranslateComponent(Object...)that removes all formatting codes from the output- Parameters:
formatArgs- The format arguments- Returns:
- The translated string
- Since:
- 0.3.1.0
-
consoleWithPrefix
-
localizationHasPath
public boolean localizationHasPath()Checks if theLocalizationhas this path in it- Returns:
trueif the localization has the path,falseotherwise- Since:
- 0.3.1.0
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
localization
Returns the value of thelocalizationrecord component.- Returns:
- the value of the
localizationrecord component
-
path
Returns the value of thepathrecord component.- Returns:
- the value of the
pathrecord component
-
styleOptions
Returns the value of thestyleOptionsrecord component.- Returns:
- the value of the
styleOptionsrecord component
-