Merge remote-tracking branch 'origin/master' into feature/mapping

This commit is contained in:
sk89q 2014-07-10 22:33:25 -07:00
commit 97a1664db5
5 changed files with 34 additions and 18 deletions

View File

@ -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<String> 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);
}
}

View File

@ -241,9 +241,15 @@ 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) {
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);

View File

@ -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

View File

@ -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));

View File

@ -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
}