This commit is contained in:
TomyLobo 2011-11-23 02:29:48 +01:00
parent 1a57f6e95d
commit 7e13b60a51
161 changed files with 1433 additions and 1412 deletions

View File

@ -21,7 +21,10 @@ package com.sk89q.bukkit.migration;
public interface PermissionsProvider { public interface PermissionsProvider {
public boolean hasPermission(String name, String permission); public boolean hasPermission(String name, String permission);
public boolean hasPermission(String worldName, String name, String permission); public boolean hasPermission(String worldName, String name, String permission);
public boolean inGroup(String player, String group); public boolean inGroup(String player, String group);
public String[] getGroups(String player); public String[] getGroups(String player);
} }

View File

@ -67,5 +67,4 @@ public @interface Command {
* meaning that if it is given it must have a value * meaning that if it is given it must have a value
*/ */
String flags() default ""; String flags() default "";
} }

View File

@ -56,7 +56,6 @@ import com.sk89q.util.StringUtil;
* @param <T> command sender class * @param <T> command sender class
*/ */
public abstract class CommandsManager<T> { public abstract class CommandsManager<T> {
/** /**
* Logger for general errors. * Logger for general errors.
*/ */
@ -70,8 +69,7 @@ public abstract class CommandsManager<T> {
* the key of the command name (one for each alias) with the * the key of the command name (one for each alias) with the
* method. * method.
*/ */
protected Map<Method, Map<String, Method>> commands protected Map<Method, Map<String, Method>> commands = new HashMap<Method, Map<String, Method>>();
= new HashMap<Method, Map<String, Method>>();
/** /**
* Used to store the instances associated with a method. * Used to store the instances associated with a method.
@ -256,7 +254,8 @@ public abstract class CommandsManager<T> {
char[] flags = cmd.flags().toCharArray(); char[] flags = cmd.flags().toCharArray();
for (int i = 0; i < flags.length; ++i) { for (int i = 0; i < flags.length; ++i) {
if (flags.length > i + 1 && flags[i + 1] == ':') { if (flags.length > i + 1 && flags[i + 1] == ':') {
i++; continue; i++;
continue;
} }
flagChars.add(flags[i]); flagChars.add(flags[i]);
} }
@ -294,7 +293,6 @@ public abstract class CommandsManager<T> {
command.append(args[i] + " "); command.append(args[i] + " ");
} }
Map<String, Method> map = commands.get(method); Map<String, Method> map = commands.get(method);
boolean found = false; boolean found = false;
@ -430,16 +428,19 @@ public abstract class CommandsManager<T> {
CommandContext context = new CommandContext(newArgs, valueFlags); CommandContext context = new CommandContext(newArgs, valueFlags);
if (context.argsLength() < cmd.min()) if (context.argsLength() < cmd.min()) {
throw new CommandUsageException("Too few arguments.", getUsage(args, level, cmd)); throw new CommandUsageException("Too few arguments.", getUsage(args, level, cmd));
}
if (cmd.max() != -1 && context.argsLength() > cmd.max()) if (cmd.max() != -1 && context.argsLength() > cmd.max()) {
throw new CommandUsageException("Too many arguments.", getUsage(args, level, cmd)); throw new CommandUsageException("Too many arguments.", getUsage(args, level, cmd));
}
for (char flag : context.getFlags()) { for (char flag : context.getFlags()) {
if (!newFlags.contains(flag)) if (!newFlags.contains(flag)) {
throw new CommandUsageException("Unknown flag: " + flag, getUsage(args, level, cmd)); throw new CommandUsageException("Unknown flag: " + flag, getUsage(args, level, cmd));
} }
}
methodArgs[0] = context; methodArgs[0] = context;

View File

@ -5,6 +5,7 @@ import java.lang.reflect.InvocationTargetException;
public class SimpleInjector<T> implements Injector { public class SimpleInjector<T> implements Injector {
private final T injectionObject; private final T injectionObject;
public SimpleInjector(T injectionObject) { public SimpleInjector(T injectionObject) {
this.injectionObject = injectionObject; this.injectionObject = injectionObject;
} }

View File

@ -36,6 +36,7 @@ import java.util.Map;
public class YAMLNode { public class YAMLNode {
protected Map<String, Object> root; protected Map<String, Object> root;
private boolean writeDefaults; private boolean writeDefaults;
public YAMLNode(Map<String, Object> root, boolean writeDefaults) { public YAMLNode(Map<String, Object> root, boolean writeDefaults) {
this.root = root; this.root = root;
this.writeDefaults = writeDefaults; this.writeDefaults = writeDefaults;

View File

@ -171,7 +171,8 @@ public class YAMLProcessor extends YAMLNode {
} }
yaml.dump(root, writer); yaml.dump(root, writer);
return true; return true;
} catch (IOException e) {} finally { } catch (IOException e) {
} finally {
try { try {
if (stream != null) { if (stream != null) {
stream.close(); stream.close();

View File

@ -287,16 +287,15 @@ public class CuboidClipboard {
* @param noAir * @param noAir
* @throws MaxChangedBlocksException * @throws MaxChangedBlocksException
*/ */
public void place(EditSession editSession, Vector pos, boolean noAir) public void place(EditSession editSession, Vector pos, boolean noAir) throws MaxChangedBlocksException {
throws MaxChangedBlocksException {
for (int x = 0; x < size.getBlockX(); ++x) { for (int x = 0; x < size.getBlockX(); ++x) {
for (int y = 0; y < size.getBlockY(); ++y) { for (int y = 0; y < size.getBlockY(); ++y) {
for (int z = 0; z < size.getBlockZ(); ++z) { for (int z = 0; z < size.getBlockZ(); ++z) {
if (noAir && data[x][y][z].isAir()) if (noAir && data[x][y][z].isAir()) {
continue; continue;
}
editSession.setBlock(new Vector(x, y, z).add(pos), editSession.setBlock(new Vector(x, y, z).add(pos), data[x][y][z]);
data[x][y][z]);
} }
} }
} }

View File

@ -327,20 +327,17 @@ public class EditSession {
if (BlockType.shouldPlaceLast(block.getType())) { if (BlockType.shouldPlaceLast(block.getType())) {
// Place torches, etc. last // Place torches, etc. last
queueLast.put(pt.toBlockVector(), block); queueLast.put(pt.toBlockVector(), block);
return !(getBlockType(pt) == block.getType() return !(getBlockType(pt) == block.getType() && getBlockData(pt) == block.getData());
&& getBlockData(pt) == block.getData());
} else if (BlockType.shouldPlaceFinal(block.getType())) { } else if (BlockType.shouldPlaceFinal(block.getType())) {
// Place signs, reed, etc even later // Place signs, reed, etc even later
queueFinal.put(pt.toBlockVector(), block); queueFinal.put(pt.toBlockVector(), block);
return !(getBlockType(pt) == block.getType() return !(getBlockType(pt) == block.getType() && getBlockData(pt) == block.getData());
&& getBlockData(pt) == block.getData());
} else if (BlockType.shouldPlaceLast(getBlockType(pt))) { } else if (BlockType.shouldPlaceLast(getBlockType(pt))) {
// Destroy torches, etc. first // Destroy torches, etc. first
rawSetBlock(pt, new BaseBlock(BlockID.AIR)); rawSetBlock(pt, new BaseBlock(BlockID.AIR));
} else { } else {
queueAfter.put(pt.toBlockVector(), block); queueAfter.put(pt.toBlockVector(), block);
return !(getBlockType(pt) == block.getType() return !(getBlockType(pt) == block.getType() && getBlockData(pt) == block.getData());
&& getBlockData(pt) == block.getData());
} }
} }
@ -403,6 +400,7 @@ public class EditSession {
return world.getBlockData(pt); return world.getBlockData(pt);
} }
/** /**
* Gets the block type at a position x, y, z. * Gets the block type at a position x, y, z.
* *
@ -2033,13 +2031,11 @@ public class EditSession {
final int ceilRadiusZ = (int) Math.ceil(radiusZ); final int ceilRadiusZ = (int) Math.ceil(radiusZ);
double nextXn = 0; double nextXn = 0;
forX: forX: for (int x = 0; x <= ceilRadiusX; ++x) {
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn; final double xn = nextXn;
nextXn = (x + 1) * invRadiusX; nextXn = (x + 1) * invRadiusX;
double nextZn = 0; double nextZn = 0;
forZ: forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
for (int z = 0; z <= ceilRadiusZ; ++z) {
final double zn = nextZn; final double zn = nextZn;
nextZn = (z + 1) * invRadiusZ; nextZn = (z + 1) * invRadiusZ;
@ -2119,18 +2115,15 @@ public class EditSession {
final int ceilRadiusZ = (int) Math.ceil(radiusZ); final int ceilRadiusZ = (int) Math.ceil(radiusZ);
double nextXn = 0; double nextXn = 0;
forX: forX: for (int x = 0; x <= ceilRadiusX; ++x) {
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn; final double xn = nextXn;
nextXn = (x + 1) * invRadiusX; nextXn = (x + 1) * invRadiusX;
double nextYn = 0; double nextYn = 0;
forY: forY: for (int y = 0; y <= ceilRadiusY; ++y) {
for (int y = 0; y <= ceilRadiusY; ++y) {
final double yn = nextYn; final double yn = nextYn;
nextYn = (y + 1) * invRadiusY; nextYn = (y + 1) * invRadiusY;
double nextZn = 0; double nextZn = 0;
forZ: forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
for (int z = 0; z <= ceilRadiusZ; ++z) {
final double zn = nextZn; final double zn = nextZn;
nextZn = (z + 1) * invRadiusZ; nextZn = (z + 1) * invRadiusZ;

View File

@ -1,4 +1,3 @@
package com.sk89q.worldedit;
// $Id$ // $Id$
/* /*
* WorldEditLibrary * WorldEditLibrary
@ -18,6 +17,8 @@ package com.sk89q.worldedit;
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldedit;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.filtering.HeightMapFilter; import com.sk89q.worldedit.filtering.HeightMapFilter;

View File

@ -26,7 +26,6 @@ import java.io.File;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
/** /**
* Represents WorldEdit's configuration. * Represents WorldEdit's configuration.
* *

View File

@ -322,6 +322,7 @@ public abstract class LocalPlayer {
TargetBlock tb = new TargetBlock(this, range, 0.2); TargetBlock tb = new TargetBlock(this, range, 0.2);
return (useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace()); return (useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace());
} }
/** /**
* Get the point of the block being looked at. May return null. * Get the point of the block being looked at. May return null.
* *

View File

@ -75,7 +75,6 @@ public class LocalSession {
private boolean fastMode = false; private boolean fastMode = false;
private Mask mask; private Mask mask;
private TimeZone timezone = TimeZone.getDefault(); private TimeZone timezone = TimeZone.getDefault();
//private Boolean jumptoBlock = true;
/** /**
* Construct the object. * Construct the object.

View File

@ -248,10 +248,16 @@ public abstract class LocalWorld {
*/ */
public void simulateBlockMine(Vector pt) { public void simulateBlockMine(Vector pt) {
BaseItemStack stack = BlockType.getBlockDrop(getBlockType(pt), (short) getBlockData(pt)); BaseItemStack stack = BlockType.getBlockDrop(getBlockType(pt), (short) getBlockData(pt));
if (stack != null) dropItem(pt, if (stack == null) {
stack.getAmount() > 1 ? new BaseItemStack(stack.getType(), return;
1, stack.getDamage()) : stack, stack.getAmount()); }
final int amount = stack.getAmount();
if (amount > 1) {
dropItem(pt, new BaseItemStack(stack.getType(), 1, stack.getDamage()), amount);
} else {
dropItem(pt, stack, amount);
}
} }
/** /**
@ -298,7 +304,8 @@ public abstract class LocalWorld {
* *
* @param pt Position to check * @param pt Position to check
*/ */
public void checkLoadedChunk(Vector pt) {} public void checkLoadedChunk(Vector pt) {
}
/** /**
* Compare if the other world is equal. * Compare if the other world is equal.
@ -331,7 +338,9 @@ public abstract class LocalWorld {
* *
* @param chunks the chunks to fix * @param chunks the chunks to fix
*/ */
public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {} public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {
}
public void fixLighting(Iterable<BlockVector2D> chunks) {}
public void fixLighting(Iterable<BlockVector2D> chunks) {
}
} }

View File

@ -374,12 +374,11 @@ public class WorldEdit {
} }
// Check if the item is allowed // Check if the item is allowed
if (allAllowed || player.hasPermission("worldedit.anyblock") if (allAllowed || player.hasPermission("worldedit.anyblock") || !config.disallowedBlocks.contains(blockId)) {
|| !config.disallowedBlocks.contains(blockId)) { switch (blockType) {
case SIGN_POST:
case WALL_SIGN:
// Allow special sign text syntax // Allow special sign text syntax
if (blockType == BlockType.SIGN_POST
|| blockType == BlockType.WALL_SIGN) {
String[] text = new String[4]; String[] text = new String[4];
text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : ""; text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : "";
text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : ""; text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : "";
@ -387,8 +386,8 @@ public class WorldEdit {
text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : ""; text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : "";
return new SignBlock(blockType.getID(), data, text); return new SignBlock(blockType.getID(), data, text);
case MOB_SPAWNER:
// Allow setting mob spawn type // Allow setting mob spawn type
} else if (blockType == BlockType.MOB_SPAWNER) {
if (blockAndExtraData.length > 1) { if (blockAndExtraData.length > 1) {
String mobName = blockAndExtraData[1]; String mobName = blockAndExtraData[1];
for (MobType mobType : MobType.values()) { for (MobType mobType : MobType.values()) {
@ -405,8 +404,8 @@ public class WorldEdit {
return new MobSpawnerBlock(data, MobType.PIG.getName()); return new MobSpawnerBlock(data, MobType.PIG.getName());
} }
case NOTE_BLOCK:
// Allow setting note // Allow setting note
} else if (blockType == BlockType.NOTE_BLOCK) {
if (blockAndExtraData.length > 1) { if (blockAndExtraData.length > 1) {
byte note = Byte.parseByte(blockAndExtraData[1]); byte note = Byte.parseByte(blockAndExtraData[1]);
if (note < 0 || note > 24) { if (note < 0 || note > 24) {
@ -417,10 +416,11 @@ public class WorldEdit {
} else { } else {
return new NoteBlock(data, (byte) 0); return new NoteBlock(data, (byte) 0);
} }
}
default:
return new BaseBlock(blockId, data); return new BaseBlock(blockId, data);
} }
}
throw new DisallowedItemException(arg); throw new DisallowedItemException(arg);
} }
@ -1376,7 +1376,7 @@ public class WorldEdit {
try { try {
engine.evaluate(script, filename, vars); engine.evaluate(script, filename, vars);
} catch (ScriptException e) { } catch (ScriptException e) {
player.printError("Failed to execute:");; player.printError("Failed to execute:");
player.printRaw(e.getMessage()); player.printRaw(e.getMessage());
e.printStackTrace(); e.printStackTrace();
} catch (NumberFormatException e) { } catch (NumberFormatException e) {

View File

@ -189,6 +189,7 @@ public abstract class BlockBag {
* @param pos * @param pos
*/ */
public abstract void addSourcePosition(Vector pos); public abstract void addSourcePosition(Vector pos);
/** /**
* Adds a position to be used a source. * Adds a position to be used a source.
* *

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.bags; package com.sk89q.worldedit.bags;
/** /**
* *
* @author sk89q * @author sk89q

View File

@ -130,6 +130,7 @@ public class BaseBlock {
data = (byte) BlockData.flip(type, data); data = (byte) BlockData.flip(type, data);
return this; return this;
} }
/** /**
* Flip this block. * Flip this block.
* @param direction * @param direction

View File

@ -129,7 +129,6 @@ public class ChestBlock extends BaseBlock implements TileEntityBlock, ContainerB
return; return;
} }
Tag t = values.get("id"); Tag t = values.get("id");
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Chest")) { if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Chest")) {
throw new DataException("'Chest' tile entity expected"); throw new DataException("'Chest' tile entity expected");

View File

@ -129,7 +129,6 @@ public class DispenserBlock extends BaseBlock implements TileEntityBlock, Contai
return; return;
} }
Tag t = values.get("id"); Tag t = values.get("id");
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Trap")) { if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Trap")) {
throw new DataException("'Trap' tile entity expected"); throw new DataException("'Trap' tile entity expected");

View File

@ -35,6 +35,7 @@ public interface TileEntityBlock {
* @return title entity ID * @return title entity ID
*/ */
public String getTileEntityID(); public String getTileEntityID();
/** /**
* Store additional tile entity data. * Store additional tile entity data.
* *
@ -43,6 +44,7 @@ public interface TileEntityBlock {
*/ */
public Map<String, Tag> toTileEntityNBT() public Map<String, Tag> toTileEntityNBT()
throws DataException; throws DataException;
/** /**
* Get additional information from the title entity data. * Get additional information from the title entity data.
* *

View File

@ -122,5 +122,4 @@ public class BukkitConfiguration extends LocalConfiguration {
logFileHandler.close(); logFileHandler.close();
} }
} }
} }

View File

@ -109,5 +109,6 @@ public class BukkitUtil {
if (Math.abs(a.getZ() - b.getZ()) > EQUALS_PRECISION) return false; if (Math.abs(a.getZ() - b.getZ()) > EQUALS_PRECISION) return false;
return true; return true;
} }
public static final double EQUALS_PRECISION = 0.0001; public static final double EQUALS_PRECISION = 0.0001;
} }

View File

@ -273,13 +273,14 @@ public class BukkitWorld extends LocalWorld {
*/ */
@Override @Override
public boolean copyToWorld(Vector pt, BaseBlock block) { public boolean copyToWorld(Vector pt, BaseBlock block) {
// Signs
if (block instanceof SignBlock) { if (block instanceof SignBlock) {
// Signs
setSignText(pt, ((SignBlock) block).getText()); setSignText(pt, ((SignBlock) block).getText());
return true; return true;
}
if (block instanceof FurnaceBlock) {
// Furnaces // Furnaces
} else if (block instanceof FurnaceBlock) {
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
@ -289,13 +290,15 @@ public class BukkitWorld extends LocalWorld {
bukkit.setBurnTime(we.getBurnTime()); bukkit.setBurnTime(we.getBurnTime());
bukkit.setCookTime(we.getCookTime()); bukkit.setCookTime(we.getCookTime());
return setContainerBlockContents(pt, ((ContainerBlock) block).getItems()); return setContainerBlockContents(pt, ((ContainerBlock) block).getItems());
}
if (block instanceof ContainerBlock) {
// Chests/dispenser // Chests/dispenser
} else if (block instanceof ContainerBlock) {
return setContainerBlockContents(pt, ((ContainerBlock) block).getItems()); return setContainerBlockContents(pt, ((ContainerBlock) block).getItems());
}
if (block instanceof MobSpawnerBlock) {
// Mob spawners // Mob spawners
} else if (block instanceof MobSpawnerBlock) {
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
@ -305,9 +308,10 @@ public class BukkitWorld extends LocalWorld {
bukkit.setCreatureTypeId(we.getMobType()); bukkit.setCreatureTypeId(we.getMobType());
bukkit.setDelay(we.getDelay()); bukkit.setDelay(we.getDelay());
return true; return true;
}
if (block instanceof NoteBlock) {
// Note block // Note block
} else if (block instanceof NoteBlock) {
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
@ -330,13 +334,14 @@ public class BukkitWorld extends LocalWorld {
*/ */
@Override @Override
public boolean copyFromWorld(Vector pt, BaseBlock block) { public boolean copyFromWorld(Vector pt, BaseBlock block) {
// Signs
if (block instanceof SignBlock) { if (block instanceof SignBlock) {
// Signs
((SignBlock) block).setText(getSignText(pt)); ((SignBlock) block).setText(getSignText(pt));
return true; return true;
}
if (block instanceof FurnaceBlock) {
// Furnaces // Furnaces
} else if (block instanceof FurnaceBlock) {
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
@ -347,14 +352,16 @@ public class BukkitWorld extends LocalWorld {
we.setCookTime(bukkit.getCookTime()); we.setCookTime(bukkit.getCookTime());
((ContainerBlock) block).setItems(getContainerBlockContents(pt)); ((ContainerBlock) block).setItems(getContainerBlockContents(pt));
return true; return true;
}
if (block instanceof ContainerBlock) {
// Chests/dispenser // Chests/dispenser
} else if (block instanceof ContainerBlock) {
((ContainerBlock) block).setItems(getContainerBlockContents(pt)); ((ContainerBlock) block).setItems(getContainerBlockContents(pt));
return true; return true;
}
if (block instanceof MobSpawnerBlock) {
// Mob spawners // Mob spawners
} else if (block instanceof MobSpawnerBlock) {
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
@ -364,9 +371,10 @@ public class BukkitWorld extends LocalWorld {
we.setMobType(bukkit.getCreatureTypeId()); we.setMobType(bukkit.getCreatureTypeId());
we.setDelay((short) bukkit.getDelay()); we.setDelay((short) bukkit.getDelay());
return true; return true;
}
if (block instanceof NoteBlock) {
// Note block // Note block
} else if (block instanceof NoteBlock) {
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
@ -534,41 +542,55 @@ public class BukkitWorld extends LocalWorld {
continue; continue;
} }
if (type == EntityType.ARROWS) { switch (type) {
case ARROWS:
if (ent instanceof Arrow) { if (ent instanceof Arrow) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.BOATS) { break;
case BOATS:
if (ent instanceof Boat) { if (ent instanceof Boat) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.ITEMS) { break;
case ITEMS:
if (ent instanceof Item) { if (ent instanceof Item) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.MINECARTS) { break;
case MINECARTS:
if (ent instanceof Minecart) { if (ent instanceof Minecart) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.PAINTINGS) { break;
case PAINTINGS:
if (ent instanceof Painting) { if (ent instanceof Painting) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.TNT) { break;
case TNT:
if (ent instanceof TNTPrimed) { if (ent instanceof TNTPrimed) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.XP_ORBS) { break;
case XP_ORBS:
if (ent instanceof ExperienceOrb) { if (ent instanceof ExperienceOrb) {
ent.remove(); ent.remove();
++num; ++num;
} }
break;
} }
} }

View File

@ -115,9 +115,11 @@ public class WorldEditPlayerListener extends PlayerListener {
} }
if (!ignoreLeftClickAir) { if (!ignoreLeftClickAir) {
final int taskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() { final int taskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
ignoreLeftClickAir = false; ignoreLeftClickAir = false;
}}, 2); }
}, 2);
if (taskId != -1) { if (taskId != -1) {
ignoreLeftClickAir = true; ignoreLeftClickAir = true;

View File

@ -207,13 +207,15 @@ public class WorldEditPlugin extends JavaPlugin {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { try {
if (input != null) if (input != null) {
input.close(); input.close();
}
} catch (IOException e) {} } catch (IOException e) {}
try { try {
if (output != null) if (output != null) {
output.close(); output.close();
}
} catch (IOException e) {} } catch (IOException e) {}
} }
} }
@ -267,8 +269,7 @@ public class WorldEditPlugin extends JavaPlugin {
BlockBag blockBag = session.getBlockBag(wePlayer); BlockBag blockBag = session.getBlockBag(wePlayer);
EditSession editSession = EditSession editSession =
new EditSession(wePlayer.getWorld(), new EditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag);
session.getBlockChangeLimit(), blockBag);
editSession.enableQueue(); editSession.enableQueue();
return editSession; return editSession;

View File

@ -129,7 +129,9 @@ public class ChunkCommands {
player.printError("Error occurred: " + e.getMessage()); player.printError("Error occurred: " + e.getMessage());
} finally { } finally {
if (out != null) { if (out != null) {
try { out.close(); } catch (IOException ie) {} try {
out.close();
} catch (IOException ie) { }
} }
} }
} else if (config.shellSaveType.equalsIgnoreCase("bash")) { } else if (config.shellSaveType.equalsIgnoreCase("bash")) {

View File

@ -74,7 +74,6 @@ public class NavigationCommands {
} else { } else {
player.print((ascentLevels != 1) ? "Ascended " + Integer.toString(ascentLevels) + " levels." : "Ascended a level."); player.print((ascentLevels != 1) ? "Ascended " + Integer.toString(ascentLevels) + " levels." : "Ascended a level.");
} }
} }
@Command( @Command(
@ -103,7 +102,6 @@ public class NavigationCommands {
} else { } else {
player.print((descentLevels != 1) ? "Descended " + Integer.toString(descentLevels) + " levels." : "Descended a level."); player.print((descentLevels != 1) ? "Descended " + Integer.toString(descentLevels) + " levels." : "Descended a level.");
} }
} }
@Command( @Command(

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.commands; package com.sk89q.worldedit.commands;
import java.util.Set; import java.util.Set;
import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandContext;
@ -268,7 +267,6 @@ public class RegionCommands {
player.print(affected + " blocks moved."); player.print(affected + " blocks moved.");
} }
@Command( @Command(
aliases = { "/stack" }, aliases = { "/stack" },
usage = "[count] [direction]", usage = "[count] [direction]",

View File

@ -106,7 +106,6 @@ public class SelectionCommands {
return; return;
} }
session.getRegionSelector(player.getWorld()) session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos); .explainSecondarySelection(player, session, pos);
} }

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.commands; package com.sk89q.worldedit.commands;
import java.util.Set; import java.util.Set;
import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandContext;

View File

@ -21,5 +21,6 @@ package com.sk89q.worldedit.cui;
public interface CUIEvent { public interface CUIEvent {
public String getTypeId(); public String getTypeId();
public String[] getParameters(); public String[] getParameters();
} }

View File

@ -17,7 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldedit.data; package com.sk89q.worldedit.data;
import java.util.List; import java.util.List;
@ -173,8 +172,9 @@ public class Chunk {
* @throws DataException * @throws DataException
*/ */
private Map<String, Tag> getBlockTileEntity(Vector pos) throws DataException { private Map<String, Tag> getBlockTileEntity(Vector pos) throws DataException {
if (tileEntities == null) if (tileEntities == null) {
populateTileEntities(); populateTileEntities();
}
return tileEntities.get(new BlockVector(pos)); return tileEntities.get(new BlockVector(pos));
} }
@ -232,8 +232,7 @@ public class Chunk {
} }
Tag tag = items.get(key); Tag tag = items.get(key);
if (!expected.isInstance(tag)) { if (!expected.isInstance(tag)) {
throw new InvalidFormatException( throw new InvalidFormatException(key + " tag is not of tag type " + expected.getName());
key + " tag is not of tag type " + expected.getName());
} }
return tag; return tag;
} }

View File

@ -116,7 +116,6 @@ public abstract class McRegionChunkStore extends ChunkStore {
protected abstract InputStream getInputStream(String name, String worldname) protected abstract InputStream getInputStream(String name, String worldname)
throws IOException, DataException; throws IOException, DataException;
/** /**
* Close resources. * Close resources.
* *

View File

@ -112,8 +112,7 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore {
// So not there either... // So not there either...
if (testEntry == null) { if (testEntry == null) {
for (Enumeration<? extends ZipEntry> e = zip.entries(); for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements();) {
e.hasMoreElements(); ) {
testEntry = (ZipEntry) e.nextElement(); testEntry = (ZipEntry) e.nextElement();

View File

@ -100,8 +100,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
Pattern pattern = Pattern.compile(".*\\.mcr$"); Pattern pattern = Pattern.compile(".*\\.mcr$");
// World pattern // World pattern
Pattern worldPattern = Pattern.compile(worldname + "\\$"); Pattern worldPattern = Pattern.compile(worldname + "\\$");
for (Enumeration<? extends ZipEntry> e = zip.entries(); for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
e.hasMoreElements();) {
ZipEntry testEntry = (ZipEntry) e.nextElement(); ZipEntry testEntry = (ZipEntry) e.nextElement();
// Check for world // Check for world
if (worldPattern.matcher(worldname).matches()) { if (worldPattern.matcher(worldname).matches()) {
@ -158,8 +157,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean isValid() { public boolean isValid() {
for (Enumeration<? extends ZipEntry> e = zip.entries(); for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
e.hasMoreElements();) {
ZipEntry testEntry = e.nextElement(); ZipEntry testEntry = e.nextElement();

View File

@ -109,8 +109,7 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore {
// So not there either... // So not there either...
if (testEntry == null) { if (testEntry == null) {
for (Enumeration<? extends ZipEntry> e = zip.entries(); for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
e.hasMoreElements(); ) {
testEntry = (ZipEntry) e.nextElement(); testEntry = (ZipEntry) e.nextElement();

View File

@ -95,8 +95,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
} }
} else { } else {
Pattern pattern = Pattern.compile(".*\\.mcr$"); Pattern pattern = Pattern.compile(".*\\.mcr$");
for (Enumeration<? extends ZipEntry> e = zip.entries(); for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
e.hasMoreElements();) {
ZipEntry testEntry = (ZipEntry) e.nextElement(); ZipEntry testEntry = (ZipEntry) e.nextElement();
// Check for world // Check for world
if (testEntry.getName().startsWith(worldname + "/")) { if (testEntry.getName().startsWith(worldname + "/")) {
@ -152,8 +151,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
@Override @Override
public boolean isValid() { public boolean isValid() {
for (Enumeration<? extends ZipEntry> e = zip.entries(); for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
e.hasMoreElements();) {
ZipEntry testEntry = e.nextElement(); ZipEntry testEntry = e.nextElement();

View File

@ -100,8 +100,7 @@ public class Expression {
try { try {
return root.getValue(); return root.getValue();
} } catch (ReturnException e) {
catch (ReturnException e) {
return e.getValue(); return e.getValue();
} }
} }

View File

@ -182,8 +182,7 @@ public class Parser {
if (peek().id() == ';') { if (peek().id() == ';') {
++position; ++position;
break; break;
} } else {
else {
break loop; break loop;
} }
@ -205,8 +204,7 @@ public class Parser {
break loop; break loop;
} }
break; break;
} } else {
else {
break loop; break loop;
} }
} }

View File

@ -231,11 +231,9 @@ public final class ParserProcessors {
final Identifiable last = input.removeLast(); final Identifiable last = input.removeLast();
if (last instanceof OperatorToken) { if (last instanceof OperatorToken) {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x" + ((OperatorToken) last).operator)); postfixes.addLast(new UnaryOperator(last.getPosition(), "x" + ((OperatorToken) last).operator));
} } else if (last instanceof UnaryOperator) {
else if (last instanceof UnaryOperator) {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x" + ((UnaryOperator) last).operator)); postfixes.addLast(new UnaryOperator(last.getPosition(), "x" + ((UnaryOperator) last).operator));
} } else {
else {
center = last; center = last;
break; break;
} }

View File

@ -17,8 +17,7 @@ public class Conditional extends Node {
public double getValue() throws EvaluationException { public double getValue() throws EvaluationException {
if (condition.getValue() > 0.0) { if (condition.getValue() > 0.0) {
return truePart.getValue(); return truePart.getValue();
} } else {
else {
return falsePart == null ? 0 : falsePart.getValue(); return falsePart == null ? 0 : falsePart.getValue();
} }
} }

View File

@ -28,8 +28,7 @@ public class For extends Node {
try { try {
ret = body.getValue(); ret = body.getValue();
} } catch (BreakException e) {
catch (BreakException e) {
if (e.doContinue) { if (e.doContinue) {
continue; continue;
} else { } else {

View File

@ -90,14 +90,12 @@ public final class Functions {
} }
} }
public static final Function getFunction(int position, String name, RValue... args) throws NoSuchMethodException { public static final Function getFunction(int position, String name, RValue... args) throws NoSuchMethodException {
final Method getter = getMethod(name, false, args); final Method getter = getMethod(name, false, args);
try { try {
Method setter = getMethod(name, true, args); Method setter = getMethod(name, true, args);
return new LValueFunction(position, getter, setter, args); return new LValueFunction(position, getter, setter, args);
} } catch (NoSuchMethodException e) {
catch (NoSuchMethodException e) {
return new Function(position, getter, args); return new Function(position, getter, args);
} }
} }

View File

@ -28,5 +28,6 @@ import com.sk89q.worldedit.expression.Identifiable;
*/ */
public interface RValue extends Identifiable { public interface RValue extends Identifiable {
public double getValue() throws EvaluationException; public double getValue() throws EvaluationException;
public Node optimize() throws EvaluationException; public Node optimize() throws EvaluationException;
} }

View File

@ -27,8 +27,7 @@ public class While extends Node {
try { try {
ret = body.getValue(); ret = body.getValue();
} } catch (BreakException e) {
catch (BreakException e) {
if (e.doContinue) { if (e.doContinue) {
continue; continue;
} else { } else {
@ -45,8 +44,7 @@ public class While extends Node {
try { try {
ret = body.getValue(); ret = body.getValue();
} } catch (BreakException e) {
catch (BreakException e) {
if (e.doContinue) { if (e.doContinue) {
continue; continue;
} else { } else {

View File

@ -92,8 +92,9 @@ public class HeightMapFilter {
for (int ky = 0; ky < kh; ++ky) { for (int ky = 0; ky < kh; ++ky) {
int offsetY = y + ky - koy; int offsetY = y + ky - koy;
// Clamp coordinates inside data // Clamp coordinates inside data
if (offsetY < 0 || offsetY >= height) if (offsetY < 0 || offsetY >= height) {
offsetY = y; offsetY = y;
}
offsetY *= width; offsetY *= width;
@ -104,8 +105,9 @@ public class HeightMapFilter {
int offsetX = x + kx - kox; int offsetX = x + kx - kox;
// Clamp coordinates inside data // Clamp coordinates inside data
if (offsetX < 0 || offsetX >= width) if (offsetX < 0 || offsetX >= width) {
offsetX = x; offsetX = x;
}
z += f * inData[offsetY + offsetX]; z += f * inData[offsetY + offsetX];
} }

View File

@ -50,4 +50,3 @@ public class UnderOverlayMask implements Mask {
} }
} }

View File

@ -35,36 +35,42 @@ public interface Region extends Iterable<BlockVector> {
* @return min. point * @return min. point
*/ */
public Vector getMinimumPoint(); public Vector getMinimumPoint();
/** /**
* Get the upper point of a region. * Get the upper point of a region.
* *
* @return max. point * @return max. point
*/ */
public Vector getMaximumPoint(); public Vector getMaximumPoint();
/** /**
* Get the number of blocks in the region. * Get the number of blocks in the region.
* *
* @return number of blocks * @return number of blocks
*/ */
public int getArea(); public int getArea();
/** /**
* Get X-size. * Get X-size.
* *
* @return width * @return width
*/ */
public int getWidth(); public int getWidth();
/** /**
* Get Y-size. * Get Y-size.
* *
* @return height * @return height
*/ */
public int getHeight(); public int getHeight();
/** /**
* Get Z-size. * Get Z-size.
* *
* @return length * @return length
*/ */
public int getLength(); public int getLength();
/** /**
* Expand the region. * Expand the region.
* *
@ -72,6 +78,7 @@ public interface Region extends Iterable<BlockVector> {
* @throws RegionOperationException * @throws RegionOperationException
*/ */
public void expand(Vector change) throws RegionOperationException; public void expand(Vector change) throws RegionOperationException;
/** /**
* Contract the region. * Contract the region.
* *
@ -79,6 +86,7 @@ public interface Region extends Iterable<BlockVector> {
* @throws RegionOperationException * @throws RegionOperationException
*/ */
public void contract(Vector change) throws RegionOperationException; public void contract(Vector change) throws RegionOperationException;
/** /**
* Returns true based on whether the region contains the point, * Returns true based on whether the region contains the point,
* *
@ -86,6 +94,7 @@ public interface Region extends Iterable<BlockVector> {
* @return * @return
*/ */
public boolean contains(Vector pt); public boolean contains(Vector pt);
/** /**
* Get a list of chunks. * Get a list of chunks.
* *

View File

@ -24,7 +24,9 @@ import javax.script.ScriptException;
public interface CraftScriptEngine { public interface CraftScriptEngine {
public void setTimeLimit(int milliseconds); public void setTimeLimit(int milliseconds);
public int getTimeLimit(); public int getTimeLimit();
public Object evaluate(String script, String filename, Map<String, Object> args) public Object evaluate(String script, String filename, Map<String, Object> args)
throws ScriptException, Throwable; throws ScriptException, Throwable;
} }

View File

@ -1,4 +1,3 @@
package com.sk89q.worldedit.snapshots;
// $Id$ // $Id$
/* /*
* WorldEdit * WorldEdit
@ -18,6 +17,8 @@ package com.sk89q.worldedit.snapshots;
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldedit.snapshots;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.regions.*; import com.sk89q.worldedit.regions.*;
import com.sk89q.worldedit.blocks.*; import com.sk89q.worldedit.blocks.*;
@ -141,8 +142,7 @@ public class SnapshotRestore {
errorChunks = new ArrayList<Vector2D>(); errorChunks = new ArrayList<Vector2D>();
// Now let's start restoring! // Now let's start restoring!
for (Map.Entry<BlockVector2D,ArrayList<Vector>> entry : for (Map.Entry<BlockVector2D, ArrayList<Vector>> entry : neededChunks.entrySet()) {
neededChunks.entrySet()) {
BlockVector2D chunkPos = entry.getKey(); BlockVector2D chunkPos = entry.getKey();
Chunk chunk; Chunk chunk;

View File

@ -134,8 +134,7 @@ public class TargetBlock {
* @return Block * @return Block
*/ */
public BlockWorldVector getTargetBlock() { public BlockWorldVector getTargetBlock() {
while ((getNextBlock() != null) while (getNextBlock() != null && world.getBlockType(getCurrentBlock()) == 0) ;
&& (world.getBlockType(getCurrentBlock()) == 0));
return getCurrentBlock(); return getCurrentBlock();
} }
@ -146,8 +145,7 @@ public class TargetBlock {
* @return Block * @return Block
*/ */
public BlockWorldVector getSolidTargetBlock() { public BlockWorldVector getSolidTargetBlock() {
while ((getNextBlock() != null) while (getNextBlock() != null && BlockType.canPassThrough(world.getBlockType(getCurrentBlock()))) ;
&& BlockType.canPassThrough(world.getBlockType(getCurrentBlock())));
return getCurrentBlock(); return getCurrentBlock();
} }

View File

@ -75,8 +75,7 @@ public class BlockDataTest {
public void testCycle() { public void testCycle() {
// Test monotony // Test monotony
for (int type = 0; type < 256; ++type) { for (int type = 0; type < 256; ++type) {
if (type == BlockID.CLOTH) if (type == BlockID.CLOTH) continue;
continue;
for (int data = 0; data < 16; ++data) { for (int data = 0; data < 16; ++data) {
final String message = type + "/" + data; final String message = type + "/" + data;