Package org.bukkit.block
Interface Vault
- All Superinterfaces:
BlockState
,Metadatable
,PersistentDataHolder
,PersistentDataViewHolder
,TileState
Represents a captured state of a vault.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addRewardedPlayer
(UUID playerUUID) Adds a player as rewarded for this vault.double
Gets 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.double
Gets 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 theItemStack
that players must use to unlock this vault.Gets theLootTable
that this vault will select rewards from.long
Gets 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.boolean
hasConnectedPlayer
(UUID playerUUID) Returns whether a given player is currently connected to this vault.boolean
hasRewardedPlayer
(UUID playerUUID) Returns whether a given player has already been rewarded by this vault.boolean
removeRewardedPlayer
(UUID playerUUID) Removes a player as rewarded for this vault, allowing them to use akey item
again to receive rewards.void
setActivationRange
(double activationRange) Sets the range in blocks at which the vault will become active when a player is near.void
setDeactivationRange
(double deactivationRange) Sets the range in blocks at which this vault will become inactive when a player is not near.void
setDisplayedItem
(ItemStack displayedItem) Sets the item to display inside this vault until the next cycle.void
setDisplayedLootTable
(@Nullable LootTable lootTable) Sets the loot table that this vault will display items from.void
setKeyItem
(ItemStack key) Sets theItemStack
that players must use to unlock this vault.void
setLootTable
(LootTable lootTable) Sets theLootTable
that this vault will select rewards from.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.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
-
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 theItemStack
that players must use to unlock this vault.- Returns:
- The item that players must use to unlock this vault.
-
setKeyItem
Sets theItemStack
that players must use to unlock this vault.- Parameters:
key
- The key item.
-
getLootTable
LootTable getLootTable()Gets theLootTable
that this vault will select rewards from.- Returns:
- The loot table.
-
setLootTable
Sets theLootTable
that 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 table
if unset.- Returns:
- The
LootTable
that 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, ornull
to 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:
true
if 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 item
again to receive rewards.- Parameters:
playerUUID
- The player's uuid.- Returns:
true
if 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 time
for 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:
true
if 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
-