Record Class PlayerNotification

java.lang.Object
java.lang.Record
dev.chicoferreira.lifestealer.PlayerNotification
Record Components:
textMessage - the text message to send to the player
actionBarMessage - the action bar message to send to the player
titleMessage - the title message to send to the player
subtitleMessage - the subtitle message to send to the player
titleTimes - the title timings to send to the player
sound - 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 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,net.kyori.adventure.text.minimessage.tag.resolver.TagResolver> ADDITIONAL_RESOLVERS
      Additional tag resolvers to apply to the messages. Used in main class to add custom resolvers (for example, parsing PAPI placeholders).
  • Constructor Details

    • PlayerNotification

      public PlayerNotification(String textMessage)
      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 a PlayerNotification record class.
      Parameters:
      textMessage - the value for the textMessage record component
      actionBarMessage - the value for the actionBarMessage record component
      titleMessage - the value for the titleMessage record component
      subtitleMessage - the value for the subtitleMessage record component
      titleTimes - the value for the titleTimes record component
      sound - the value for the sound record component
      particle - the value for the particle record component
  • Method Details

    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • textMessage

      @NotNull public @NotNull Optional<String> textMessage()
      Returns the value of the textMessage record component.
      Returns:
      the value of the textMessage record component
    • actionBarMessage

      @NotNull public @NotNull Optional<String> actionBarMessage()
      Returns the value of the actionBarMessage record component.
      Returns:
      the value of the actionBarMessage record component
    • titleMessage

      @NotNull public @NotNull Optional<String> titleMessage()
      Returns the value of the titleMessage record component.
      Returns:
      the value of the titleMessage record component
    • subtitleMessage

      @NotNull public @NotNull Optional<String> subtitleMessage()
      Returns the value of the subtitleMessage record component.
      Returns:
      the value of the subtitleMessage record component
    • titleTimes

      @NotNull public @NotNull Optional<net.kyori.adventure.title.Title.Times> titleTimes()
      Returns the value of the titleTimes record component.
      Returns:
      the value of the titleTimes record component
    • sound

      @NotNull public @NotNull Optional<net.kyori.adventure.sound.Sound> sound()
      Returns the value of the sound record component.
      Returns:
      the value of the sound record component
    • particle

      @NotNull public @NotNull Optional<com.destroystokyo.paper.ParticleBuilder> particle()
      Returns the value of the particle record component.
      Returns:
      the value of the particle record component