Package org.bukkit.block
Interface Vault
- All Superinterfaces:
BlockState,Metadatable,PersistentDataHolder,PersistentDataViewHolder,TileState
Represents a captured state of a vault.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddRewardedPlayer(UUID playerUUID) Adds a player as rewarded for this vault.doubleGets the range in blocks at which this vault will become active when a player is near.Gets an unmodifiable set of "connected players"; players who are inside this vault's activation range and who have not received rewards yet.doubleGets the range in blocks at which this vault will become inactive when a player is not near.Gets the item currently being displayed inside this vault.Gets the loot table that this vault will display items from.Gets theItemStackthat players must use to unlock this vault.Gets theLootTablethat this vault will select rewards from.longGets the next time (ingame time) that this vault block will be updated/ticked at.Gets the players who have used a key on this vault and unlocked it.booleanhasConnectedPlayer(UUID playerUUID) Returns whether a given player is currently connected to this vault.booleanhasRewardedPlayer(UUID playerUUID) Returns whether a given player has already been rewarded by this vault.booleanremoveRewardedPlayer(UUID playerUUID) Removes a player as rewarded for this vault, allowing them to use akey itemagain to receive rewards.voidsetActivationRange(double activationRange) Sets the range in blocks at which the vault will become active when a player is near.voidsetDeactivationRange(double deactivationRange) Sets the range in blocks at which this vault will become inactive when a player is not near.voidsetDisplayedItem(ItemStack displayedItem) Sets the item to display inside this vault until the next cycle.voidsetDisplayedLootTable(@Nullable LootTable lootTable) Sets the loot table that this vault will display items from.voidsetKeyItem(ItemStack key) Sets theItemStackthat players must use to unlock this vault.voidsetLootTable(LootTable lootTable) Sets theLootTablethat this vault will select rewards from.voidsetNextStateUpdateTime(long nextStateUpdateTime) Sets the next time that this vault block will be updated/ticked at, if this value is less than or equals to the currentWorld.getGameTime(), then it will be updated in the first possible tick.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, isSuffocating, setBlockData, setData, setRawData, setType, update, update, updateMethods inherited from interface org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadataMethods inherited from interface org.bukkit.block.TileState
getPersistentDataContainer, isSnapshot
-
Method Details
-
getActivationRange
double getActivationRange()Gets the range in blocks at which this vault will become active when a player is near.- Returns:
- This vault's activation range.
-
setActivationRange
void setActivationRange(double activationRange) Sets the range in blocks at which the vault will become active when a player is near.- Parameters:
activationRange- The new activation range.- Throws:
IllegalArgumentException- if the new range is not a number, or if the new range is more thangetDeactivationRange().
-
getDeactivationRange
double getDeactivationRange()Gets the range in blocks at which this vault will become inactive when a player is not near.- Returns:
- This vault's deactivation range.
-
setDeactivationRange
void setDeactivationRange(double deactivationRange) Sets the range in blocks at which this vault will become inactive when a player is not near.- Parameters:
deactivationRange- The new deactivation range- Throws:
IllegalArgumentException- if the new range is not a number, or if the new range is less thangetActivationRange().
-
getKeyItem
ItemStack getKeyItem()Gets theItemStackthat players must use to unlock this vault.- Returns:
- The item that players must use to unlock this vault.
-
setKeyItem
Sets theItemStackthat players must use to unlock this vault.- Parameters:
key- The key item.
-
getLootTable
LootTable getLootTable()Gets theLootTablethat this vault will select rewards from.- Returns:
- The loot table.
-
setLootTable
Sets theLootTablethat this vault will select rewards from.- Parameters:
lootTable- The new loot table.
-
getDisplayedLootTable
Gets the loot table that this vault will display items from.Falls back to the regular
loot tableif unset.- Returns:
- The
LootTablethat will be used to display items.
-
setDisplayedLootTable
Sets the loot table that this vault will display items from.- Parameters:
lootTable- The new loot table to display, ornullto clear this display override.
-
getNextStateUpdateTime
long getNextStateUpdateTime()Gets the next time (ingame time) that this vault block will be updated/ticked at.- Returns:
- The next time that this vault block will be updated/ticked at.
- See Also:
-
setNextStateUpdateTime
void setNextStateUpdateTime(long nextStateUpdateTime) Sets the next time that this vault block will be updated/ticked at, if this value is less than or equals to the currentWorld.getGameTime(), then it will be updated in the first possible tick.- Parameters:
nextStateUpdateTime- The next time that this vault block will be updated/ticked at.- See Also:
-
getRewardedPlayers
@Unmodifiable Collection<UUID> getRewardedPlayers()Gets the players who have used a key on this vault and unlocked it.- Returns:
- An unmodifiable collection of player uuids.
- API Note:
- Only the most recent 128 player UUIDs will be stored by vault blocks.
-
addRewardedPlayer
Adds a player as rewarded for this vault.- Parameters:
playerUUID- The player's uuid.- Returns:
trueif this player was previously not rewarded, and has been added as a result of this operation.- API Note:
- Only the most recent 128 player UUIDs will be stored by vault blocks. Attempting to add more will result in the first player UUID being removed.
-
removeRewardedPlayer
Removes a player as rewarded for this vault, allowing them to use akey itemagain to receive rewards.- Parameters:
playerUUID- The player's uuid.- Returns:
trueif this player was previously rewarded, and has been removed as a result of this operation.- API Note:
- Only the most recent 128 player UUIDs will be stored by vault blocks.
-
hasRewardedPlayer
Returns whether a given player has already been rewarded by this vault.- Parameters:
playerUUID- The player's uuid.- Returns:
- Whether this player was previously rewarded by this vault.
-
getConnectedPlayers
@Unmodifiable Set<UUID> getConnectedPlayers()Gets an unmodifiable set of "connected players"; players who are inside this vault's activation range and who have not received rewards yet.- Returns:
- An unmodifiable set of connected player uuids.
- API Note:
- Vaults will only periodically scan for nearby players, so it may take until the next
update timefor this collection to be updated upon a player entering its range.
-
hasConnectedPlayer
Returns whether a given player is currently connected to this vault.- Parameters:
playerUUID- the player's uuid- Returns:
trueif this player is currently connected to this vault.- See Also:
-
getDisplayedItem
ItemStack getDisplayedItem()Gets the item currently being displayed inside this vault. Displayed items will automatically cycle between random items from thegetDisplayedLootTable()orgetLootTable()loot tables while this vault is active.- Returns:
- The item currently being displayed inside this vault.
-
setDisplayedItem
Sets the item to display inside this vault until the next cycle.- Parameters:
displayedItem- The item to display
-