use of com.elmakers.mine.bukkit.api.block.BlockData in project MagicPlugin by elBukkit.
the class UndoRegistry method commit.
public void commit(BlockData block) {
BlockData currentState = modified.get(block.getId());
if (currentState == block) {
modified.remove(block.getId());
}
block.commit();
reflective.remove(block.getId());
breakable.remove(block.getId());
}
use of com.elmakers.mine.bukkit.api.block.BlockData in project MagicPlugin by elBukkit.
the class UndoRegistry method registerWatched.
public void registerWatched(BlockData blockData) {
BlockData priorState = watching.get(blockData.getId());
if (priorState != null) {
priorState.setNextState(blockData);
blockData.setPriorState(priorState);
}
watching.put(blockData.getId(), blockData);
}
use of com.elmakers.mine.bukkit.api.block.BlockData in project MagicPlugin by elBukkit.
the class UndoRegistry method commitAll.
public void commitAll() {
Collection<BlockData> blocks = modified.values();
modified.clear();
watching.clear();
for (BlockData block : blocks) {
block.commit();
}
}
use of com.elmakers.mine.bukkit.api.block.BlockData in project MagicPlugin by elBukkit.
the class UndoRegistry method registerModified.
public void registerModified(BlockData blockData) {
BlockData priorState = modified.get(blockData.getId());
if (priorState != null) {
priorState.setNextState(blockData);
blockData.setPriorState(priorState);
}
modified.put(blockData.getId(), blockData);
}
use of com.elmakers.mine.bukkit.api.block.BlockData in project MagicPlugin by elBukkit.
the class UndoRegistry method getBlockData.
@Nullable
public BlockData getBlockData(Location location) {
long blockId = com.elmakers.mine.bukkit.block.BlockData.getBlockId(location.getBlock());
// Prefer to return blocks that are watched by lists which are going to auto-undo.
BlockData watchedBlock = watching.get(blockId);
if (watchedBlock != null && watchedBlock.getUndoList() != null && watchedBlock.getUndoList().isScheduled()) {
return watchedBlock;
}
BlockData modifiedBlock = modified.get(blockId);
if (modifiedBlock != null) {
return modifiedBlock;
}
if (watchedBlock != null) {
return watchedBlock;
}
return null;
}
Aggregations