Class BlockStateMock

java.lang.Object
org.mockbukkit.mockbukkit.block.state.BlockStateMock
All Implemented Interfaces:
BlockState, Metadatable
Direct Known Subclasses:
TileStateMock

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

    • BlockStateMock

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

      protected BlockStateMock(@NotNull @NotNull 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 Material material, @NotNull @NotNull 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 Block block, @NotNull @NotNull 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 Material material, @NotNull @NotNull Tag<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 Block block, @NotNull @NotNull Tag<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 MetadataValue newMetadataValue)
      Specified by:
      setMetadata in interface Metadatable
    • getMetadata

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

      public boolean hasMetadata(String metadataKey)
      Specified by:
      hasMetadata in interface Metadatable
    • removeMetadata

      public void removeMetadata(String metadataKey, Plugin owningPlugin)
      Specified by:
      removeMetadata in interface Metadatable
    • getBlock

      @NotNull public @NotNull Block getBlock()
      Specified by:
      getBlock in interface BlockState
    • getData

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

      @NotNull public @NotNull Material getType()
      Specified by:
      getType in interface BlockState
    • getLightLevel

      public byte getLightLevel()
      Specified by:
      getLightLevel in interface BlockState
    • getWorld

      @NotNull public @NotNull World getWorld()
      Specified by:
      getWorld in interface BlockState
    • getX

      public int getX()
      Specified by:
      getX in interface BlockState
    • getY

      public int getY()
      Specified by:
      getY in interface BlockState
    • getZ

      public int getZ()
      Specified by:
      getZ in interface BlockState
    • getLocation

      @NotNull public @NotNull Location getLocation()
      Specified by:
      getLocation in interface BlockState
    • getLocation

      public Location getLocation(Location loc)
      Specified by:
      getLocation in interface BlockState
    • getChunk

      @NotNull public @NotNull Chunk getChunk()
      Specified by:
      getChunk in interface BlockState
    • setData

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

      public void setType(Material type)
      Specified by:
      setType in interface BlockState
    • update

      public boolean update()
      Specified by:
      update in interface BlockState
    • update

      public boolean update(boolean force)
      Specified by:
      update in interface BlockState
    • update

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

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

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

      public boolean isPlaced()
      Specified by:
      isPlaced in interface BlockState
    • isCollidable

      public boolean isCollidable()
      Specified by:
      isCollidable in interface BlockState
    • getDrops

      @NotNull public @NotNull Collection<ItemStack> getDrops()
      Specified by:
      getDrops in interface BlockState
    • getDrops

      @NotNull public @NotNull Collection<ItemStack> getDrops(@Nullable @Nullable ItemStack tool)
      Specified by:
      getDrops in interface BlockState
    • getDrops

      @NotNull public @NotNull Collection<ItemStack> getDrops(@NotNull @NotNull ItemStack tool, @Nullable @Nullable Entity entity)
      Specified by:
      getDrops in interface BlockState
    • getBlockData

      @NotNull public @NotNull BlockData getBlockData()
      Specified by:
      getBlockData in interface BlockState
    • copy

      @NotNull public @NotNull BlockStateMock copy()
      This returns a copy of this BlockStateMock. Inheriters of this class must override this method!
      Specified by:
      copy in interface BlockState
      Returns:
      A copy of this BlockStateMock.
    • copy

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

      public void setBlockData(BlockData data)
      Specified by:
      setBlockData in interface BlockState
    • getSnapshot

      @NotNull public @NotNull BlockStateMock getSnapshot()
      This returns a copy of this BlockStateMock. Inheriters of this class must 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringInternal

      protected String toStringInternal()
      Provides the contents of toString() .

      Implementors must call super as in the following example.

      
      	@Override
      	protected String toStringInternal()
      	{
      		return super.toStringInternal() +
      				", member1=" + member1 +
      				", member2=" + member2;
      	}
       
      Returns:
      Comma separated list of properties and values.
    • mockState

      @NotNull public static @NotNull BlockStateMock mockState(@NotNull @NotNull 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.
    • mockState

      @NotNull public static @NotNull BlockStateMock mockState(@NotNull @NotNull Material material)