Search in sources :

Example 6 with BlockData

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());
}
Also used : BlockData(com.elmakers.mine.bukkit.api.block.BlockData)

Example 7 with BlockData

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);
}
Also used : BlockData(com.elmakers.mine.bukkit.api.block.BlockData)

Example 8 with 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();
    }
}
Also used : BlockData(com.elmakers.mine.bukkit.api.block.BlockData)

Example 9 with BlockData

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);
}
Also used : BlockData(com.elmakers.mine.bukkit.api.block.BlockData)

Example 10 with 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;
}
Also used : BlockData(com.elmakers.mine.bukkit.api.block.BlockData) Nullable(javax.annotation.Nullable)

Aggregations

BlockData (com.elmakers.mine.bukkit.api.block.BlockData)22 Block (org.bukkit.block.Block)6 ArrayList (java.util.ArrayList)2 Nullable (javax.annotation.Nullable)2 Location (org.bukkit.Location)2 FallingBlock (org.bukkit.entity.FallingBlock)2 ItemStack (org.bukkit.inventory.ItemStack)2 CastContext (com.elmakers.mine.bukkit.api.action.CastContext)1 Batch (com.elmakers.mine.bukkit.api.batch.Batch)1 BlockList (com.elmakers.mine.bukkit.api.block.BlockList)1 MaterialBrush (com.elmakers.mine.bukkit.api.block.MaterialBrush)1 UndoList (com.elmakers.mine.bukkit.api.block.UndoList)1 UndoQueue (com.elmakers.mine.bukkit.api.block.UndoQueue)1 Mage (com.elmakers.mine.bukkit.api.magic.Mage)1 MageController (com.elmakers.mine.bukkit.api.magic.MageController)1 MagicAPI (com.elmakers.mine.bukkit.api.magic.MagicAPI)1 MaterialSet (com.elmakers.mine.bukkit.api.magic.MaterialSet)1 LostWand (com.elmakers.mine.bukkit.api.wand.LostWand)1 UndoList (com.elmakers.mine.bukkit.block.UndoList)1 MagicController (com.elmakers.mine.bukkit.magic.MagicController)1