Skip to content

Commit

Permalink
Deprecate MultiStageReorder and ReorderMode (EngineHub#1999)
Browse files Browse the repository at this point in the history
* Start deprecating MultiStage reorder

* Rather than changing behaviour just deprecate

* Add deprecation message

* Apply PR review notes
  • Loading branch information
me4502 authored Jun 12, 2022
1 parent 7cc90a7 commit f667474
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
22 changes: 19 additions & 3 deletions worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public enum Stage {
* NONE = Place blocks without worrying about placement order.
* </p>
*/
@Deprecated
public enum ReorderMode {
MULTI_STAGE("multi"),
FAST("fast"),
Expand Down Expand Up @@ -213,6 +214,7 @@ public String getDisplayName() {

private final @Nullable List<TracingExtent> tracingExtents;

@Deprecated
private ReorderMode reorderMode = ReorderMode.FAST;

private Mask oldMask;
Expand Down Expand Up @@ -363,6 +365,7 @@ public void enableStandardMode() {
*
* @param reorderMode The reorder mode
*/
@Deprecated
public void setReorderMode(ReorderMode reorderMode) {
if (reorderMode == ReorderMode.FAST && sideEffectExtent == null) {
throw new IllegalArgumentException("An EditSession without a fast mode tried to use it for reordering!");
Expand Down Expand Up @@ -406,6 +409,7 @@ public void setReorderMode(ReorderMode reorderMode) {
*
* @return the reorder mode
*/
@Deprecated
public ReorderMode getReorderMode() {
return reorderMode;
}
Expand Down Expand Up @@ -451,7 +455,7 @@ public void setBlockChangeLimit(int limit) {
* Returns queue status.
*
* @return whether the queue is enabled
* @deprecated Use {@link EditSession#getReorderMode()} with MULTI_STAGE instead.
* @deprecated Use {@link EditSession#isBufferingEnabled()} instead.
*/
@Deprecated
public boolean isQueueEnabled() {
Expand All @@ -461,7 +465,7 @@ public boolean isQueueEnabled() {
/**
* Queue certain types of block for better reproduction of those blocks.
*
* @deprecated Use {@link EditSession#setReorderMode(ReorderMode)} with MULTI_STAGE instead.
* @deprecated There is no specific replacement, instead enable what you want specifically.
*/
@Deprecated
public void enableQueue() {
Expand All @@ -471,7 +475,7 @@ public void enableQueue() {
/**
* Disable the queue. This will flush the session.
*
* @deprecated Use {@link EditSession#setReorderMode(ReorderMode)} with another mode instead.
* @deprecated Use {@link EditSession#disableBuffering()} instead.
*/
@Deprecated
public void disableQueue() {
Expand Down Expand Up @@ -614,6 +618,15 @@ public void setBatchingChunks(boolean batchingChunks) {
chunkBatchingExtent.setEnabled(batchingChunks);
}

/**
* Check if this session has any buffering extents enabled.
*
* @return {@code true} if any extents are buffering
*/
public boolean isBufferingEnabled() {
return isBatchingChunks() || (sideEffectExtent != null && sideEffectExtent.isPostEditSimulationEnabled());
}

/**
* Disable all buffering extents.
*
Expand All @@ -625,6 +638,9 @@ public void disableBuffering() {
if (commitRequired()) {
internalFlushSession();
}
if (sideEffectExtent != null) {
sideEffectExtent.setPostEditSimulationEnabled(false);
}
setReorderMode(ReorderMode.NONE);
if (chunkBatchingExtent != null) {
chunkBatchingExtent.setEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.SideEffectSet;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.world.World;
Expand Down Expand Up @@ -1120,6 +1119,7 @@ public void setFastMode(boolean fastMode) {
*
* @return The reorder mode
*/
@Deprecated
public EditSession.ReorderMode getReorderMode() {
return reorderMode;
}
Expand All @@ -1129,6 +1129,7 @@ public EditSession.ReorderMode getReorderMode() {
*
* @param reorderMode The reorder mode
*/
@Deprecated
public void setReorderMode(EditSession.ReorderMode reorderMode) {
this.reorderMode = reorderMode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.AbstractBufferingExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.world.SideEffectExtent;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.OperationQueue;
import com.sk89q.worldedit.function.operation.RunContext;
Expand All @@ -42,7 +43,10 @@

/**
* Re-orders blocks into several stages.
*
* @deprecated Use {@link SideEffectExtent} with {@link SideEffectExtent#setPostEditSimulationEnabled} instead.
*/
@Deprecated
public class MultiStageReorder extends AbstractBufferingExtent implements ReorderingExtent {

private static final Map<BlockType, PlacementPriority> priorityMap = new HashMap<>();
Expand Down

0 comments on commit f667474

Please sign in to comment.