Package org.bukkit.block
Interface Jukebox
- All Superinterfaces:
BlockInventoryHolder
,BlockState
,InventoryHolder
,Metadatable
,PersistentDataHolder
,PersistentDataViewHolder
,TileState
,TileStateInventoryHolder
Represents a captured state of a jukebox.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
eject()
Stops the jukebox playing and ejects the current record.Gets the inventory of the block represented by this block state.Gets the record inserted into the jukebox.Gets the record item inserted into the jukebox.Gets the captured inventory snapshot of this container.boolean
Gets whether or not this jukebox has a record.boolean
Checks if the jukebox is playing a record.void
setPlaying
(@Nullable Material record) Sets the record being played.void
Sets the record being played.boolean
Starts the jukebox playing if there is a record.void
Stops the jukebox playing without ejecting the record.Methods inherited from interface org.bukkit.inventory.BlockInventoryHolder
getBlock
Methods inherited from interface org.bukkit.block.BlockState
copy, copy, getBlock, getBlockData, getChunk, getData, getDrops, getDrops, getDrops, getLightLevel, getLocation, getLocation, getRawData, getType, getWorld, getX, getY, getZ, isCollidable, isPlaced, setBlockData, setData, setRawData, setType, update, update, update
Methods inherited from interface org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadata
Methods inherited from interface org.bukkit.block.TileState
getPersistentDataContainer, isSnapshot
-
Method Details
-
getPlaying
Gets the record inserted into the jukebox.- Returns:
- The record Material, or AIR if none is inserted
-
setPlaying
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 withstopPlaying()
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
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:TileStateInventoryHolder
Gets the inventory of the block represented by this block state.If the block was changed to a different type in the meantime, the returned inventory might no longer be valid.
If this block state is not placed this will return the captured inventory snapshot instead.
- Specified by:
getInventory
in interfaceInventoryHolder
- Specified by:
getInventory
in interfaceTileStateInventoryHolder
- Returns:
- the inventory
-
getSnapshotInventory
Description copied from interface:TileStateInventoryHolder
Gets the captured inventory snapshot of this container.The returned inventory is not linked to any block. Any modifications to the returned inventory will not be applied to the block represented by this block state up until
BlockState.update(boolean, boolean)
has been called.- Specified by:
getSnapshotInventory
in interfaceTileStateInventoryHolder
- Returns:
- the captured inventory snapshot
-