Search in sources :

Example 1 with UndoContext

use of com.sk89q.worldedit.history.UndoContext in project FastAsyncWorldEdit by IntellectualSites.

the class EditSession method undo.

// FAWE end
// FAWE start
/**
 * Restores all blocks to their initial state.
 *
 * @param editSession a new {@link EditSession} to perform the undo in
 */
public void undo(EditSession editSession) {
    UndoContext context = new UndoContext();
    // FAWE start - listen for inventory, flush & prepare changeset
    context.setExtent(editSession.bypassAll);
    ChangeSet changeSet = getChangeSet();
    setChangeSet(null);
    Operations.completeBlindly(ChangeSetExecutor.create(changeSet, context, ChangeSetExecutor.Type.UNDO, editSession.getBlockBag(), editSession.getLimit().INVENTORY_MODE));
    flushQueue();
    editSession.changes = 1;
}
Also used : UndoContext(com.sk89q.worldedit.history.UndoContext) BlockBagChangeSet(com.fastasyncworldedit.core.history.changeset.BlockBagChangeSet) ChangeSet(com.sk89q.worldedit.history.changeset.ChangeSet) AbstractChangeSet(com.fastasyncworldedit.core.history.changeset.AbstractChangeSet)

Example 2 with UndoContext

use of com.sk89q.worldedit.history.UndoContext in project FastAsyncWorldEdit by IntellectualSites.

the class EditSession method redo.

// FAWE end
/**
 * Sets to new state.
 *
 * @param editSession a new {@link EditSession} to perform the redo in
 */
public void redo(EditSession editSession) {
    UndoContext context = new UndoContext();
    // FAWE start - listen for inventory, flush & prepare changeset
    context.setExtent(editSession.bypassAll);
    ChangeSet changeSet = getChangeSet();
    setChangeSet(null);
    Operations.completeBlindly(ChangeSetExecutor.create(changeSet, context, ChangeSetExecutor.Type.REDO, editSession.getBlockBag(), editSession.getLimit().INVENTORY_MODE));
    flushQueue();
    editSession.changes = 1;
}
Also used : UndoContext(com.sk89q.worldedit.history.UndoContext) BlockBagChangeSet(com.fastasyncworldedit.core.history.changeset.BlockBagChangeSet) ChangeSet(com.sk89q.worldedit.history.changeset.ChangeSet) AbstractChangeSet(com.fastasyncworldedit.core.history.changeset.AbstractChangeSet)

Example 3 with UndoContext

use of com.sk89q.worldedit.history.UndoContext in project FastAsyncWorldEdit by IntellectualSites.

the class EditSession method setBlocks.

// FAWE start
public void setBlocks(ChangeSet changeSet, ChangeSetExecutor.Type type) {
    final UndoContext context = new UndoContext();
    context.setExtent(bypassAll);
    Operations.completeBlindly(ChangeSetExecutor.create(changeSet, context, type, getBlockBag(), getLimit().INVENTORY_MODE));
    flushQueue();
    changes = 1;
}
Also used : UndoContext(com.sk89q.worldedit.history.UndoContext)

Aggregations

UndoContext (com.sk89q.worldedit.history.UndoContext)3 AbstractChangeSet (com.fastasyncworldedit.core.history.changeset.AbstractChangeSet)2 BlockBagChangeSet (com.fastasyncworldedit.core.history.changeset.BlockBagChangeSet)2 ChangeSet (com.sk89q.worldedit.history.changeset.ChangeSet)2