Class CustomJukeboxPlayableComponent

java.lang.Object
io.github.lucfr1746.llibrary.itemstack.component.CustomJukeboxPlayableComponent
All Implemented Interfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable, org.bukkit.inventory.meta.components.JukeboxPlayableComponent

public class CustomJukeboxPlayableComponent extends Object implements org.bukkit.inventory.meta.components.JukeboxPlayableComponent
Represents a custom implementation of the JukeboxPlayableComponent interface. This class allows customizing jukebox behavior, such as setting custom songs, their keys, and whether they show up in item tooltips.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CustomJukeboxPlayableComponent(org.bukkit.NamespacedKey songKey, org.bukkit.JukeboxSong jukeboxSong, boolean showInTooltip)
    Constructs a new CustomJukeboxPlayableComponent.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable org.bukkit.JukeboxSong
    Gets the song associated with this component.
    @NotNull org.bukkit.NamespacedKey
    Gets the key of the song assigned to this component.
    boolean
    Checks whether the song should be shown in the item's tooltip.
    @NotNull Map<String,Object>
    Serializes this component into a map of key-value pairs.
    void
    setShowInTooltip(boolean show)
    Sets whether the song should be shown in the item's tooltip.
    void
    setSong(@NotNull org.bukkit.JukeboxSong song)
    Sets the song for this component.
    void
    setSongKey(@NotNull org.bukkit.NamespacedKey songKey)
    Sets the song key for this component.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CustomJukeboxPlayableComponent

      public CustomJukeboxPlayableComponent(org.bukkit.NamespacedKey songKey, org.bukkit.JukeboxSong jukeboxSong, boolean showInTooltip)
      Constructs a new CustomJukeboxPlayableComponent.
      Parameters:
      songKey - the key identifying the song
      jukeboxSong - the song to be played by the jukebox
      showInTooltip - whether the song should be shown in the item's tooltip
  • Method Details

    • getSong

      @Nullable public @Nullable org.bukkit.JukeboxSong getSong()
      Gets the song associated with this component.
      Specified by:
      getSong in interface org.bukkit.inventory.meta.components.JukeboxPlayableComponent
      Returns:
      the JukeboxSong, or null if not set
    • getSongKey

      @NotNull public @NotNull org.bukkit.NamespacedKey getSongKey()
      Gets the key of the song assigned to this component.
      Specified by:
      getSongKey in interface org.bukkit.inventory.meta.components.JukeboxPlayableComponent
      Returns:
      the NamespacedKey representing the song's key
    • setSong

      public void setSong(@NotNull @NotNull org.bukkit.JukeboxSong song)
      Sets the song for this component.
      Specified by:
      setSong in interface org.bukkit.inventory.meta.components.JukeboxPlayableComponent
      Parameters:
      song - the JukeboxSong to set
    • setSongKey

      public void setSongKey(@NotNull @NotNull org.bukkit.NamespacedKey songKey)
      Sets the song key for this component.
      Specified by:
      setSongKey in interface org.bukkit.inventory.meta.components.JukeboxPlayableComponent
      Parameters:
      songKey - the NamespacedKey representing the song's key
    • isShowInTooltip

      public boolean isShowInTooltip()
      Checks whether the song should be shown in the item's tooltip.
      Specified by:
      isShowInTooltip in interface org.bukkit.inventory.meta.components.JukeboxPlayableComponent
      Returns:
      true if the song is shown in the tooltip, false otherwise
    • setShowInTooltip

      public void setShowInTooltip(boolean show)
      Sets whether the song should be shown in the item's tooltip.
      Specified by:
      setShowInTooltip in interface org.bukkit.inventory.meta.components.JukeboxPlayableComponent
      Parameters:
      show - true to show the song in the tooltip, false otherwise
    • serialize

      @NotNull public @NotNull Map<String,Object> serialize()
      Serializes this component into a map of key-value pairs.
      Specified by:
      serialize in interface org.bukkit.configuration.serialization.ConfigurationSerializable
      Returns:
      a map containing the serialized data