Interface Jukebox

All Superinterfaces:
BlockInventoryHolder, BlockState, InventoryHolder, Metadatable, PersistentDataHolder, TileState

public interface Jukebox extends TileState, BlockInventoryHolder
Represents a captured state of a jukebox.
  • Method Details

    • getPlaying

      @NotNull @NotNull Material getPlaying()
      Gets the record inserted into the jukebox.
      Returns:
      The record Material, or AIR if none is inserted
    • setPlaying

      void setPlaying(@Nullable @Nullable Material record)
      Sets the record being played.
      Parameters:
      record - The record Material, or null/AIR to stop playing
    • hasRecord

      boolean hasRecord()
      Gets whether or not this jukebox has a record.

      A jukebox can have a record but not be playing if it was stopped with stopPlaying() or if a record has finished playing.

      Returns:
      true if this jukebox has a record, false if it the jukebox is empty
    • getRecord

      Gets the record item inserted into the jukebox.
      Returns:
      a copy of the inserted record, or an air stack if none
    • setRecord

      void setRecord(@Nullable @Nullable ItemStack record)
      Sets the record being played. The jukebox will start playing automatically.
      Parameters:
      record - the record to insert or null/AIR to empty
    • isPlaying

      boolean isPlaying()
      Checks if the jukebox is playing a record.
      Returns:
      True if there is a record playing
    • startPlaying

      boolean startPlaying()
      Starts the jukebox playing if there is a record.
      Returns:
      true if the jukebox had a record and was able to start playing, false if the jukebox was already playing or did not have a record
    • stopPlaying

      void stopPlaying()
      Stops the jukebox playing without ejecting the record.
    • eject

      boolean eject()
      Stops the jukebox playing and ejects the current record.

      If the block represented by this state is no longer a jukebox, this will do nothing and return false.

      Returns:
      True if a record was ejected; false if there was none playing
      Throws:
      IllegalStateException - if this block state is not placed
    • getInventory

      Description copied from interface: InventoryHolder
      Get the object's inventory.
      Specified by:
      getInventory in interface InventoryHolder
      Returns:
      inventory
      See Also:
    • getSnapshotInventory

      @NotNull @NotNull JukeboxInventory getSnapshotInventory()
      Returns:
      snapshot inventory
      See Also: