Package net.kyori.moonshine.message
Record Class StringMessageRenderer<R,I,O,F>
java.lang.Object
java.lang.Record
net.kyori.moonshine.message.StringMessageRenderer<R,I,O,F>
- All Implemented Interfaces:
net.kyori.moonshine.message.IMessageRenderer<R,
I, O, F>
public record StringMessageRenderer<R,I,O,F> (String prefix, String suffix, Function<I,String> intermediateToStringConverter, Function<String,O> stringToOutputConverter, Function<F,String> placeholderValueToStringConverter)
extends Record
implements net.kyori.moonshine.message.IMessageRenderer<R,I,O,F>
A standard formatter for strings using
String.replace(CharSequence, CharSequence)
with
"${prefix}${value}${suffix}"
where value
is converted using placeholderValueToStringConverter
.
Most people will want a more advanced formatter for Discord messages/embeds, Minecraft component messages, etc.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.Returns the value of theintermediateToStringConverter
record component.Returns the value of theplaceholderValueToStringConverter
record component.prefix()
Returns the value of theprefix
record component.render
(R receiver, I intermediateMessage, Map<String, ? extends F> resolvedPlaceholders, Method method, Type owner) Returns the value of thestringToOutputConverter
record component.suffix()
Returns the value of thesuffix
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
StringMessageRenderer
public StringMessageRenderer(String prefix, String suffix, Function<I, String> intermediateToStringConverter, Function<String, O> stringToOutputConverter, Function<F, String> placeholderValueToStringConverter) Creates an instance of aStringMessageRenderer
record class.- Parameters:
prefix
- the value for theprefix
record componentsuffix
- the value for thesuffix
record componentintermediateToStringConverter
- the value for theintermediateToStringConverter
record componentstringToOutputConverter
- the value for thestringToOutputConverter
record componentplaceholderValueToStringConverter
- the value for theplaceholderValueToStringConverter
record component
-
-
Method Details
-
render
-
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)
. -
prefix
Returns the value of theprefix
record component.- Returns:
- the value of the
prefix
record component
-
suffix
Returns the value of thesuffix
record component.- Returns:
- the value of the
suffix
record component
-
intermediateToStringConverter
Returns the value of theintermediateToStringConverter
record component.- Returns:
- the value of the
intermediateToStringConverter
record component
-
stringToOutputConverter
Returns the value of thestringToOutputConverter
record component.- Returns:
- the value of the
stringToOutputConverter
record component
-
placeholderValueToStringConverter
Returns the value of theplaceholderValueToStringConverter
record component.- Returns:
- the value of the
placeholderValueToStringConverter
record component
-