mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 20:36:42 +00:00
Switch to Gradle. Use git log --follow for history.
This converts the project into a multi-module Gradle build. By default, Git does not show history past a rename, so use git log --follow to see further history.
This commit is contained in:
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Sets block from an iterator of {@link Map.Entry} containing a
|
||||
* {@link BlockVector} as the key and a {@link BaseBlock} as the value.
|
||||
*/
|
||||
public class BlockMapEntryPlacer implements Operation {
|
||||
|
||||
private final Extent extent;
|
||||
private final Iterator<Map.Entry<BlockVector, BaseBlock>> iterator;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent to set the blocks on
|
||||
* @param iterator the iterator
|
||||
*/
|
||||
public BlockMapEntryPlacer(Extent extent, Iterator<Map.Entry<BlockVector, BaseBlock>> iterator) {
|
||||
checkNotNull(extent);
|
||||
checkNotNull(iterator);
|
||||
this.extent = extent;
|
||||
this.iterator = iterator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<BlockVector, BaseBlock> entry = iterator.next();
|
||||
extent.setBlock(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Performs an undo or redo from a given {@link ChangeSet}.
|
||||
*/
|
||||
public class ChangeSetExecutor implements Operation {
|
||||
|
||||
public enum Type {UNDO, REDO}
|
||||
|
||||
private final Iterator<Change> iterator;
|
||||
private final Type type;
|
||||
private final UndoContext context;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param changeSet the change set
|
||||
* @param type type of change
|
||||
* @param context the undo context
|
||||
*/
|
||||
private ChangeSetExecutor(ChangeSet changeSet, Type type, UndoContext context) {
|
||||
checkNotNull(changeSet);
|
||||
checkNotNull(type);
|
||||
checkNotNull(context);
|
||||
|
||||
this.type = type;
|
||||
this.context = context;
|
||||
|
||||
if (type == Type.UNDO) {
|
||||
iterator = changeSet.backwardIterator();
|
||||
} else {
|
||||
iterator = changeSet.forwardIterator();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
while (iterator.hasNext()) {
|
||||
Change change = iterator.next();
|
||||
if (type == Type.UNDO) {
|
||||
change.undo(context);
|
||||
} else {
|
||||
change.redo(context);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new undo operation.
|
||||
*
|
||||
* @param changeSet the change set
|
||||
* @param context an undo context
|
||||
* @return an operation
|
||||
*/
|
||||
public static ChangeSetExecutor createUndo(ChangeSet changeSet, UndoContext context) {
|
||||
return new ChangeSetExecutor(changeSet, Type.UNDO, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new redo operation.
|
||||
*
|
||||
* @param changeSet the change set
|
||||
* @param context an undo context
|
||||
* @return an operation
|
||||
*/
|
||||
public static ChangeSetExecutor createRedo(ChangeSet changeSet, UndoContext context) {
|
||||
return new ChangeSetExecutor(changeSet, Type.REDO, context);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Executes a delegete operation, but returns to another operation upon
|
||||
* completing the delegate.
|
||||
*/
|
||||
public class DelegateOperation implements Operation {
|
||||
|
||||
private final Operation original;
|
||||
private Operation delegate;
|
||||
|
||||
/**
|
||||
* Create a new operation delegate.
|
||||
*
|
||||
* @param original the operation to return to
|
||||
* @param delegate the delegate operation to complete before returning
|
||||
*/
|
||||
public DelegateOperation(Operation original, Operation delegate) {
|
||||
checkNotNull(original);
|
||||
checkNotNull(delegate);
|
||||
this.original = original;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
delegate = delegate.resume(run);
|
||||
return delegate != null ? this : original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
delegate.cancel();
|
||||
original.cancel();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,249 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.CombinedRegionFunction;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
||||
import com.sk89q.worldedit.function.block.ExtentBlockCopy;
|
||||
import com.sk89q.worldedit.function.entity.ExtentEntityCopy;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.math.transform.Identity;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Makes a copy of a portion of one extent to another extent or another point.
|
||||
*
|
||||
* <p>This is a forward extent copy, meaning that it iterates over the blocks
|
||||
* in the source extent, and will copy as many blocks as there are in the
|
||||
* source. Therefore, interpolation will not occur to fill in the gaps.</p>
|
||||
*/
|
||||
public class ForwardExtentCopy implements Operation {
|
||||
|
||||
private final Extent source;
|
||||
private final Extent destination;
|
||||
private final Region region;
|
||||
private final Vector from;
|
||||
private final Vector to;
|
||||
private int repetitions = 1;
|
||||
private Mask sourceMask = Masks.alwaysTrue();
|
||||
private boolean removingEntities;
|
||||
private RegionFunction sourceFunction = null;
|
||||
private Transform transform = new Identity();
|
||||
private Transform currentTransform = null;
|
||||
private RegionVisitor lastVisitor;
|
||||
private int affected;
|
||||
|
||||
/**
|
||||
* Create a new copy using the region's lowest minimum point as the
|
||||
* "from" position.
|
||||
*
|
||||
* @param source the source extent
|
||||
* @param region the region to copy
|
||||
* @param destination the destination extent
|
||||
* @param to the destination position
|
||||
* @see #ForwardExtentCopy(Extent, Region, Vector, Extent, Vector) the main constructor
|
||||
*/
|
||||
public ForwardExtentCopy(Extent source, Region region, Extent destination, Vector to) {
|
||||
this(source, region, region.getMinimumPoint(), destination, to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new copy.
|
||||
*
|
||||
* @param source the source extent
|
||||
* @param region the region to copy
|
||||
* @param from the source position
|
||||
* @param destination the destination extent
|
||||
* @param to the destination position
|
||||
*/
|
||||
public ForwardExtentCopy(Extent source, Region region, Vector from, Extent destination, Vector to) {
|
||||
checkNotNull(source);
|
||||
checkNotNull(region);
|
||||
checkNotNull(from);
|
||||
checkNotNull(destination);
|
||||
checkNotNull(to);
|
||||
this.source = source;
|
||||
this.destination = destination;
|
||||
this.region = region;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transformation that will occur on every point.
|
||||
*
|
||||
* <p>The transformation will stack with each repetition.</p>
|
||||
*
|
||||
* @return a transformation
|
||||
*/
|
||||
public Transform getTransform() {
|
||||
return transform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the transformation that will occur on every point.
|
||||
*
|
||||
* @param transform a transformation
|
||||
* @see #getTransform()
|
||||
*/
|
||||
public void setTransform(Transform transform) {
|
||||
checkNotNull(transform);
|
||||
this.transform = transform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mask that gets applied to the source extent.
|
||||
*
|
||||
* <p>This mask can be used to filter what will be copied from the source.</p>
|
||||
*
|
||||
* @return a source mask
|
||||
*/
|
||||
public Mask getSourceMask() {
|
||||
return sourceMask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a mask that gets applied to the source extent.
|
||||
*
|
||||
* @param sourceMask a source mask
|
||||
* @see #getSourceMask()
|
||||
*/
|
||||
public void setSourceMask(Mask sourceMask) {
|
||||
checkNotNull(sourceMask);
|
||||
this.sourceMask = sourceMask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the function that gets applied to all source blocks <em>after</em>
|
||||
* the copy has been made.
|
||||
*
|
||||
* @return a source function, or null if none is to be applied
|
||||
*/
|
||||
public RegionFunction getSourceFunction() {
|
||||
return sourceFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the function that gets applied to all source blocks <em>after</em>
|
||||
* the copy has been made.
|
||||
*
|
||||
* @param function a source function, or null if none is to be applied
|
||||
*/
|
||||
public void setSourceFunction(RegionFunction function) {
|
||||
this.sourceFunction = function;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of repetitions left.
|
||||
*
|
||||
* @return the number of repetitions
|
||||
*/
|
||||
public int getRepetitions() {
|
||||
return repetitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of repetitions left.
|
||||
*
|
||||
* @param repetitions the number of repetitions
|
||||
*/
|
||||
public void setRepetitions(int repetitions) {
|
||||
checkArgument(repetitions >= 0, "number of repetitions must be non-negative");
|
||||
this.repetitions = repetitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether entities that are copied should be removed.
|
||||
*
|
||||
* @return true if removing
|
||||
*/
|
||||
public boolean isRemovingEntities() {
|
||||
return removingEntities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether entities that are copied should be removed.
|
||||
*
|
||||
* @param removingEntities true if removing
|
||||
*/
|
||||
public void setRemovingEntities(boolean removingEntities) {
|
||||
this.removingEntities = removingEntities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of affected objects.
|
||||
*
|
||||
* @return the number of affected
|
||||
*/
|
||||
public int getAffected() {
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
if (lastVisitor != null) {
|
||||
affected += lastVisitor.getAffected();
|
||||
lastVisitor = null;
|
||||
}
|
||||
|
||||
if (repetitions > 0) {
|
||||
repetitions--;
|
||||
|
||||
if (currentTransform == null) {
|
||||
currentTransform = transform;
|
||||
}
|
||||
|
||||
ExtentBlockCopy blockCopy = new ExtentBlockCopy(source, from, destination, to, currentTransform);
|
||||
RegionMaskingFilter filter = new RegionMaskingFilter(sourceMask, blockCopy);
|
||||
RegionFunction function = sourceFunction != null ? new CombinedRegionFunction(filter, sourceFunction) : filter;
|
||||
RegionVisitor blockVisitor = new RegionVisitor(region, function);
|
||||
|
||||
ExtentEntityCopy entityCopy = new ExtentEntityCopy(from, destination, to, currentTransform);
|
||||
entityCopy.setRemoving(removingEntities);
|
||||
List<? extends Entity> entities = source.getEntities(region);
|
||||
EntityVisitor entityVisitor = new EntityVisitor(entities.iterator(), entityCopy);
|
||||
|
||||
lastVisitor = blockVisitor;
|
||||
currentTransform = currentTransform.combine(transform);
|
||||
return new DelegateOperation(this, new OperationQueue(blockVisitor, entityVisitor));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
/**
|
||||
* An task that may be split into multiple steps to be run sequentially
|
||||
* immediately or at a varying or fixed interval. Operations should attempt
|
||||
* to break apart tasks into smaller tasks that can be completed in quicker
|
||||
* successions.
|
||||
*/
|
||||
public interface Operation {
|
||||
|
||||
/**
|
||||
* Complete the next step. If this method returns true, then the method may
|
||||
* be called again in the future, or possibly never. If this method
|
||||
* returns false, then this method should not be called again.
|
||||
*
|
||||
* @param run describes information about the current run
|
||||
* @return another operation to run that operation again, or null to stop
|
||||
* @throws WorldEditException an error
|
||||
*/
|
||||
Operation resume(RunContext run) throws WorldEditException;
|
||||
|
||||
/**
|
||||
* Abort the current task. After the this method is called,
|
||||
* {@link #resume(RunContext)} should not be called at any point in the
|
||||
* future. This method should not be called after successful completion of
|
||||
* the operation. This method must be called if the operation is
|
||||
* interrupted before completion.
|
||||
*/
|
||||
void cancel();
|
||||
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Executes multiple queues in order.
|
||||
*/
|
||||
public class OperationQueue implements Operation {
|
||||
|
||||
private final Deque<Operation> queue = new ArrayDeque<Operation>();
|
||||
private Operation current;
|
||||
|
||||
/**
|
||||
* Create a new queue containing no operations.
|
||||
*/
|
||||
public OperationQueue() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new queue with operations from the given collection.
|
||||
*
|
||||
* @param operations a collection of operations
|
||||
*/
|
||||
public OperationQueue(Collection<Operation> operations) {
|
||||
checkNotNull(operations);
|
||||
for (Operation operation : operations) {
|
||||
offer(operation);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new queue with operations from the given array.
|
||||
*
|
||||
* @param operation an array of operations
|
||||
*/
|
||||
public OperationQueue(Operation... operation) {
|
||||
checkNotNull(operation);
|
||||
for (Operation o : operation) {
|
||||
offer(o);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new operation to the queue.
|
||||
*
|
||||
* @param operation the operation
|
||||
*/
|
||||
public void offer(Operation operation) {
|
||||
checkNotNull(operation);
|
||||
queue.offer(operation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
if (current == null && !queue.isEmpty()) {
|
||||
current = queue.poll();
|
||||
}
|
||||
|
||||
if (current != null) {
|
||||
current = current.resume(run);
|
||||
|
||||
if (current == null) {
|
||||
current = queue.poll();
|
||||
}
|
||||
}
|
||||
|
||||
return current != null ? this : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
for (Operation operation : queue) {
|
||||
operation.cancel();
|
||||
}
|
||||
queue.clear();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
/**
|
||||
* Operation helper methods.
|
||||
*/
|
||||
public final class Operations {
|
||||
|
||||
private Operations() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete a given operation synchronously until it completes.
|
||||
*
|
||||
* @param op operation to execute
|
||||
* @throws WorldEditException WorldEdit exception
|
||||
*/
|
||||
public static void complete(Operation op) throws WorldEditException {
|
||||
while (op != null) {
|
||||
op = op.resume(new RunContext());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete a given operation synchronously until it completes. Catch all
|
||||
* errors that is not {@link MaxChangedBlocksException} for legacy reasons.
|
||||
*
|
||||
* @param op operation to execute
|
||||
* @throws MaxChangedBlocksException thrown when too many blocks have been changed
|
||||
*/
|
||||
public static void completeLegacy(Operation op) throws MaxChangedBlocksException {
|
||||
while (op != null) {
|
||||
try {
|
||||
op = op.resume(new RunContext());
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
throw e;
|
||||
} catch (WorldEditException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete a given operation synchronously until it completes. Re-throw all
|
||||
* {@link com.sk89q.worldedit.WorldEditException} exceptions as
|
||||
* {@link java.lang.RuntimeException}s.
|
||||
*
|
||||
* @param op operation to execute
|
||||
*/
|
||||
public static void completeBlindly(Operation op) {
|
||||
while (op != null) {
|
||||
try {
|
||||
op = op.resume(new RunContext());
|
||||
} catch (WorldEditException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
/**
|
||||
* Describes the current run.
|
||||
*/
|
||||
public class RunContext {
|
||||
|
||||
/**
|
||||
* Return whether the current operation should still continue running.
|
||||
*
|
||||
* <p>This method can be called frequently.</p>
|
||||
*
|
||||
* @return true if the operation should continue running
|
||||
*/
|
||||
public boolean shouldContinue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user