From 393b0d3d7a6c82bb3a4d070c431c1fd0bdb3cfae Mon Sep 17 00:00:00 2001 From: sk89q Date: Wed, 9 Jul 2014 23:05:40 -0700 Subject: [PATCH 1/6] Handle when CommandException.getMessage() is null in CommandManager. Related to WORLDEDIT-3156. --- .../worldedit/extension/platform/CommandManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java b/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java index 466903332..0d52e4b8c 100644 --- a/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java +++ b/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java @@ -243,7 +243,13 @@ public final class CommandManager { actor.printRaw(t.getClass().getName() + ": " + t.getMessage()); t.printStackTrace(); } catch (CommandException e) { - actor.printError(e.getMessage()); + String message = e.getMessage(); + if (message != null) { + actor.printError(e.getMessage()); + } else + actor.printError("An unknown error has occurred! Please see console."); + logger.log(Level.SEVERE, "An unknown error occurred", e); + } } finally { EditSession editSession = locals.get(EditSession.class); From 4e69c7263fc8fac4c86c0bcdfccac3ee48fd70e2 Mon Sep 17 00:00:00 2001 From: sk89q Date: Wed, 9 Jul 2014 23:07:40 -0700 Subject: [PATCH 2/6] Fix a syntax error in 393b0d3d. --- .../com/sk89q/worldedit/extension/platform/CommandManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java b/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java index 0d52e4b8c..f08714d61 100644 --- a/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java +++ b/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java @@ -246,7 +246,7 @@ public final class CommandManager { String message = e.getMessage(); if (message != null) { actor.printError(e.getMessage()); - } else + } else { actor.printError("An unknown error has occurred! Please see console."); logger.log(Level.SEVERE, "An unknown error occurred", e); } From dd497fdcb199f41d951389da7c2990cb42939a04 Mon Sep 17 00:00:00 2001 From: sk89q Date: Wed, 9 Jul 2014 23:08:17 -0700 Subject: [PATCH 3/6] Send WrappedCommandException to the logger. --- .../com/sk89q/worldedit/extension/platform/CommandManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java b/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java index f08714d61..49b21d797 100644 --- a/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java +++ b/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java @@ -241,7 +241,7 @@ public final class CommandManager { Throwable t = e.getCause(); actor.printError("Please report this error: [See console]"); actor.printRaw(t.getClass().getName() + ": " + t.getMessage()); - t.printStackTrace(); + logger.log(Level.SEVERE, "An unexpected error while handling a WorldEdit command", t); } catch (CommandException e) { String message = e.getMessage(); if (message != null) { From 728352612383041a1a4a49aff30bb5e6a4017446 Mon Sep 17 00:00:00 2001 From: sk89q Date: Thu, 10 Jul 2014 00:30:43 -0700 Subject: [PATCH 4/6] Fixes commands registered with the legacy handler not tab completing players. Closes WORLDEDIT-3151. --- .../java/com/sk89q/bukkit/util/DynamicPluginCommand.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/bukkit/java/com/sk89q/bukkit/util/DynamicPluginCommand.java b/src/bukkit/java/com/sk89q/bukkit/util/DynamicPluginCommand.java index c48df659c..479681c6b 100644 --- a/src/bukkit/java/com/sk89q/bukkit/util/DynamicPluginCommand.java +++ b/src/bukkit/java/com/sk89q/bukkit/util/DynamicPluginCommand.java @@ -30,7 +30,6 @@ import org.bukkit.command.TabCompleter; import org.bukkit.plugin.Plugin; import java.util.Arrays; -import java.util.Collections; import java.util.List; /** @@ -81,10 +80,10 @@ public class DynamicPluginCommand extends org.bukkit.command.Command implements @Override public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - if (owner instanceof TabCompleter) { + if (registeredWith instanceof CommandInspector) { return ((TabCompleter) owner).onTabComplete(sender, this, alias, args); } else { - return Collections.emptyList(); + return super.tabComplete(sender, alias, args); } } From 66a51636a3f816ef7ccc464a564a23f0805f13ef Mon Sep 17 00:00:00 2001 From: sk89q Date: Thu, 10 Jul 2014 00:47:36 -0700 Subject: [PATCH 5/6] Ellipsoid-based region selectors no longer starts primary at (0, 0, 0). Fixes WORLDEDIT-2968. --- .../regions/selector/EllipsoidRegionSelector.java | 9 ++++++++- .../worldedit/regions/selector/SphereRegionSelector.java | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java b/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java index 3aed786a1..21a2eee6e 100644 --- a/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java +++ b/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java @@ -41,6 +41,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class EllipsoidRegionSelector extends com.sk89q.worldedit.regions.EllipsoidRegionSelector implements RegionSelector, CUIRegion { protected EllipsoidRegion region; + protected boolean started = false; /** * Create a new selector. @@ -113,11 +114,17 @@ public class EllipsoidRegionSelector extends com.sk89q.worldedit.regions.Ellipso region.setCenter(pos.toBlockVector()); region.setRadius(new Vector()); + started = true; + return true; } @Override public boolean selectSecondary(Vector pos) { + if (!started) { + return false; + } + final Vector diff = pos.subtract(region.getCenter()); final Vector minRadius = Vector.getMaximum(diff, diff.multiply(-1.0)); region.extendRadius(minRadius); @@ -153,7 +160,7 @@ public class EllipsoidRegionSelector extends com.sk89q.worldedit.regions.Ellipso @Override public boolean isDefined() { - return region.getRadius().lengthSq() > 0; + return started && region.getRadius().lengthSq() > 0; } @Override diff --git a/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java b/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java index f6f043778..002ba7577 100644 --- a/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java +++ b/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java @@ -80,6 +80,10 @@ public class SphereRegionSelector extends EllipsoidRegionSelector { @Override public boolean selectSecondary(Vector pos) { + if (!started) { + return false; + } + final double radiusScalar = Math.ceil(pos.distance(region.getCenter())); region.setRadius(new Vector(radiusScalar, radiusScalar, radiusScalar)); From 91d3292d81ec60621926d9e314a38f22582e6ad3 Mon Sep 17 00:00:00 2001 From: sk89q Date: Thu, 10 Jul 2014 01:04:15 -0700 Subject: [PATCH 6/6] Call editSession.setBlock() in SnapshotRestore. Fixes WORLDEDIT-2879. --- .../world/snapshot/SnapshotRestore.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java b/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java index 51db687ce..68e93213d 100644 --- a/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java +++ b/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java @@ -19,25 +19,25 @@ package com.sk89q.worldedit.world.snapshot; -import java.io.IOException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.world.chunk.Chunk; -import com.sk89q.worldedit.world.storage.ChunkStore; -import com.sk89q.worldedit.world.DataException; -import com.sk89q.worldedit.world.storage.MissingChunkException; -import com.sk89q.worldedit.world.storage.MissingWorldException; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.world.DataException; +import com.sk89q.worldedit.world.chunk.Chunk; +import com.sk89q.worldedit.world.storage.ChunkStore; +import com.sk89q.worldedit.world.storage.MissingChunkException; +import com.sk89q.worldedit.world.storage.MissingWorldException; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; /** * @@ -168,7 +168,7 @@ public class SnapshotRestore { for (Vector pos : entry.getValue()) { try { BaseBlock block = chunk.getBlock(pos); - editSession.rawSetBlock(pos, block); + editSession.setBlock(pos, block); } catch (DataException e) { // this is a workaround: just ignore for now }