Class BlockStateDelegate

java.lang.Object
net.glowstone.util.BlockStateDelegate

public class BlockStateDelegate extends Object
A small utility class that allow to maintain a BlockState's list in order to capture a chain of modified blocks and update all the states in once, or never (ie: event cancelled).
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    backupBlockState(org.bukkit.block.Block block)
    Backups a block state.
    org.bukkit.block.BlockState
    getBlockState(org.bukkit.Location loc)
    Returns the BlockState of a block at the given location.
    org.bukkit.block.BlockState
    getBlockState(org.bukkit.World world, int x, int y, int z)
    Returns the BlockState of a block at the given coordinates.
    Collection<org.bukkit.block.BlockState>
    Returns the BlockState list.
    void
    Roll-back previously backed-up block states.
    void
    setType(org.bukkit.World world, int x, int y, int z, org.bukkit.Material type)
    Sets a block type and add it to the BlockState list.
    void
    setTypeAndData(org.bukkit.World world, int x, int y, int z, org.bukkit.Material type, org.bukkit.block.data.BlockData data)
    Sets a block type and MaterialData, and add it to the BlockState list.
    void
    Updates all block states contained in the BlockState list.

    Methods inherited from class java.lang.Object

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

    • BlockStateDelegate

      public BlockStateDelegate()
  • Method Details

    • setType

      public void setType(org.bukkit.World world, int x, int y, int z, org.bukkit.Material type)
      Sets a block type and add it to the BlockState list.
      Parameters:
      world - the world which contains the block
      x - the x-coordinate of this block
      y - the y-coordinate of this block
      z - the z-coordinate of this block
      type - the new type of this block
    • setTypeAndData

      public void setTypeAndData(org.bukkit.World world, int x, int y, int z, org.bukkit.Material type, org.bukkit.block.data.BlockData data)
      Sets a block type and MaterialData, and add it to the BlockState list.
      Parameters:
      world - the world which contains the block
      x - the x-coordinate of this block
      y - the y-coordinate of this block
      z - the z-coordinate of this block
      type - the new type of this block
      data - the new MaterialData of this block
    • backupBlockState

      public void backupBlockState(org.bukkit.block.Block block)
      Backups a block state.
      Parameters:
      block - the block which state should be backup
    • rollbackBlockStates

      public void rollbackBlockStates()
      Roll-back previously backed-up block states.
    • getBlockStates

      public Collection<org.bukkit.block.BlockState> getBlockStates()
      Returns the BlockState list.
      Returns:
      A list with all BlockState.
    • updateBlockStates

      public void updateBlockStates()
      Updates all block states contained in the BlockState list.
    • getBlockState

      public org.bukkit.block.BlockState getBlockState(org.bukkit.World world, int x, int y, int z)
      Returns the BlockState of a block at the given coordinates.
      Parameters:
      world - the world which contains the block
      x - the x-coordinate
      y - the y-coordinate
      z - the z-coordinate
      Returns:
      The BlockState state.
    • getBlockState

      public org.bukkit.block.BlockState getBlockState(org.bukkit.Location loc)
      Returns the BlockState of a block at the given location.
      Parameters:
      loc - the location which contains the block
      Returns:
      The BlockState state.