Package net.glowstone.util
Class BlockStateDelegate
java.lang.Object
net.glowstone.util.BlockStateDelegate
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
backupBlockState
(org.bukkit.block.Block block) Backups a block state.org.bukkit.block.BlockState
getBlockState
(org.bukkit.Location loc) Returns theBlockState
of a block at the given location.org.bukkit.block.BlockState
getBlockState
(org.bukkit.World world, int x, int y, int z) Returns theBlockState
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.
-
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 blockx
- the x-coordinate of this blocky
- the y-coordinate of this blockz
- the z-coordinate of this blocktype
- 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 blockx
- the x-coordinate of this blocky
- the y-coordinate of this blockz
- the z-coordinate of this blocktype
- the new type of this blockdata
- 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
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 theBlockState
of a block at the given coordinates.- Parameters:
world
- the world which contains the blockx
- the x-coordinatey
- the y-coordinatez
- the z-coordinate- Returns:
- The
BlockState
state.
-
getBlockState
public org.bukkit.block.BlockState getBlockState(org.bukkit.Location loc) Returns theBlockState
of a block at the given location.- Parameters:
loc
- the location which contains the block- Returns:
- The
BlockState
state.
-