From 198427dc3d928cfc25fafffd4af00753a8e6b7b5 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Mon, 29 Jul 2019 21:05:31 -0400 Subject: [PATCH] fix more compile errors --- .../boydti/fawe/beta/DelegateFilterBlock.java | 5 ++++ .../com/boydti/fawe/object/FawePlayer.java | 14 +++++------ .../java/com/sk89q/worldedit/EditSession.java | 24 +++++++++++++++++++ .../worldedit/command/ClipboardCommands.java | 3 ++- .../sk89q/worldedit/command/MaskCommands.java | 6 ++--- .../worldedit/command/RegionCommands.java | 4 ++-- .../worldedit/command/SchematicCommands.java | 2 +- .../worldedit/extension/platform/Actor.java | 2 +- .../com/sk89q/worldedit/extent/Extent.java | 5 ---- 9 files changed, 44 insertions(+), 21 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java index 01c34a309..4cb06ff5e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java @@ -650,6 +650,11 @@ public class DelegateFilterBlock extends FilterBlock { return parent.getBlock(position); } + @Override + public BlockType getBlockType(BlockVector3 position) { + return parent.getBlockType(position); + } + @Override public BaseBlock getFullBlock(BlockVector3 position) { return parent.getFullBlock(position); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java index fbb94dac7..66b4622f0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java @@ -265,18 +265,18 @@ public abstract class FawePlayer extends Metadatable { // Queue for async tasks private AtomicInteger runningCount = new AtomicInteger(); - private SimpleAsyncNotifyQueue asyncNotifyQueue = new SimpleAsyncNotifyQueue((t, e) -> { - while (e.getCause() != null) { - e = e.getCause(); + private SimpleAsyncNotifyQueue asyncNotifyQueue = new SimpleAsyncNotifyQueue((thread, throwable) -> { + while (throwable.getCause() != null) { + throwable = throwable.getCause(); } - if (e instanceof WorldEditException) { - sendMessage(e.getLocalizedMessage()); + if (throwable instanceof WorldEditException) { + sendMessage(throwable.getLocalizedMessage()); } else { - FaweException fe = FaweException.get(e); + FaweException fe = FaweException.get(throwable); if (fe != null) { sendMessage(fe.getMessage()); } else { - e.printStackTrace(); + throwable.printStackTrace(); } } }); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 251694c32..ad37cbe87 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -103,6 +103,7 @@ import com.sk89q.worldedit.internal.expression.runtime.ExpressionTimeoutExceptio import com.sk89q.worldedit.internal.expression.runtime.RValue; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.MathUtils; import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.Vector2; @@ -1403,6 +1404,29 @@ public class EditSession extends AbstractDelegateExtent implements SimpleWorld, return replaceBlocks(region, mask, pattern); } + /** + * Sets the blocks at the center of the given region to the given pattern. + * If the center sits between two blocks on a certain axis, then two blocks + * will be placed to mark the center. + * + * @param region the region to find the center of + * @param pattern the replacement pattern + * @return the number of blocks placed + * @throws MaxChangedBlocksException thrown if too many blocks are changed + */ + public int center(Region region, Pattern pattern) throws MaxChangedBlocksException { + checkNotNull(region); + checkNotNull(pattern); + + Vector3 center = region.getCenter(); + Region centerRegion = new CuboidRegion( + getWorld(), // Causes clamping of Y range + BlockVector3.at(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())), + BlockVector3.at(MathUtils.roundHalfUp(center.getX()), + center.getY(), MathUtils.roundHalfUp(center.getZ()))); + return setBlocks(centerRegion, pattern); + } + /** * Make the faces of the given region as if it was a {@link CuboidRegion}. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index ea62cb9db..4e24f8282 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -126,7 +126,8 @@ public class ClipboardCommands { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); - long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); + long volume = + ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1); FaweLimit limit = FawePlayer.wrap(player).getLimit(); if (volume >= limit.MAX_CHECKS) { throw FaweException.MAX_CHECKS; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java index b9bb4a190..149b8b1ef 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java @@ -88,8 +88,7 @@ public class MaskCommands { } @Command( - name = "false", - aliases = {"#false"}, + name = "#false", desc = "Always false" ) public Mask falseMask(Extent extent) { @@ -97,8 +96,7 @@ public class MaskCommands { } @Command( - name = "true", - aliases = {"#true"}, + name = "#true", desc = "Always true" ) public Mask trueMask(Extent extent) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 1073a665a..623bfc4d3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -547,7 +547,7 @@ public class RegionCommands { boolean skipEntities, @Switch(name = 'a', desc = "Ignore air blocks") boolean ignoreAirBlocks, - @Switch(name = 'm', desc = "Source mask") + @ArgFlag(name = "m", desc = "Source mask") Mask sourceMask, InjectedValueAccess context) throws WorldEditException { player.checkConfirmationStack(() -> { @@ -677,7 +677,7 @@ public class RegionCommands { int thickness, @Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air") Pattern pattern, - @Switch(name = 'm', desc = "Mask to hollow with") Mask mask, + @ArgFlag(name = "m", desc = "Mask to hollow with") Mask mask, InjectedValueAccess context) throws WorldEditException { checkCommandArgument(thickness >= 0, "Thickness must be >= 0"); Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 954ac76e3..3496c042c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -577,7 +577,7 @@ public class SchematicCommands { boolean oldFirst, @Switch(name = 'n', desc = "Sort by date, newest first") boolean newFirst, - @Switch(name = 'f', desc = "Restricts by format.") + @ArgFlag(name = 'f', desc = "Restricts by format.") String formatName, @Arg(name = "filter", desc = "Filter for schematics", def = "all") String filter) throws WorldEditException { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java index cdcba32a2..de8adb1e5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java @@ -83,7 +83,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject { */ void print(Component component); - /** + /**F * Returns true if the actor can destroy bedrock. * * @return true if bedrock can be broken by the actor diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index 03da1338c..955acb05c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -52,7 +52,6 @@ import com.sk89q.worldedit.registry.state.PropertyGroup; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; @@ -620,8 +619,4 @@ public interface Extent extends InputExtent, OutputExtent { return count; } - default World getWorld() { - return null; - } - }