Package dev.chicoferreira.lifestealer
Record Class PlayerNotification
java.lang.Object
java.lang.Record
dev.chicoferreira.lifestealer.PlayerNotification
- Record Components:
textMessage- the text message to send to the playeractionBarMessage- the action bar message to send to the playertitleMessage- the title message to send to the playersubtitleMessage- the subtitle message to send to the playertitleTimes- the title timings to send to the playersound- the sound to play to the player
public record PlayerNotification(@NotNull Optional<String> textMessage, @NotNull Optional<String> actionBarMessage, @NotNull Optional<String> titleMessage, @NotNull Optional<String> subtitleMessage, @NotNull Optional<net.kyori.adventure.title.Title.Times> titleTimes, @NotNull Optional<net.kyori.adventure.sound.Sound> sound, @NotNull Optional<com.destroystokyo.paper.ParticleBuilder> particle)
extends Record
Represents a notification that can be sent to a player.
A notification is sent when a command is executed, when the player consumes a heart, etc.
The message components are stored as string and are parsed using the adventure-api mini-message format when the message is sent, so it's possible to use the native placeholders of the adventure-api.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic BiFunction<org.bukkit.command.CommandSender, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver> Additional tag resolvers to apply to the messages.static final net.kyori.adventure.text.minimessage.MiniMessage -
Constructor Summary
ConstructorsConstructorDescriptionPlayerNotification(String textMessage) Creates player notification with a text message.PlayerNotification(@NotNull Optional<String> textMessage, @NotNull Optional<String> actionBarMessage, @NotNull Optional<String> titleMessage, @NotNull Optional<String> subtitleMessage, @NotNull Optional<net.kyori.adventure.title.Title.Times> titleTimes, @NotNull Optional<net.kyori.adventure.sound.Sound> sound, @NotNull Optional<com.destroystokyo.paper.ParticleBuilder> particle) Creates an instance of aPlayerNotificationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theactionBarMessagerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull Optional<com.destroystokyo.paper.ParticleBuilder> particle()Returns the value of theparticlerecord component.@NotNull Optional<net.kyori.adventure.sound.Sound> sound()Returns the value of thesoundrecord component.Returns the value of thesubtitleMessagerecord component.Returns the value of thetextMessagerecord component.Returns the value of thetitleMessagerecord component.@NotNull Optional<net.kyori.adventure.title.Title.Times> Returns the value of thetitleTimesrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
MINI_MESSAGE
public static final net.kyori.adventure.text.minimessage.MiniMessage MINI_MESSAGE -
ADDITIONAL_RESOLVERS
public static BiFunction<org.bukkit.command.CommandSender,net.kyori.adventure.text.minimessage.tag.resolver.TagResolver, ADDITIONAL_RESOLVERSnet.kyori.adventure.text.minimessage.tag.resolver.TagResolver> Additional tag resolvers to apply to the messages. Used in main class to add custom resolvers (for example, parsing PAPI placeholders).
-
-
Constructor Details
-
PlayerNotification
Creates player notification with a text message.- Parameters:
textMessage- the text message to send to the player
-
PlayerNotification
public PlayerNotification(@NotNull @NotNull Optional<String> textMessage, @NotNull @NotNull Optional<String> actionBarMessage, @NotNull @NotNull Optional<String> titleMessage, @NotNull @NotNull Optional<String> subtitleMessage, @NotNull @NotNull Optional<net.kyori.adventure.title.Title.Times> titleTimes, @NotNull @NotNull Optional<net.kyori.adventure.sound.Sound> sound, @NotNull @NotNull Optional<com.destroystokyo.paper.ParticleBuilder> particle) Creates an instance of aPlayerNotificationrecord class.- Parameters:
textMessage- the value for thetextMessagerecord componentactionBarMessage- the value for theactionBarMessagerecord componenttitleMessage- the value for thetitleMessagerecord componentsubtitleMessage- the value for thesubtitleMessagerecord componenttitleTimes- the value for thetitleTimesrecord componentsound- the value for thesoundrecord componentparticle- the value for theparticlerecord component
-
-
Method Details
-
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). -
textMessage
Returns the value of thetextMessagerecord component.- Returns:
- the value of the
textMessagerecord component
-
actionBarMessage
Returns the value of theactionBarMessagerecord component.- Returns:
- the value of the
actionBarMessagerecord component
-
titleMessage
Returns the value of thetitleMessagerecord component.- Returns:
- the value of the
titleMessagerecord component
-
subtitleMessage
Returns the value of thesubtitleMessagerecord component.- Returns:
- the value of the
subtitleMessagerecord component
-
titleTimes
Returns the value of thetitleTimesrecord component.- Returns:
- the value of the
titleTimesrecord component
-
sound
Returns the value of thesoundrecord component.- Returns:
- the value of the
soundrecord component
-
particle
Returns the value of theparticlerecord component.- Returns:
- the value of the
particlerecord component
-