From f5f5a55b4ca51b19edfa7881c34d69ad1b76fbc0 Mon Sep 17 00:00:00 2001 From: IronApollo Date: Tue, 15 Sep 2020 22:34:45 -0400 Subject: [PATCH] Fix limits --- .../processors/LimitProcessor.java | 47 ------------------- .../boydti/fawe/util/EditSessionBuilder.java | 13 ++--- .../platform/PlatformCommandManager.java | 6 ++- 3 files changed, 8 insertions(+), 58 deletions(-) delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitProcessor.java diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitProcessor.java deleted file mode 100644 index 2485ba5c2..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitProcessor.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.boydti.fawe.beta.implementation.processors; - -import com.boydti.fawe.beta.IBatchProcessor; -import com.boydti.fawe.beta.IChunk; -import com.boydti.fawe.beta.IChunkGet; -import com.boydti.fawe.beta.IChunkSet; -import com.boydti.fawe.object.FaweLimit; -import com.boydti.fawe.object.exception.FaweException; -import com.sk89q.worldedit.extent.Extent; - -public class LimitProcessor implements IBatchProcessor { - private final FaweLimit limit; - private final IBatchProcessor parent; - public LimitProcessor(FaweLimit limit, IBatchProcessor parent) { - this.limit = limit; - this.parent = parent; - } - - @Override - public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) { - try { - return parent.processSet(chunk, get, set); - } catch (FaweException e) { - if (!limit.MAX_CHANGES()) { - throw e; - } - return null; - } - } - - @Override - public boolean processGet(int chunkX, int chunkZ) { - try { - return parent.processGet(chunkX, chunkZ); - } catch (FaweException e) { - if (!limit.MAX_CHECKS()) { - throw e; - } - return false; - } - } - - @Override - public Extent construct(Extent child) { - return new LimitExtent(parent.construct(child), limit); - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java index 152ec2475..3bafe998b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java @@ -2,10 +2,9 @@ package com.boydti.fawe.util; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IQueueChunk; import com.boydti.fawe.beta.IQueueExtent; -import com.boydti.fawe.beta.implementation.processors.LimitProcessor; +import com.boydti.fawe.beta.implementation.processors.LimitExtent; import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory; @@ -383,14 +382,8 @@ public class EditSessionBuilder { } else { // this.extent = new HeightBoundExtent(this.extent, this.limit, 0, world.getMaxY()); } - IBatchProcessor limitProcessor = regionExtent; - if (limit != null && !limit.isUnlimited()) { - limitProcessor = new LimitProcessor(limit, limitProcessor); - } - if (regionExtent != null && queue != null && combineStages) { - queue.addProcessor(limitProcessor); - } else if (regionExtent != null) { - this.extent = limitProcessor.construct(regionExtent.getExtent()); + if (limit != null && !limit.isUnlimited() && regionExtent != null) { + this.extent = new LimitExtent(regionExtent, limit); } if (this.limit.STRIP_NBT != null && !this.limit.STRIP_NBT.isEmpty()) { System.out.println("TODO add batch processor for strip nbt"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 05e963e6d..4444a4524 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -721,7 +721,11 @@ public final class PlatformCommandManager { } actor.printError(e.getRichMessage()); } catch (CommandExecutionException e) { - handleUnknownException(actor, e.getCause()); + if (e.getCause() instanceof FaweException) { + actor.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason", ((FaweException)e.getCause()).getComponent())); + } else { + handleUnknownException(actor, e.getCause()); + } } catch (CommandException e) { Component msg = e.getRichMessage(); if (msg != TextComponent.empty()) {