From 46887623bc2ea1ae2aeebf99ed6e1fdac300de67 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 22 Aug 2016 23:10:51 +1000 Subject: [PATCH] Allow EditSession construction with no allowed regions Not sure why WorldEdit creates an EditSession for commands which clearly do not need one. This change now means players without an allowed region can use informational and navigation commands without a region. The error will be instead thrown when the EditSession is first used. --- core/src/main/java/com/sk89q/worldedit/EditSession.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/sk89q/worldedit/EditSession.java b/core/src/main/java/com/sk89q/worldedit/EditSession.java index 75c4eb73..76e37984 100644 --- a/core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -248,9 +248,6 @@ public class EditSession implements Extent { throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY); } } - if (allowedRegions != null && allowedRegions.length == 0) { - throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_NO_REGION); - } this.blockBag = blockBag; this.originalLimit = limit; this.limit = limit.copy(); @@ -273,7 +270,11 @@ public class EditSession implements Extent { } } if (allowedRegions != null) { - this.extent = new ProcessedWEExtent(this.extent, allowedRegions, limit); + if (allowedRegions.length == 0) { + this.extent = new NullExtent(this.extent, BBC.NO_REGION); + } else { + this.extent = new ProcessedWEExtent(this.extent, allowedRegions, limit); + } } this.extent = wrapExtent(this.extent, bus, event, Stage.BEFORE_HISTORY); }