Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor

public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
super(extent, mask, region);
World world = ExtentTraverser.getWorldFromExtent(extent);
if (world == null) {
throw new UnsupportedOperationException(
"World is required for PlacementStateProcessor but none found in given extent.");
}
World world = getWorldFromExtent(extent);
BukkitWorld bukkitWorld;
if (world instanceof WorldWrapper wrapper) {
bukkitWorld = (BukkitWorld) wrapper.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor

public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
super(extent, mask, region);
World world = ExtentTraverser.getWorldFromExtent(extent);
if (world == null) {
throw new UnsupportedOperationException(
"World is required for PlacementStateProcessor but none found in given extent.");
}
World world = getWorldFromExtent(extent);
BukkitWorld bukkitWorld;
if (world instanceof WorldWrapper wrapper) {
bukkitWorld = (BukkitWorld) wrapper.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor

public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
super(extent, mask, region);
World world = ExtentTraverser.getWorldFromExtent(extent);
if (world == null) {
throw new UnsupportedOperationException(
"World is required for PlacementStateProcessor but none found in given extent.");
}
World world = getWorldFromExtent(extent);
BukkitWorld bukkitWorld;
if (world instanceof WorldWrapper wrapper) {
bukkitWorld = (BukkitWorld) wrapper.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor

public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
super(extent, mask, region);
World world = ExtentTraverser.getWorldFromExtent(extent);
if (world == null) {
throw new UnsupportedOperationException(
"World is required for PlacementStateProcessor but none found in given extent.");
}
World world = getWorldFromExtent(extent);
BukkitWorld bukkitWorld;
if (world instanceof WorldWrapper wrapper) {
bukkitWorld = (BukkitWorld) wrapper.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor

public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
super(extent, mask, region);
World world = ExtentTraverser.getWorldFromExtent(extent);
if (world == null) {
throw new UnsupportedOperationException(
"World is required for PlacementStateProcessor but none found in given extent.");
}
World world = getWorldFromExtent(extent);
BukkitWorld bukkitWorld;
if (world instanceof WorldWrapper wrapper) {
bukkitWorld = (BukkitWorld) wrapper.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor

public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
super(extent, mask, region);
World world = ExtentTraverser.getWorldFromExtent(extent);
if (world == null) {
throw new UnsupportedOperationException(
"World is required for PlacementStateProcessor but none found in given extent.");
}
World world = getWorldFromExtent(extent);
BukkitWorld bukkitWorld;
if (world instanceof WorldWrapper wrapper) {
bukkitWorld = (BukkitWorld) wrapper.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor

public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
super(extent, mask, region);
World world = ExtentTraverser.getWorldFromExtent(extent);
if (world == null) {
throw new UnsupportedOperationException(
"World is required for PlacementStateProcessor but none found in given extent.");
}
World world = getWorldFromExtent(extent);
BukkitWorld bukkitWorld;
if (world instanceof WorldWrapper wrapper) {
bukkitWorld = (BukkitWorld) wrapper.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor

public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
super(extent, mask, region);
World world = ExtentTraverser.getWorldFromExtent(extent);
if (world == null) {
throw new UnsupportedOperationException(
"World is required for PlacementStateProcessor but none found in given extent.");
}
World world = getWorldFromExtent(extent);
BukkitWorld bukkitWorld;
if (world instanceof WorldWrapper wrapper) {
bukkitWorld = (BukkitWorld) wrapper.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor

public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
super(extent, mask, region);
World world = ExtentTraverser.getWorldFromExtent(extent);
if (world == null) {
throw new UnsupportedOperationException(
"World is required for PlacementStateProcessor but none found in given extent.");
}
World world = getWorldFromExtent(extent);
BukkitWorld bukkitWorld;
if (world instanceof WorldWrapper wrapper) {
bukkitWorld = (BukkitWorld) wrapper.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.queue.IChunkSet;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.fastasyncworldedit.core.util.ExtentTraverser;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
Expand All @@ -24,6 +25,7 @@
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockCategory;
Expand Down Expand Up @@ -114,6 +116,18 @@ protected PlacementStateProcessor(
this.finished = finished;
}

protected static World getWorldFromExtent(Extent extent) throws UnsupportedOperationException {
World world = ExtentTraverser.getWorldFromExtent(extent);
if (world == null) {
throw new UnsupportedOperationException(
"World is required for PlacementStateProcessor but none found in given extent (" + extent
.getClass()
.getName() + ").");
}
return world;

}

private static void setup() {
NullExtent nullExtent = new NullExtent(
com.sk89q.worldedit.extent.NullExtent.INSTANCE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.Optional;

public class ExtentTraverser<T extends Extent> {

Expand Down Expand Up @@ -45,7 +46,8 @@ public static World getWorldFromExtent(Extent extent) {
} else if (extent instanceof ParallelQueueExtent pqe) {
return ((SingleThreadQueueExtent) pqe.getExtent()).getWorld();
} else {
return new ExtentTraverser<>(extent).findAndGet(World.class);
return Optional.ofNullable(new ExtentTraverser<>(extent).findAndGet(World.class)).orElseGet(() -> Optional.ofNullable(
new ExtentTraverser<>(extent).findAndGet(EditSession.class)).map(EditSession::getWorld).orElse(null));
}
}

Expand Down
Loading