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 aPlayerNotification
record class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theactionBarMessage
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.@NotNull Optional
<com.destroystokyo.paper.ParticleBuilder> particle()
Returns the value of theparticle
record component.@NotNull Optional
<net.kyori.adventure.sound.Sound> sound()
Returns the value of thesound
record component.Returns the value of thesubtitleMessage
record component.Returns the value of thetextMessage
record component.Returns the value of thetitleMessage
record component.@NotNull Optional
<net.kyori.adventure.title.Title.Times> Returns the value of thetitleTimes
record component.final String
toString()
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 aPlayerNotification
record class.- Parameters:
textMessage
- the value for thetextMessage
record componentactionBarMessage
- the value for theactionBarMessage
record componenttitleMessage
- the value for thetitleMessage
record componentsubtitleMessage
- the value for thesubtitleMessage
record componenttitleTimes
- the value for thetitleTimes
record componentsound
- the value for thesound
record componentparticle
- the value for theparticle
record 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 thetextMessage
record component.- Returns:
- the value of the
textMessage
record component
-
actionBarMessage
Returns the value of theactionBarMessage
record component.- Returns:
- the value of the
actionBarMessage
record component
-
titleMessage
Returns the value of thetitleMessage
record component.- Returns:
- the value of the
titleMessage
record component
-
subtitleMessage
Returns the value of thesubtitleMessage
record component.- Returns:
- the value of the
subtitleMessage
record component
-
titleTimes
Returns the value of thetitleTimes
record component.- Returns:
- the value of the
titleTimes
record component
-
sound
Returns the value of thesound
record component.- Returns:
- the value of the
sound
record component
-
particle
Returns the value of theparticle
record component.- Returns:
- the value of the
particle
record component
-