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
ConstructorsConstructorDescriptionCustomJukeboxPlayableComponent
(org.bukkit.NamespacedKey songKey, org.bukkit.JukeboxSong jukeboxSong, boolean showInTooltip) Constructs a new CustomJukeboxPlayableComponent. -
Method Summary
Modifier and TypeMethodDescription@Nullable org.bukkit.JukeboxSong
getSong()
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.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.
-
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 songjukeboxSong
- the song to be played by the jukeboxshowInTooltip
- 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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.bukkit.inventory.meta.components.JukeboxPlayableComponent
- Parameters:
show
- true to show the song in the tooltip, false otherwise
-
serialize
Serializes this component into a map of key-value pairs.- Specified by:
serialize
in interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable
- Returns:
- a map containing the serialized data
-