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

public class BlockStateMock extends Object implements org.bukkit.block.BlockState
Mock implementation of a BlockState. Also manages the creation of new BlockStates with the appropriate mock class.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructs a new BlockStateMock by cloning the data from an existing one.
     
    BlockStateMock(@NotNull org.bukkit.Material material)
    Constructs a new BlockStateMock for the provided Material.
    protected
    BlockStateMock(@NotNull org.bukkit.block.Block block)
    Constructs a new BlockStateMock for the provided Block.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    checkType(@NotNull org.bukkit.Material material, @NotNull org.bukkit.Material @NotNull ... expected)
    Ensures the provided material is one of the expected materials provided.
    protected void
    checkType(@NotNull org.bukkit.Material material, @NotNull org.bukkit.Tag<org.bukkit.Material> expected)
    Ensures the provided material is contained in the Tag.
    protected void
    checkType(@NotNull org.bukkit.block.Block block, @NotNull org.bukkit.Material... expected)
    Ensures the provided block type is one of the expected materials provided.
    protected void
    checkType(@NotNull org.bukkit.block.Block block, @NotNull org.bukkit.Tag<org.bukkit.Material> expected)
    Ensures the provided block type is contained in the Tag.
    @NotNull org.bukkit.block.BlockState
     
    @NotNull org.bukkit.block.BlockState
    copy(@NotNull org.bukkit.Location location)
     
    boolean
     
    @NotNull org.bukkit.block.Block
     
    @NotNull org.bukkit.block.data.BlockData
     
    @NotNull org.bukkit.Chunk
     
    @NotNull org.bukkit.material.MaterialData
    Deprecated.
    @NotNull Collection<org.bukkit.inventory.ItemStack>
     
    @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.Location
     
    org.bukkit.Location
    getLocation(org.bukkit.Location loc)
     
    @NotNull List<org.bukkit.metadata.MetadataValue>
    getMetadata(String metadataKey)
     
    byte
    Deprecated.
    @NotNull org.bukkit.block.BlockState
    This returns a copy of this BlockStateMock.
    @NotNull org.bukkit.Material
     
    @NotNull org.bukkit.World
     
    int
     
    int
     
    int
     
    int
     
    boolean
    hasMetadata(String metadataKey)
     
    boolean
     
    boolean
     
    static @NotNull BlockStateMock
    mockState(@NotNull org.bukkit.block.Block block)
    Attempts to construct a BlockStateMock by the provided block.
    void
    removeMetadata(String metadataKey, org.bukkit.plugin.Plugin owningPlugin)
     
    void
    setBlockData(org.bukkit.block.data.BlockData data)
     
    void
    setData(org.bukkit.material.MaterialData data)
    Deprecated.
    void
    setMetadata(String metadataKey, @NotNull org.bukkit.metadata.MetadataValue newMetadataValue)
     
    void
    setRawData(byte data)
    Deprecated.
    void
    setType(org.bukkit.Material type)
     
    boolean
     
    boolean
    update(boolean force)
     
    boolean
    update(boolean force, boolean applyPhysics)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BlockStateMock

      public BlockStateMock(@NotNull @NotNull org.bukkit.Material material)
      Constructs a new BlockStateMock for the provided Material.
      Parameters:
      material - The material this state is for.
    • BlockStateMock

      protected BlockStateMock(@NotNull @NotNull org.bukkit.block.Block block)
      Constructs a new BlockStateMock for the provided Block.
      Parameters:
      block - The block this state is for.
    • BlockStateMock

      protected BlockStateMock(@NotNull @NotNull BlockStateMock state)
      Constructs a new BlockStateMock by 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 the Tag.
      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 the Tag.
      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:
      setMetadata in interface org.bukkit.metadata.Metadatable
    • getMetadata

      @NotNull public @NotNull List<org.bukkit.metadata.MetadataValue> getMetadata(String metadataKey)
      Specified by:
      getMetadata in interface org.bukkit.metadata.Metadatable
    • hasMetadata

      public boolean hasMetadata(String metadataKey)
      Specified by:
      hasMetadata in interface org.bukkit.metadata.Metadatable
    • removeMetadata

      public void removeMetadata(String metadataKey, org.bukkit.plugin.Plugin owningPlugin)
      Specified by:
      removeMetadata in interface org.bukkit.metadata.Metadatable
    • getBlock

      @NotNull public @NotNull org.bukkit.block.Block getBlock()
      Specified by:
      getBlock in interface org.bukkit.block.BlockState
    • getData

      @Deprecated(since="1.18") public @NotNull org.bukkit.material.MaterialData getData()
      Deprecated.
      Specified by:
      getData in interface org.bukkit.block.BlockState
    • getType

      @NotNull public @NotNull org.bukkit.Material getType()
      Specified by:
      getType in interface org.bukkit.block.BlockState
    • getLightLevel

      public byte getLightLevel()
      Specified by:
      getLightLevel in interface org.bukkit.block.BlockState
    • getWorld

      @NotNull public @NotNull org.bukkit.World getWorld()
      Specified by:
      getWorld in interface org.bukkit.block.BlockState
    • getX

      public int getX()
      Specified by:
      getX in interface org.bukkit.block.BlockState
    • getY

      public int getY()
      Specified by:
      getY in interface org.bukkit.block.BlockState
    • getZ

      public int getZ()
      Specified by:
      getZ in interface org.bukkit.block.BlockState
    • getLocation

      @NotNull public @NotNull org.bukkit.Location getLocation()
      Specified by:
      getLocation in interface org.bukkit.block.BlockState
    • getLocation

      public org.bukkit.Location getLocation(org.bukkit.Location loc)
      Specified by:
      getLocation in interface org.bukkit.block.BlockState
    • getChunk

      @NotNull public @NotNull org.bukkit.Chunk getChunk()
      Specified by:
      getChunk in interface org.bukkit.block.BlockState
    • setData

      @Deprecated(since="1.18") public void setData(@NotNull org.bukkit.material.MaterialData data)
      Deprecated.
      Specified by:
      setData in interface org.bukkit.block.BlockState
    • setType

      public void setType(org.bukkit.Material type)
      Specified by:
      setType in interface org.bukkit.block.BlockState
    • update

      public boolean update()
      Specified by:
      update in interface org.bukkit.block.BlockState
    • update

      public boolean update(boolean force)
      Specified by:
      update in interface org.bukkit.block.BlockState
    • update

      public boolean update(boolean force, boolean applyPhysics)
      Specified by:
      update in interface org.bukkit.block.BlockState
    • getRawData

      @Deprecated(since="1.6.2") public byte getRawData()
      Deprecated.
      Specified by:
      getRawData in interface org.bukkit.block.BlockState
    • setRawData

      @Deprecated(since="1.6.2") public void setRawData(byte data)
      Deprecated.
      Specified by:
      setRawData in interface org.bukkit.block.BlockState
    • isPlaced

      public boolean isPlaced()
      Specified by:
      isPlaced in interface org.bukkit.block.BlockState
    • isCollidable

      public boolean isCollidable()
      Specified by:
      isCollidable in interface org.bukkit.block.BlockState
    • getDrops

      @NotNull public @NotNull Collection<org.bukkit.inventory.ItemStack> getDrops()
      Specified by:
      getDrops in interface org.bukkit.block.BlockState
    • getDrops

      @NotNull public @NotNull Collection<org.bukkit.inventory.ItemStack> getDrops(@Nullable @Nullable org.bukkit.inventory.ItemStack tool)
      Specified by:
      getDrops in interface org.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:
      getDrops in interface org.bukkit.block.BlockState
    • getBlockData

      @NotNull public @NotNull org.bukkit.block.data.BlockData getBlockData()
      Specified by:
      getBlockData in interface org.bukkit.block.BlockState
    • copy

      @NotNull public @NotNull org.bukkit.block.BlockState copy()
      Specified by:
      copy in interface org.bukkit.block.BlockState
    • copy

      @NotNull public @NotNull org.bukkit.block.BlockState copy(@NotNull @NotNull org.bukkit.Location location)
      Specified by:
      copy in interface org.bukkit.block.BlockState
    • setBlockData

      public void setBlockData(org.bukkit.block.data.BlockData data)
      Specified by:
      setBlockData in interface org.bukkit.block.BlockState
    • getSnapshot

      @NotNull public @NotNull org.bukkit.block.BlockState getSnapshot()
      This returns a copy of this BlockStateMock. Inheritents of this class should override this method!
      Returns:
      A snapshot of this BlockStateMock.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • 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 basic BlockStateMock if no implementation is found.
      Parameters:
      block - The block to create the BlockState from.
      Returns:
      The BlockState.