Class BlockStateMock
java.lang.Object
be.seeseemelk.mockbukkit.block.state.BlockStateMock
- All Implemented Interfaces:
org.bukkit.block.BlockState,org.bukkit.metadata.Metadatable
- Direct Known Subclasses:
TileStateMock
Mock implementation of a
BlockState.
Also manages the creation of new BlockStates with the appropriate mock class.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBlockStateMock(@NotNull BlockStateMock state) Constructs a newBlockStateMockby cloning the data from an existing one.BlockStateMock(@NotNull org.bukkit.Material material) Constructs a newBlockStateMockfor the providedMaterial.protectedBlockStateMock(@NotNull org.bukkit.block.Block block) Constructs a newBlockStateMockfor the providedBlock. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckType(@NotNull org.bukkit.Material material, @NotNull org.bukkit.Material @NotNull ... expected) Ensures the provided material is one of the expected materials provided.protected voidcheckType(@NotNull org.bukkit.Material material, @NotNull org.bukkit.Tag<org.bukkit.Material> expected) Ensures the provided material is contained in theTag.protected voidcheckType(@NotNull org.bukkit.block.Block block, @NotNull org.bukkit.Material... expected) Ensures the provided block type is one of the expected materials provided.protected voidcheckType(@NotNull org.bukkit.block.Block block, @NotNull org.bukkit.Tag<org.bukkit.Material> expected) Ensures the provided block type is contained in theTag.@NotNull org.bukkit.block.BlockStatecopy()@NotNull org.bukkit.block.BlockStatecopy(@NotNull org.bukkit.Location location) boolean@NotNull org.bukkit.block.BlockgetBlock()@NotNull org.bukkit.block.data.BlockData@NotNull org.bukkit.ChunkgetChunk()@NotNull org.bukkit.material.MaterialDatagetData()Deprecated.@NotNull Collection<org.bukkit.inventory.ItemStack> getDrops()@NotNull Collection<org.bukkit.inventory.ItemStack> getDrops(@NotNull org.bukkit.inventory.ItemStack tool, @Nullable org.bukkit.entity.Entity entity) @NotNull Collection<org.bukkit.inventory.ItemStack> getDrops(@Nullable org.bukkit.inventory.ItemStack tool) byte@NotNull org.bukkit.Locationorg.bukkit.LocationgetLocation(org.bukkit.Location loc) @NotNull List<org.bukkit.metadata.MetadataValue> getMetadata(String metadataKey) byteDeprecated.@NotNull org.bukkit.block.BlockStateThis returns a copy of thisBlockStateMock.@NotNull org.bukkit.MaterialgetType()@NotNull org.bukkit.WorldgetWorld()intgetX()intgetY()intgetZ()inthashCode()booleanhasMetadata(String metadataKey) booleanbooleanisPlaced()static @NotNull BlockStateMockmockState(@NotNull org.bukkit.block.Block block) Attempts to construct a BlockStateMock by the provided block.voidremoveMetadata(String metadataKey, org.bukkit.plugin.Plugin owningPlugin) voidsetBlockData(org.bukkit.block.data.BlockData data) voidsetData(org.bukkit.material.MaterialData data) Deprecated.voidsetMetadata(String metadataKey, @NotNull org.bukkit.metadata.MetadataValue newMetadataValue) voidsetRawData(byte data) Deprecated.voidsetType(org.bukkit.Material type) booleanupdate()booleanupdate(boolean force) booleanupdate(boolean force, boolean applyPhysics)
-
Constructor Details
-
BlockStateMock
public BlockStateMock(@NotNull @NotNull org.bukkit.Material material) Constructs a newBlockStateMockfor the providedMaterial.- Parameters:
material- The material this state is for.
-
BlockStateMock
protected BlockStateMock(@NotNull @NotNull org.bukkit.block.Block block) Constructs a newBlockStateMockfor the providedBlock.- Parameters:
block- The block this state is for.
-
BlockStateMock
Constructs a newBlockStateMockby cloning the data from an existing one.- Parameters:
state- The state to clone.
-
-
Method Details
-
checkType
protected void checkType(@NotNull @NotNull org.bukkit.Material material, @NotNull @NotNull org.bukkit.Material @NotNull ... expected) Ensures the provided material is one of the expected materials provided.- Parameters:
material- The material to test.expected- The expected materials.
-
checkType
protected void checkType(@NotNull @NotNull org.bukkit.block.Block block, @NotNull @NotNull org.bukkit.Material... expected) Ensures the provided block type is one of the expected materials provided.- Parameters:
block- The block to test.expected- The expected materials.
-
checkType
protected void checkType(@NotNull @NotNull org.bukkit.Material material, @NotNull @NotNull org.bukkit.Tag<org.bukkit.Material> expected) Ensures the provided material is contained in theTag.- Parameters:
material- The material to test.expected- The expected tag.
-
checkType
protected void checkType(@NotNull @NotNull org.bukkit.block.Block block, @NotNull @NotNull org.bukkit.Tag<org.bukkit.Material> expected) Ensures the provided block type is contained in theTag.- Parameters:
block- The material to test.expected- The expected tag.
-
setMetadata
public void setMetadata(String metadataKey, @NotNull @NotNull org.bukkit.metadata.MetadataValue newMetadataValue) - Specified by:
setMetadatain interfaceorg.bukkit.metadata.Metadatable
-
getMetadata
- Specified by:
getMetadatain interfaceorg.bukkit.metadata.Metadatable
-
hasMetadata
- Specified by:
hasMetadatain interfaceorg.bukkit.metadata.Metadatable
-
removeMetadata
- Specified by:
removeMetadatain interfaceorg.bukkit.metadata.Metadatable
-
getBlock
@NotNull public @NotNull org.bukkit.block.Block getBlock()- Specified by:
getBlockin interfaceorg.bukkit.block.BlockState
-
getData
Deprecated.- Specified by:
getDatain interfaceorg.bukkit.block.BlockState
-
getType
@NotNull public @NotNull org.bukkit.Material getType()- Specified by:
getTypein interfaceorg.bukkit.block.BlockState
-
getLightLevel
public byte getLightLevel()- Specified by:
getLightLevelin interfaceorg.bukkit.block.BlockState
-
getWorld
@NotNull public @NotNull org.bukkit.World getWorld()- Specified by:
getWorldin interfaceorg.bukkit.block.BlockState
-
getX
public int getX()- Specified by:
getXin interfaceorg.bukkit.block.BlockState
-
getY
public int getY()- Specified by:
getYin interfaceorg.bukkit.block.BlockState
-
getZ
public int getZ()- Specified by:
getZin interfaceorg.bukkit.block.BlockState
-
getLocation
@NotNull public @NotNull org.bukkit.Location getLocation()- Specified by:
getLocationin interfaceorg.bukkit.block.BlockState
-
getLocation
public org.bukkit.Location getLocation(org.bukkit.Location loc) - Specified by:
getLocationin interfaceorg.bukkit.block.BlockState
-
getChunk
@NotNull public @NotNull org.bukkit.Chunk getChunk()- Specified by:
getChunkin interfaceorg.bukkit.block.BlockState
-
setData
Deprecated.- Specified by:
setDatain interfaceorg.bukkit.block.BlockState
-
setType
public void setType(org.bukkit.Material type) - Specified by:
setTypein interfaceorg.bukkit.block.BlockState
-
update
public boolean update()- Specified by:
updatein interfaceorg.bukkit.block.BlockState
-
update
public boolean update(boolean force) - Specified by:
updatein interfaceorg.bukkit.block.BlockState
-
update
public boolean update(boolean force, boolean applyPhysics) - Specified by:
updatein interfaceorg.bukkit.block.BlockState
-
getRawData
Deprecated.- Specified by:
getRawDatain interfaceorg.bukkit.block.BlockState
-
setRawData
Deprecated.- Specified by:
setRawDatain interfaceorg.bukkit.block.BlockState
-
isPlaced
public boolean isPlaced()- Specified by:
isPlacedin interfaceorg.bukkit.block.BlockState
-
isCollidable
public boolean isCollidable()- Specified by:
isCollidablein interfaceorg.bukkit.block.BlockState
-
getDrops
- Specified by:
getDropsin interfaceorg.bukkit.block.BlockState
-
getDrops
@NotNull public @NotNull Collection<org.bukkit.inventory.ItemStack> getDrops(@Nullable @Nullable org.bukkit.inventory.ItemStack tool) - Specified by:
getDropsin interfaceorg.bukkit.block.BlockState
-
getDrops
@NotNull public @NotNull Collection<org.bukkit.inventory.ItemStack> getDrops(@NotNull @NotNull org.bukkit.inventory.ItemStack tool, @Nullable @Nullable org.bukkit.entity.Entity entity) - Specified by:
getDropsin interfaceorg.bukkit.block.BlockState
-
getBlockData
@NotNull public @NotNull org.bukkit.block.data.BlockData getBlockData()- Specified by:
getBlockDatain interfaceorg.bukkit.block.BlockState
-
copy
@NotNull public @NotNull org.bukkit.block.BlockState copy()- Specified by:
copyin interfaceorg.bukkit.block.BlockState
-
copy
@NotNull public @NotNull org.bukkit.block.BlockState copy(@NotNull @NotNull org.bukkit.Location location) - Specified by:
copyin interfaceorg.bukkit.block.BlockState
-
setBlockData
public void setBlockData(org.bukkit.block.data.BlockData data) - Specified by:
setBlockDatain interfaceorg.bukkit.block.BlockState
-
getSnapshot
@NotNull public @NotNull org.bukkit.block.BlockState getSnapshot()This returns a copy of thisBlockStateMock. Inheritents of this class should override this method!- Returns:
- A snapshot of this
BlockStateMock.
-
hashCode
public int hashCode() -
equals
-
mockState
@NotNull public static @NotNull BlockStateMock mockState(@NotNull @NotNull org.bukkit.block.Block block) Attempts to construct a BlockStateMock by the provided block. Will return a basicBlockStateMockif no implementation is found.- Parameters:
block- The block to create the BlockState from.- Returns:
- The BlockState.
-