Cleanup and a few bugfixes

This commit is contained in:
Wizjany 2011-09-24 15:24:10 -04:00
parent a2e23fedf7
commit b5b55a2775
30 changed files with 170 additions and 191 deletions

View File

@ -41,14 +41,17 @@ public class DinnerPermsResolver implements PermissionsResolver {
public boolean hasPermission(String name, String permission) { public boolean hasPermission(String name, String permission) {
Player player = server.getPlayer(name); Player player = server.getPlayer(name);
if (player == null) if (player == null) {
return false; // Permissions are only registered for online players return false; // Permissions are only registered for online players
if ( player.hasPermission("*") || player.hasPermission(permission)) }
if ( player.hasPermission("*") || player.hasPermission(permission)) {
return true; return true;
}
int dotPos = permission.lastIndexOf("."); int dotPos = permission.lastIndexOf(".");
while (dotPos > -1) { while (dotPos > -1) {
if (player.hasPermission(permission.substring(0, dotPos + 1) + "*")) if (player.hasPermission(permission.substring(0, dotPos + 1) + "*")) {
return true; return true;
}
dotPos = permission.lastIndexOf(".", dotPos - 1); dotPos = permission.lastIndexOf(".", dotPos - 1);
} }
return false; return false;
@ -60,22 +63,25 @@ public class DinnerPermsResolver implements PermissionsResolver {
public boolean inGroup(String name, String group) { public boolean inGroup(String name, String group) {
Player player = server.getPlayer(name); Player player = server.getPlayer(name);
if (player == null) if (player == null) {
return false; return false;
}
return player.hasPermission(GROUP_PREFIX + group); return player.hasPermission(GROUP_PREFIX + group);
} }
public String[] getGroups(String name) { public String[] getGroups(String name) {
Player player = server.getPlayer(name); Player player = server.getPlayer(name);
if (player == null) if (player == null) {
return new String[0]; return new String[0];
}
List<String> groupNames = new ArrayList<String>(); List<String> groupNames = new ArrayList<String>();
for (PermissionAttachmentInfo permAttach : player.getEffectivePermissions()) { for (PermissionAttachmentInfo permAttach : player.getEffectivePermissions()) {
String perm = permAttach.getPermission(); String perm = permAttach.getPermission();
if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) {
continue; continue;
}
groupNames.add(perm.substring(GROUP_PREFIX.length(), perm.length())); groupNames.add(perm.substring(GROUP_PREFIX.length(), perm.length()));
} }
return groupNames.toArray(new String[0]); return groupNames.toArray(new String[groupNames.size()]);
} }
} }

View File

@ -45,8 +45,9 @@ public class NijiPermissionsResolver implements PermissionsResolver {
if (plugin == null) { if (plugin == null) {
throw new MissingPluginException(); throw new MissingPluginException();
} }
if (!checkRealNijiPerms(ignoreBridges)) if (!checkRealNijiPerms(ignoreBridges)) {
throw new MissingPluginException(); throw new MissingPluginException();
}
try { try {
api = (Permissions)plugin; api = (Permissions)plugin;
@ -129,11 +130,13 @@ public class NijiPermissionsResolver implements PermissionsResolver {
} }
public static boolean checkRealNijiPerms(boolean ignoreBridges) { public static boolean checkRealNijiPerms(boolean ignoreBridges) {
if (!ignoreBridges) if (!ignoreBridges) {
return true; return true;
}
PluginCommand permsCommand = Bukkit.getServer().getPluginCommand("permissions"); PluginCommand permsCommand = Bukkit.getServer().getPluginCommand("permissions");
if (permsCommand == null) if (permsCommand == null) {
return false; return false;
}
return permsCommand.getPlugin().getDescription().getName().equals("Permissions"); return permsCommand.getPlugin().getDescription().getName().equals("Permissions");
} }
} }

View File

@ -34,8 +34,9 @@ public class PermissionsExResolver implements PermissionsResolver {
public PermissionsExResolver(Server server) throws MissingPluginException { public PermissionsExResolver(Server server) throws MissingPluginException {
this.server = server; this.server = server;
manager = server.getServicesManager().load(PermissionManager.class); manager = server.getServicesManager().load(PermissionManager.class);
if (manager == null) if (manager == null) {
throw new MissingPluginException(); throw new MissingPluginException();
}
} }
public void load() { public void load() {

View File

@ -76,6 +76,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
loadConfig(new File("wepif.yml")); loadConfig(new File("wepif.yml"));
findResolver(); findResolver();
} }
public void findResolver() { public void findResolver() {
if (tryPluginPermissionsResolver()) return; if (tryPluginPermissionsResolver()) return;
if (tryNijiPermissions()) return; if (tryNijiPermissions()) return;
@ -132,8 +133,9 @@ public class PermissionsResolverManager implements PermissionsResolver {
} }
private boolean tryDinnerPerms() { private boolean tryDinnerPerms() {
if (!permsConfig.getBoolean("dinnerperms", true)) if (!permsConfig.getBoolean("dinnerperms", true)) {
return false; return false;
}
perms = new DinnerPermsResolver(server); perms = new DinnerPermsResolver(server);
logger.info(name + ": Using the Bukkit Permissions API."); logger.info(name + ": Using the Bukkit Permissions API.");
return true; return true;

View File

@ -133,8 +133,9 @@ public class CommandContext {
throw new CommandException("Value flag '" + flagName + "' already given"); throw new CommandException("Value flag '" + flagName + "' already given");
} }
if (nextArg >= argList.size()) if (nextArg >= argList.size()) {
throw new CommandException("No value specified for the '-"+flagName+"' flag."); throw new CommandException("No value specified for the '-"+flagName+"' flag.");
}
// If it is a value flag, read another argument and add it // If it is a value flag, read another argument and add it
this.valueFlags.put(flagName, argList.get(nextArg++)); this.valueFlags.put(flagName, argList.get(nextArg++));
@ -217,8 +218,9 @@ public class CommandContext {
public String getFlag(char ch, String def) { public String getFlag(char ch, String def) {
final String value = valueFlags.get(ch); final String value = valueFlags.get(ch);
if (value == null) if (value == null) {
return def; return def;
}
return value; return value;
} }
@ -229,8 +231,9 @@ public class CommandContext {
public int getFlagInteger(char ch, int def) throws NumberFormatException { public int getFlagInteger(char ch, int def) throws NumberFormatException {
final String value = valueFlags.get(ch); final String value = valueFlags.get(ch);
if (value == null) if (value == null) {
return def; return def;
}
return Integer.parseInt(value); return Integer.parseInt(value);
} }
@ -241,8 +244,9 @@ public class CommandContext {
public double getFlagDouble(char ch, double def) throws NumberFormatException { public double getFlagDouble(char ch, double def) throws NumberFormatException {
final String value = valueFlags.get(ch); final String value = valueFlags.get(ch);
if (value == null) if (value == null) {
return def; return def;
}
return Double.parseDouble(value); return Double.parseDouble(value);
} }

View File

@ -422,7 +422,8 @@ public abstract class CommandsManager<T> {
} }
} }
public void invokeMethod(Method parent, String[] args, T player, Method method, Object instance, Object[] methodArgs, int level) throws CommandException { public void invokeMethod(Method parent, String[] args, T player, Method method,
Object instance, Object[] methodArgs, int level) throws CommandException {
try { try {
method.invoke(instance, methodArgs); method.invoke(instance, methodArgs);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {

View File

@ -2386,6 +2386,7 @@ public class EditSession {
setBlockIfAir(pos.add(-1, h, -1), log); setBlockIfAir(pos.add(-1, h, -1), log);
} }
setBlockIfAir(pos.add(-1, 0, -1), pumpkin); setBlockIfAir(pos.add(-1, 0, -1), pumpkin);
break;
} }
} }

View File

@ -89,8 +89,9 @@ public class HeightMap {
int[] newData = new int[data.length]; int[] newData = new int[data.length];
System.arraycopy(data, 0, newData, 0, data.length); System.arraycopy(data, 0, newData, 0, data.length);
for (int i = 0; i < iterations; ++i) for (int i = 0; i < iterations; ++i) {
newData = filter.filter(newData, width, height); newData = filter.filter(newData, width, height);
}
return apply(newData); return apply(newData);
} }

View File

@ -240,8 +240,7 @@ public abstract class LocalPlayer {
// Found a ceiling! // Found a ceiling!
if (!BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) { if (!BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
int platformY = Math.max(initialY, y - 3 - clearance); int platformY = Math.max(initialY, y - 3 - clearance);
world.setBlockType(new Vector(x, platformY, z), world.setBlockType(new Vector(x, platformY, z), BlockID.GLASS);
BlockID.GLASS);
setPosition(new Vector(x + 0.5, platformY + 1, z + 0.5)); setPosition(new Vector(x + 0.5, platformY + 1, z + 0.5));
return true; return true;
} }
@ -273,8 +272,7 @@ public abstract class LocalPlayer {
} else if (y > maxY + 1) { } else if (y > maxY + 1) {
break; break;
} else if (y == maxY + 1) { } else if (y == maxY + 1) {
world.setBlockType(new Vector(x, y - 2, z), world.setBlockType(new Vector(x, y - 2, z), BlockID.GLASS);
BlockID.GLASS);
setPosition(new Vector(x + 0.5, y - 1, z + 0.5)); setPosition(new Vector(x + 0.5, y - 1, z + 0.5));
return true; return true;
} }
@ -351,10 +349,12 @@ public abstract class LocalPlayer {
* @return * @return
*/ */
public PlayerDirection getCardinalDirection() { public PlayerDirection getCardinalDirection() {
if (getPitch() > 67.5) if (getPitch() > 67.5) {
return PlayerDirection.DOWN; return PlayerDirection.DOWN;
if (getPitch() < -67.5) }
if (getPitch() < -67.5) {
return PlayerDirection.UP; return PlayerDirection.UP;
}
// From hey0's code // From hey0's code
double rot = (getYaw() - 90) % 360; double rot = (getYaw() - 90) % 360;

View File

@ -36,7 +36,6 @@ import com.sk89q.worldedit.tools.Tool;
import com.sk89q.worldedit.bags.BlockBag; import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.cui.CUIPointBasedRegion; import com.sk89q.worldedit.cui.CUIPointBasedRegion;
import com.sk89q.worldedit.cui.CUIEvent; import com.sk89q.worldedit.cui.CUIEvent;
import com.sk89q.worldedit.cui.SelectionPointEvent;
import com.sk89q.worldedit.cui.SelectionShapeEvent; import com.sk89q.worldedit.cui.SelectionShapeEvent;
import com.sk89q.worldedit.masks.Mask; import com.sk89q.worldedit.masks.Mask;
import com.sk89q.worldedit.regions.CuboidRegionSelector; import com.sk89q.worldedit.regions.CuboidRegionSelector;
@ -66,8 +65,7 @@ public class LocalSession {
private boolean toolControl = true; private boolean toolControl = true;
private boolean superPickaxe = false; private boolean superPickaxe = false;
private BlockTool pickaxeMode = new SinglePickaxe(); private BlockTool pickaxeMode = new SinglePickaxe();
private Map<Integer, Tool> tools private Map<Integer, Tool> tools = new HashMap<Integer, Tool>();
= new HashMap<Integer, Tool>();
private int maxBlocksChanged = -1; private int maxBlocksChanged = -1;
private boolean useInventory; private boolean useInventory;
private Snapshot snapshot; private Snapshot snapshot;
@ -122,7 +120,7 @@ public class LocalSession {
*/ */
public void remember(EditSession editSession) { public void remember(EditSession editSession) {
// Don't store anything if no changes were made // Don't store anything if no changes were made
if (editSession.size() == 0) { return; } if (editSession.size() == 0) return;
// Destroy any sessions after this undo point // Destroy any sessions after this undo point
while (historyPointer < history.size()) { while (historyPointer < history.size()) {
@ -480,10 +478,6 @@ public class LocalSession {
public void setTool(int item, Tool tool) throws InvalidToolBindException { public void setTool(int item, Tool tool) throws InvalidToolBindException {
if (item > 0 && item < 255) { if (item > 0 && item < 255) {
throw new InvalidToolBindException(item, "Blocks can't be used"); throw new InvalidToolBindException(item, "Blocks can't be used");
/* } else if (item == ItemType.COAL.getID() || item == ItemType.LIGHTSTONE_DUST.getID()) {
throw new InvalidToolBindException(item, "Item is not usuable");
// let people deal with craftbook themselves, not everyone uses it
*/
} else if (item == config.wandItem) { } else if (item == config.wandItem) {
throw new InvalidToolBindException(item, "Already used for the wand"); throw new InvalidToolBindException(item, "Already used for the wand");
} else if (item == config.navigationWand) { } else if (item == config.navigationWand) {
@ -562,10 +556,6 @@ public class LocalSession {
* @param player * @param player
*/ */
public void dispatchCUISetup(LocalPlayer player) { public void dispatchCUISetup(LocalPlayer player) {
if (!hasCUISupport) {
return;
}
if (selector != null) { if (selector != null) {
dispatchCUISelection(player); dispatchCUISelection(player);
} }
@ -581,8 +571,7 @@ public class LocalSession {
return; return;
} }
player.dispatchCUIEvent( player.dispatchCUIEvent(new SelectionShapeEvent(selector.getTypeId()));
new SelectionShapeEvent(selector.getTypeId()));
if (selector instanceof CUIPointBasedRegion) { if (selector instanceof CUIPointBasedRegion) {
((CUIPointBasedRegion) selector).describeCUI(player); ((CUIPointBasedRegion) selector).describeCUI(player);

View File

@ -206,8 +206,8 @@ public abstract class LocalWorld {
* @return * @return
* @throws MaxChangedBlocksException * @throws MaxChangedBlocksException
*/ */
public abstract boolean generateRedwoodTree(EditSession editSession, public abstract boolean generateRedwoodTree(EditSession editSession, Vector pt)
Vector pt) throws MaxChangedBlocksException; throws MaxChangedBlocksException;
/** /**
* Generate a tall redwood tree at a location. * Generate a tall redwood tree at a location.
@ -217,8 +217,8 @@ public abstract class LocalWorld {
* @return * @return
* @throws MaxChangedBlocksException * @throws MaxChangedBlocksException
*/ */
public abstract boolean generateTallRedwoodTree(EditSession editSession, public abstract boolean generateTallRedwoodTree(EditSession editSession, Vector pt)
Vector pt) throws MaxChangedBlocksException; throws MaxChangedBlocksException;
/** /**
* Drop an item. * Drop an item.

View File

@ -573,7 +573,7 @@ public class Vector {
if (!(obj instanceof Vector)) { if (!(obj instanceof Vector)) {
return false; return false;
} }
Vector other = (Vector)obj; Vector other = (Vector) obj;
return other.getX() == this.x && other.getY() == this.y && other.getZ() == this.z; return other.getX() == this.x && other.getY() == this.y && other.getZ() == this.z;
} }

View File

@ -88,7 +88,7 @@ public class Vector2D {
* @return the x * @return the x
*/ */
public int getBlockX() { public int getBlockX() {
return (int)Math.round(x); return (int) Math.round(x);
} }
/** /**
@ -122,7 +122,7 @@ public class Vector2D {
* @return the z * @return the z
*/ */
public int getBlockZ() { public int getBlockZ() {
return (int)Math.round(z); return (int) Math.round(z);
} }
/** /**
@ -165,7 +165,7 @@ public class Vector2D {
if (!(obj instanceof Vector2D)) { if (!(obj instanceof Vector2D)) {
return false; return false;
} }
Vector other = (Vector)obj; Vector other = (Vector) obj;
return other.x == this.x && other.z == this.z; return other.x == this.x && other.z == this.z;
} }

View File

@ -79,8 +79,7 @@ public class WorldEdit {
* without any WorldEdit abilities or never use WorldEdit in a session will * without any WorldEdit abilities or never use WorldEdit in a session will
* not have a session object generated for them. * not have a session object generated for them.
*/ */
private HashMap<String,LocalSession> sessions = private HashMap<String,LocalSession> sessions = new HashMap<String,LocalSession>();
new HashMap<String,LocalSession>();
/** /**
* Initialize statically. * Initialize statically.
@ -113,13 +112,14 @@ public class WorldEdit {
final Logging loggingAnnotation = method.getAnnotation(Logging.class); final Logging loggingAnnotation = method.getAnnotation(Logging.class);
final Logging.LogMode logMode; final Logging.LogMode logMode;
if (loggingAnnotation == null) if (loggingAnnotation == null) {
logMode = null; logMode = null;
else } else {
logMode = loggingAnnotation.value(); logMode = loggingAnnotation.value();
}
String msg = "WorldEdit: " + player.getName() + "(in " + player.getWorld().getName() + ")" String msg = "WorldEdit: " + player.getName() + " (in \"" + player.getWorld().getName()
+ ": " + StringUtil.joinString(args, " "); + "\")" + ": " + StringUtil.joinString(args, " ");
if (logMode != null) { if (logMode != null) {
Vector position = player.getPosition(); Vector position = player.getPosition();
final LocalSession session = getSession(player); final LocalSession session = getSession(player);
@ -690,8 +690,7 @@ public class WorldEdit {
} }
if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+\\.[A-Za-z0-9]+$")) { if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+\\.[A-Za-z0-9]+$")) {
throw new InvalidFilenameException(filename, throw new InvalidFilenameException(filename, "Invalid characters or extension missing");
"Invalid characters or extension missing");
} }
f = new File(dir, filename); f = new File(dir, filename);
@ -749,7 +748,7 @@ public class WorldEdit {
* @return * @return
*/ */
public static int divisorMod(int a, int n) { public static int divisorMod(int a, int n) {
return (int)(a - n * Math.floor(Math.floor(a) / (double)n)); return (int) (a - n * Math.floor(Math.floor(a) / (double) n));
} }
/** /**
@ -1044,6 +1043,7 @@ public class WorldEdit {
&& player.hasPermission("worldedit.navigation.jumpto")) { && player.hasPermission("worldedit.navigation.jumpto")) {
// Bug workaround // Bug workaround
// Blocks this from being used after the thru function // Blocks this from being used after the thru function
// @TODO do this right or make craftbukkit do it right
if (!session.canUseJumpto()){ if (!session.canUseJumpto()){
session.toggleJumptoBlock(); session.toggleJumptoBlock();
return false; return false;
@ -1085,8 +1085,9 @@ public class WorldEdit {
} }
// Bug workaround, so it wont do the Jumpto compass function // Bug workaround, so it wont do the Jumpto compass function
// Right after this teleport // Right after this teleport
if (session.canUseJumpto()) if (session.canUseJumpto()) {
session.toggleJumptoBlock(); session.toggleJumptoBlock();
}
return true; return true;
} }

View File

@ -43,7 +43,7 @@ public class BaseBlock {
* @param type * @param type
*/ */
public BaseBlock(int type) { public BaseBlock(int type) {
this.type = (short)type; this.type = (short) type;
} }
/** /**
@ -53,22 +53,22 @@ public class BaseBlock {
* @param data * @param data
*/ */
public BaseBlock(int type, int data) { public BaseBlock(int type, int data) {
this.type = (short)type; this.type = (short) type;
this.data = (byte)data; this.data = (byte) data;
} }
/** /**
* @return the type * @return the type
*/ */
public int getType() { public int getType() {
return (int)type; return (int) type;
} }
/** /**
* @param type the type to set * @param type the type to set
*/ */
public void setType(int type) { public void setType(int type) {
this.type = (short)type; this.type = (short) type;
} }
/** /**
@ -82,7 +82,7 @@ public class BaseBlock {
* @param data the data to set * @param data the data to set
*/ */
public void setData(int data) { public void setData(int data) {
this.data = (byte)data; this.data = (byte) data;
} }
/** /**
@ -98,14 +98,14 @@ public class BaseBlock {
* Rotate this block 90 degrees. * Rotate this block 90 degrees.
*/ */
public void rotate90() { public void rotate90() {
data = (byte)BlockData.rotate90(type, data); data = (byte) BlockData.rotate90(type, data);
} }
/** /**
* Rotate this block -90 degrees. * Rotate this block -90 degrees.
*/ */
public void rotate90Reverse() { public void rotate90Reverse() {
data = (byte)BlockData.rotate90Reverse(type, data); data = (byte) BlockData.rotate90Reverse(type, data);
} }
/** /**
@ -129,8 +129,8 @@ public class BaseBlock {
if (!(o instanceof BaseBlock)) { if (!(o instanceof BaseBlock)) {
return false; return false;
} }
return (type == ((BaseBlock)o).type) return (type == ((BaseBlock) o).type)
&& (data == ((BaseBlock)o).data || data == -1 || ((BaseBlock)o).data == -1); && (data == ((BaseBlock) o).data || data == -1 || ((BaseBlock) o).data == -1);
} }
@Override @Override

View File

@ -34,6 +34,7 @@ public class BukkitUtil {
} }
private static final Map<World,LocalWorld> wlw = new HashMap<World,LocalWorld>(); private static final Map<World,LocalWorld> wlw = new HashMap<World,LocalWorld>();
public static LocalWorld getLocalWorld(World w) { public static LocalWorld getLocalWorld(World w) {
LocalWorld lw = wlw.get(w); LocalWorld lw = wlw.get(w);
if (lw == null) { if (lw == null) {

View File

@ -304,7 +304,7 @@ public class BukkitWorld extends LocalWorld {
public boolean copyFromWorld(Vector pt, BaseBlock block) { public boolean copyFromWorld(Vector pt, BaseBlock block) {
// Signs // Signs
if (block instanceof SignBlock) { if (block instanceof SignBlock) {
((SignBlock)block).setText(getSignText(pt)); ((SignBlock) block).setText(getSignText(pt));
return true; return true;
// Furnaces // Furnaces
@ -313,16 +313,16 @@ public class BukkitWorld extends LocalWorld {
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
if (!(state instanceof Furnace)) return false; if (!(state instanceof Furnace)) return false;
Furnace bukkit = (Furnace)state; Furnace bukkit = (Furnace) state;
FurnaceBlock we = (FurnaceBlock)block; FurnaceBlock we = (FurnaceBlock) block;
we.setBurnTime(bukkit.getBurnTime()); we.setBurnTime(bukkit.getBurnTime());
we.setCookTime(bukkit.getCookTime()); we.setCookTime(bukkit.getCookTime());
((ContainerBlock)block).setItems(getContainerBlockContents(pt)); ((ContainerBlock) block).setItems(getContainerBlockContents(pt));
return true; return true;
// Chests/dispenser // Chests/dispenser
} else if (block instanceof ContainerBlock) { } else if (block instanceof ContainerBlock) {
((ContainerBlock)block).setItems(getContainerBlockContents(pt)); ((ContainerBlock) block).setItems(getContainerBlockContents(pt));
return true; return true;
// Mob spawners // Mob spawners
@ -331,10 +331,10 @@ public class BukkitWorld extends LocalWorld {
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
if (!(state instanceof CreatureSpawner)) return false; if (!(state instanceof CreatureSpawner)) return false;
CreatureSpawner bukkit = (CreatureSpawner)state; CreatureSpawner bukkit = (CreatureSpawner) state;
MobSpawnerBlock we = (MobSpawnerBlock)block; MobSpawnerBlock we = (MobSpawnerBlock) block;
we.setMobType(bukkit.getCreatureTypeId()); we.setMobType(bukkit.getCreatureTypeId());
we.setDelay((short)bukkit.getDelay()); we.setDelay((short) bukkit.getDelay());
return true; return true;
// Note block // Note block
@ -344,7 +344,7 @@ public class BukkitWorld extends LocalWorld {
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
if (!(state instanceof org.bukkit.block.NoteBlock)) return false; if (!(state instanceof org.bukkit.block.NoteBlock)) return false;
org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock)state; org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock)state;
NoteBlock we = (NoteBlock)block; NoteBlock we = (NoteBlock) block;
we.setNote(bukkit.getRawNote()); we.setNote(bukkit.getRawNote());
} }
@ -442,7 +442,7 @@ public class BukkitWorld extends LocalWorld {
@Override @Override
public void dropItem(Vector pt, BaseItemStack item) { public void dropItem(Vector pt, BaseItemStack item) {
ItemStack bukkitItem = new ItemStack(item.getType(), item.getAmount(), ItemStack bukkitItem = new ItemStack(item.getType(), item.getAmount(),
(byte)item.getDamage()); (byte) item.getDamage());
world.dropItemNaturally(toLocation(pt), bukkitItem); world.dropItemNaturally(toLocation(pt), bukkitItem);
} }
@ -563,7 +563,7 @@ public class BukkitWorld extends LocalWorld {
if (block == null) return false; if (block == null) return false;
BlockState state = block.getState(); BlockState state = block.getState();
if (state == null || !(state instanceof Sign)) return false; if (state == null || !(state instanceof Sign)) return false;
Sign sign = (Sign)state; Sign sign = (Sign) state;
sign.setLine(0, text[0]); sign.setLine(0, text[0]);
sign.setLine(1, text[1]); sign.setLine(1, text[1]);
sign.setLine(2, text[2]); sign.setLine(2, text[2]);
@ -583,7 +583,7 @@ public class BukkitWorld extends LocalWorld {
if (block == null) return new String[] { "", "", "", "" }; if (block == null) return new String[] { "", "", "", "" };
BlockState state = block.getState(); BlockState state = block.getState();
if (state == null || !(state instanceof Sign)) return new String[] { "", "", "", "" }; if (state == null || !(state instanceof Sign)) return new String[] { "", "", "", "" };
Sign sign = (Sign)state; Sign sign = (Sign) state;
String line0 = sign.getLine(0); String line0 = sign.getLine(0);
String line1 = sign.getLine(1); String line1 = sign.getLine(1);
String line2 = sign.getLine(2); String line2 = sign.getLine(2);
@ -612,7 +612,7 @@ public class BukkitWorld extends LocalWorld {
return new BaseItemStack[0]; return new BaseItemStack[0];
} }
org.bukkit.block.ContainerBlock container = (org.bukkit.block.ContainerBlock)state; org.bukkit.block.ContainerBlock container = (org.bukkit.block.ContainerBlock) state;
Inventory inven = container.getInventory(); Inventory inven = container.getInventory();
int size = inven.getSize(); int size = inven.getSize();
BaseItemStack[] contents = new BaseItemStack[size]; BaseItemStack[] contents = new BaseItemStack[size];
@ -659,7 +659,7 @@ public class BukkitWorld extends LocalWorld {
if (contents[i] != null) { if (contents[i] != null) {
inven.setItem(i, new ItemStack(contents[i].getType(), inven.setItem(i, new ItemStack(contents[i].getType(),
contents[i].getAmount(), contents[i].getAmount(),
(byte)contents[i].getDamage())); (byte) contents[i].getDamage()));
} else { } else {
inven.setItem(i, null); inven.setItem(i, null);
} }
@ -692,7 +692,7 @@ public class BukkitWorld extends LocalWorld {
return false; return false;
} }
return ((BukkitWorld)other).world.equals(world); return ((BukkitWorld) other).world.equals(world);
} }
@Override @Override

View File

@ -49,8 +49,8 @@ public class ChunkCommands {
throws WorldEditException { throws WorldEditException {
Vector pos = player.getBlockIn(); Vector pos = player.getBlockIn();
int chunkX = (int)Math.floor(pos.getBlockX() / 16.0); int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
int chunkZ = (int)Math.floor(pos.getBlockZ() / 16.0); int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
String folder1 = Integer.toString(WorldEdit.divisorMod(chunkX, 64), 36); String folder1 = Integer.toString(WorldEdit.divisorMod(chunkX, 64), 36);
String folder2 = Integer.toString(WorldEdit.divisorMod(chunkZ, 64), 36); String folder2 = Integer.toString(WorldEdit.divisorMod(chunkZ, 64), 36);
@ -159,7 +159,10 @@ 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 { } else {

View File

@ -61,7 +61,7 @@ public class RegionCommands {
if (pattern instanceof SingleBlockPattern) { if (pattern instanceof SingleBlockPattern) {
affected = editSession.setBlocks(session.getSelection(player.getWorld()), affected = editSession.setBlocks(session.getSelection(player.getWorld()),
((SingleBlockPattern)pattern).getBlock()); ((SingleBlockPattern) pattern).getBlock());
} else { } else {
affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern); affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern);
} }
@ -96,7 +96,7 @@ public class RegionCommands {
int affected = 0; int affected = 0;
if (to instanceof SingleBlockPattern) { if (to instanceof SingleBlockPattern) {
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from,
((SingleBlockPattern)to).getBlock()); ((SingleBlockPattern) to).getBlock());
} else { } else {
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to); affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to);
} }
@ -123,7 +123,7 @@ public class RegionCommands {
int affected = 0; int affected = 0;
if (pat instanceof SingleBlockPattern) { if (pat instanceof SingleBlockPattern) {
affected = editSession.overlayCuboidBlocks(region, affected = editSession.overlayCuboidBlocks(region,
((SingleBlockPattern)pat).getBlock()); ((SingleBlockPattern) pat).getBlock());
} else { } else {
affected = editSession.overlayCuboidBlocks(region, pat); affected = editSession.overlayCuboidBlocks(region, pat);
} }

View File

@ -45,14 +45,19 @@ public class ScriptingCommands {
public static void execute(CommandContext args, WorldEdit we, public static void execute(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession) LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException { throws WorldEditException {
// @TODO: Check for worldedit.scripting.execute.<script> permission
String[] scriptArgs = args.getSlice(1); String[] scriptArgs = args.getSlice(1);
String name = args.getString(0);
session.setLastScript(args.getString(0)); if (!player.hasPermission("worldedit.scripting.execute." + name)) {
player.printError("You don't have permission to use that script.");
return;
}
session.setLastScript(name);
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir); File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
File f = we.getSafeOpenFile(player, dir, args.getString(0), "js", File f = we.getSafeOpenFile(player, dir, name, "js",
new String[] {"js"}); new String[] {"js"});
we.runScript(player, f, scriptArgs); we.runScript(player, f, scriptArgs);
@ -70,10 +75,14 @@ public class ScriptingCommands {
public static void executeLast(CommandContext args, WorldEdit we, public static void executeLast(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession) LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException { throws WorldEditException {
// @TODO: Check for worldedit.scripting.execute.<script> permission
String lastScript = session.getLastScript(); String lastScript = session.getLastScript();
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
player.printError("You don't have permission to use that script.");
return;
}
if (lastScript == null) { if (lastScript == null) {
player.printError("Use /cs with a script name first."); player.printError("Use /cs with a script name first.");
return; return;

View File

@ -350,16 +350,14 @@ public class SelectionCommands {
reverseChange = args.getInteger(1) * -1; reverseChange = args.getInteger(1) * -1;
dir = we.getDirection(player, "me"); dir = we.getDirection(player, "me");
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
dir = we.getDirection(player, dir = we.getDirection(player, args.getString(1).toLowerCase());
args.getString(1).toLowerCase());
} }
break; break;
case 3: case 3:
// Both reverse amount and direction // Both reverse amount and direction
reverseChange = args.getInteger(1) * -1; reverseChange = args.getInteger(1) * -1;
dir = we.getDirection(player, dir = we.getDirection(player, args.getString(2).toLowerCase());
args.getString(2).toLowerCase());
break; break;
default: default:
dir = we.getDirection(player, "me"); dir = we.getDirection(player, "me");
@ -398,8 +396,7 @@ public class SelectionCommands {
int change = args.getInteger(0); int change = args.getInteger(0);
if (args.argsLength() == 2) { if (args.argsLength() == 2) {
dir = we.getDirection(player, dir = we.getDirection(player, args.getString(1).toLowerCase());
args.getString(1).toLowerCase());
} else { } else {
dir = we.getDirection(player, "me"); dir = we.getDirection(player, "me");
} }

View File

@ -60,7 +60,7 @@ public class UtilityCommands {
int affected = 0; int affected = 0;
if (pattern instanceof SingleBlockPattern) { if (pattern instanceof SingleBlockPattern) {
affected = editSession.fillXZ(pos, affected = editSession.fillXZ(pos,
((SingleBlockPattern)pattern).getBlock(), ((SingleBlockPattern) pattern).getBlock(),
radius, depth, false); radius, depth, false);
} else { } else {
affected = editSession.fillXZ(pos, pattern, radius, depth, false); affected = editSession.fillXZ(pos, pattern, radius, depth, false);
@ -90,7 +90,7 @@ public class UtilityCommands {
int affected = 0; int affected = 0;
if (pattern instanceof SingleBlockPattern) { if (pattern instanceof SingleBlockPattern) {
affected = editSession.fillXZ(pos, affected = editSession.fillXZ(pos,
((SingleBlockPattern)pattern).getBlock(), ((SingleBlockPattern) pattern).getBlock(),
radius, depth, true); radius, depth, true);
} else { } else {
affected = editSession.fillXZ(pos, pattern, radius, depth, true); affected = editSession.fillXZ(pos, pattern, radius, depth, true);
@ -197,8 +197,7 @@ public class UtilityCommands {
we.checkMaxRadius(size); we.checkMaxRadius(size);
int height = args.argsLength() > 1 ? Math.min(128, args.getInteger(1) + 2) : 128; int height = args.argsLength() > 1 ? Math.min(128, args.getInteger(1) + 2) : 128;
int affected = editSession.removeBelow( int affected = editSession.removeBelow(session.getPlacementPosition(player), size, height);
session.getPlacementPosition(player), size, height);
player.print(affected + " block(s) have been removed."); player.print(affected + " block(s) have been removed.");
} }
@ -219,8 +218,7 @@ public class UtilityCommands {
int size = Math.max(1, args.getInteger(1, 50)); int size = Math.max(1, args.getInteger(1, 50));
we.checkMaxRadius(size); we.checkMaxRadius(size);
int affected = editSession.removeNear( int affected = editSession.removeNear(session.getPlacementPosition(player), block.getType(), size);
session.getPlacementPosition(player), block.getType(), size);
player.print(affected + " block(s) have been removed."); player.print(affected + " block(s) have been removed.");
} }
@ -340,8 +338,7 @@ public class UtilityCommands {
: defaultRadius; : defaultRadius;
we.checkMaxRadius(size); we.checkMaxRadius(size);
int affected = editSession.removeNear( int affected = editSession.removeNear(session.getPlacementPosition(player), 51, size);
session.getPlacementPosition(player), 51, size);
player.print(affected + " block(s) have been removed."); player.print(affected + " block(s) have been removed.");
} }
@ -359,8 +356,7 @@ public class UtilityCommands {
LocalSession session, LocalPlayer player, EditSession editSession) LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException { throws WorldEditException {
int radius = args.argsLength() > 0 ? int radius = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : -1;
Math.max(1, args.getInteger(0)) : -1;
Vector origin = session.getPlacementPosition(player); Vector origin = session.getPlacementPosition(player);
int killed = player.getWorld().killMobs(origin, radius, args.hasFlag('p')); int killed = player.getWorld().killMobs(origin, radius, args.hasFlag('p'));

View File

@ -20,7 +20,6 @@
package com.sk89q.worldedit.cui; package com.sk89q.worldedit.cui;
import com.sk89q.worldedit.LocalPlayer; import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.Vector;
public interface CUIPointBasedRegion { public interface CUIPointBasedRegion {
public void describeCUI(LocalPlayer player); public void describeCUI(LocalPlayer player);

View File

@ -19,8 +19,6 @@
package com.sk89q.worldedit.cui; package com.sk89q.worldedit.cui;
import com.sk89q.worldedit.Vector;
public class SelectionMinMaxEvent implements CUIEvent { public class SelectionMinMaxEvent implements CUIEvent {
protected int min; protected int min;

View File

@ -151,6 +151,7 @@ public final class BlockData {
case 2: return 0 | open; case 2: return 0 | open;
case 3: return 1 | open; case 3: return 1 | open;
} }
break;
case BlockID.PISTON_BASE: case BlockID.PISTON_BASE:
case BlockID.PISTON_STICKY_BASE: case BlockID.PISTON_STICKY_BASE:
@ -162,19 +163,18 @@ public final class BlockData {
case 4: return 2 | rest; case 4: return 2 | rest;
case 5: return 3 | rest; case 5: return 3 | rest;
} }
break;
case BlockID.BROWN_MUSHROOM_CAP: case BlockID.BROWN_MUSHROOM_CAP:
case BlockID.RED_MUSHROOM_CAP: case BlockID.RED_MUSHROOM_CAP:
if (data >= 10) if (data >= 10) return data;
return data;
return (data * 3) % 10; return (data * 3) % 10;
case BlockID.VINE: case BlockID.VINE:
return ((data << 1) | (data >> 3)) & 0xf; return ((data << 1) | (data >> 3)) & 0xf;
case BlockID.FENCE_GATE: case BlockID.FENCE_GATE:
return ((data+1) & 0x3) | (data & ~0x3); return ((data + 1) & 0x3) | (data & ~0x3);
} }
@ -317,19 +317,18 @@ public final class BlockData {
case 2: return 4 | rest; case 2: return 4 | rest;
case 3: return 5 | rest; case 3: return 5 | rest;
} }
break;
case BlockID.BROWN_MUSHROOM_CAP: case BlockID.BROWN_MUSHROOM_CAP:
case BlockID.RED_MUSHROOM_CAP: case BlockID.RED_MUSHROOM_CAP:
if (data >= 10) if (data >= 10) return data;
return data;
return (data * 7) % 10; return (data * 7) % 10;
case BlockID.VINE: case BlockID.VINE:
return ((data >> 1) | (data << 3)) & 0xf; return ((data >> 1) | (data << 3)) & 0xf;
case BlockID.FENCE_GATE: case BlockID.FENCE_GATE:
return ((data+3) & 0x3) | (data & ~0x3); return ((data + 3) & 0x3) | (data & ~0x3);
} }
return data; return data;
@ -363,11 +362,9 @@ public final class BlockData {
case NORTH_SOUTH: case NORTH_SOUTH:
flipX = 1; flipX = 1;
break; break;
case WEST_EAST: case WEST_EAST:
flipZ = 1; flipZ = 1;
break; break;
case UP_DOWN: case UP_DOWN:
flipY = 1; flipY = 1;
break; break;
@ -389,10 +386,10 @@ public final class BlockData {
case BlockID.MINECART_TRACKS: case BlockID.MINECART_TRACKS:
switch (data) { switch (data) {
case 6: return data + flipX + 3*flipZ; case 6: return data + flipX + flipZ * 3;
case 7: return data - flipX + flipZ; case 7: return data - flipX + flipZ;
case 8: return data + flipX - flipZ; case 8: return data + flipX - flipZ;
case 9: return data - flipX - 3*flipZ; case 9: return data - flipX - flipZ * 3;
} }
/* FALL-THROUGH */ /* FALL-THROUGH */
@ -402,15 +399,12 @@ public final class BlockData {
case 0: case 0:
case 1: case 1:
return data; return data;
case 2: case 2:
case 3: case 3:
return data ^ flipX; return data ^ flipX;
case 4: case 4:
case 5: case 5:
return data ^ flipZ; return data ^ flipZ;
} }
break; break;
@ -422,7 +416,6 @@ public final class BlockData {
case 0: case 0:
case 1: case 1:
return data ^ flipX; return data ^ flipX;
case 2: case 2:
case 3: case 3:
return data ^ flipZ; return data ^ flipZ;
@ -433,20 +426,19 @@ public final class BlockData {
case BlockID.IRON_DOOR: case BlockID.IRON_DOOR:
data ^= flipY << 3; data ^= flipY << 3;
switch (data & 0x3) { switch (data & 0x3) {
case 0: return data + flipX + 3*flipZ; case 0: return data + flipX + flipZ * 3;
case 1: return data - flipX + flipZ; case 1: return data - flipX + flipZ;
case 2: return data + flipX - flipZ; case 2: return data + flipX - flipZ;
case 3: return data - flipX - 3*flipZ; case 3: return data - flipX - flipZ * 3;
} }
break; break;
case BlockID.SIGN_POST: case BlockID.SIGN_POST:
switch (direction) { switch (direction) {
case NORTH_SOUTH: case NORTH_SOUTH:
return (16-data) & 0xf; return (16 - data) & 0xf;
case WEST_EAST: case WEST_EAST:
return (8-data) & 0xf; return (8 - data) & 0xf;
} }
break; break;
@ -459,7 +451,6 @@ public final class BlockData {
case 2: case 2:
case 3: case 3:
return data ^ flipZ; return data ^ flipZ;
case 4: case 4:
case 5: case 5:
return data ^ flipX; return data ^ flipX;
@ -473,11 +464,10 @@ public final class BlockData {
switch (data & 0x3) { switch (data & 0x3) {
case 0: case 0:
case 2: case 2:
return data ^ (flipZ<<1); return data ^ (flipZ << 1);
case 1: case 1:
case 3: case 3:
return data ^ (flipX<<1); return data ^ (flipX << 1);
} }
break; break;
@ -486,7 +476,6 @@ public final class BlockData {
case 0: case 0:
case 1: case 1:
return data ^ flipZ; return data ^ flipZ;
case 2: case 2:
case 3: case 3:
return data ^ flipX; return data ^ flipX;
@ -500,11 +489,9 @@ public final class BlockData {
case 0: case 0:
case 1: case 1:
return data ^ flipY; return data ^ flipY;
case 2: case 2:
case 3: case 3:
return data ^ flipZ; return data ^ flipZ;
case 4: case 4:
case 5: case 5:
return data ^ flipX; return data ^ flipX;
@ -517,30 +504,24 @@ public final class BlockData {
case 1: case 1:
case 4: case 4:
case 7: case 7:
data += 2*flipX; data += 2 * flipX;
break; break;
case 3: case 3:
case 6: case 6:
case 9: case 9:
data -= 2*flipX; data -= 2 * flipX;
break; break;
} }
switch (data) { switch (data) {
case 1: case 1:
case 2: case 2:
case 3: case 3:
data += 6*flipZ; return data + 6 * flipZ;
break;
case 7: case 7:
case 8: case 8:
case 9: case 9:
data -= 6*flipZ; return data - 6 * flipZ;
break;
} }
break; break;
case BlockID.VINE: case BlockID.VINE:
@ -550,12 +531,10 @@ public final class BlockData {
bit1 = 0x2; bit1 = 0x2;
bit2 = 0x8; bit2 = 0x8;
break; break;
case WEST_EAST: case WEST_EAST:
bit1 = 0x1; bit1 = 0x1;
bit2 = 0x4; bit2 = 0x4;
break; break;
default: default:
return data; return data;
} }
@ -569,11 +548,10 @@ public final class BlockData {
switch (data & 0x3) { switch (data & 0x3) {
case 0: case 0:
case 2: case 2:
return data ^ 2*flipZ; return data ^ 2 * flipZ;
case 1: case 1:
case 3: case 3:
return data ^ 2*flipX; return data ^ 2 * flipX;
} }
break; break;
} }

View File

@ -66,8 +66,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
player.print("First position set to " + pos1 + "."); player.print("First position set to " + pos1 + ".");
} }
session.dispatchCUIEvent(player, session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos, getArea()));
new SelectionPointEvent(0, pos, getArea()));
} }
public void explainSecondarySelection(LocalPlayer player, public void explainSecondarySelection(LocalPlayer player,
@ -79,18 +78,15 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
player.print("Second position set to " + pos2 + "."); player.print("Second position set to " + pos2 + ".");
} }
session.dispatchCUIEvent(player, session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos, getArea()));
new SelectionPointEvent(1, pos, getArea()));
} }
public void explainRegionAdjust(LocalPlayer player, LocalSession session) { public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
if (pos1 != null) { if (pos1 != null) {
session.dispatchCUIEvent(player, session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos1, getArea()));
new SelectionPointEvent(0, pos1, getArea()));
} }
if (pos2 != null) { if (pos2 != null) {
session.dispatchCUIEvent(player, session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos2, getArea()));
new SelectionPointEvent(1, pos2, getArea()));
} }
} }
@ -151,12 +147,12 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
} }
public void describeCUI(LocalPlayer player) { public void describeCUI(LocalPlayer player) {
if (pos1 != null) if (pos1 != null) {
player.dispatchCUIEvent( player.dispatchCUIEvent(new SelectionPointEvent(0, pos1, getArea()));
new SelectionPointEvent(0, pos1, getArea())); }
if (pos2 != null) if (pos2 != null) {
player.dispatchCUIEvent( player.dispatchCUIEvent(new SelectionPointEvent(1, pos2, getArea()));
new SelectionPointEvent(1, pos2, getArea())); }
} }
public int getArea() { public int getArea() {

View File

@ -30,7 +30,6 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.cui.CUIPointBasedRegion; import com.sk89q.worldedit.cui.CUIPointBasedRegion;
import com.sk89q.worldedit.cui.SelectionMinMaxEvent; import com.sk89q.worldedit.cui.SelectionMinMaxEvent;
import com.sk89q.worldedit.cui.SelectionPoint2DEvent; import com.sk89q.worldedit.cui.SelectionPoint2DEvent;
import com.sk89q.worldedit.cui.SelectionPointEvent;
import com.sk89q.worldedit.cui.SelectionShapeEvent; import com.sk89q.worldedit.cui.SelectionShapeEvent;
/** /**
@ -83,15 +82,12 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedR
public void explainSecondarySelection(LocalPlayer player, public void explainSecondarySelection(LocalPlayer player,
LocalSession session, Vector pos) { LocalSession session, Vector pos) {
player.print("Added point #" + region.size() + " at " + pos + "."); player.print("Added point #" + region.size() + " at " + pos + ".");
session.dispatchCUIEvent(player, session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getArea()));
new SelectionPoint2DEvent(region.size() - 1, pos, getArea())); session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.minY, region.maxY));
session.dispatchCUIEvent(player,
new SelectionMinMaxEvent(region.minY, region.maxY));
} }
public void explainRegionAdjust(LocalPlayer player, LocalSession session) { public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
session.dispatchCUIEvent(player, session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.minY, region.maxY));
new SelectionMinMaxEvent(region.minY, region.maxY));
} }
public BlockVector getPrimaryPosition() throws IncompleteRegionException { public BlockVector getPrimaryPosition() throws IncompleteRegionException {
@ -153,11 +149,9 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedR
public void describeCUI(LocalPlayer player) { public void describeCUI(LocalPlayer player) {
List<BlockVector2D> points = region.getPoints(); List<BlockVector2D> points = region.getPoints();
for (int id = 0; id < points.size(); id++) { for (int id = 0; id < points.size(); id++) {
player.dispatchCUIEvent( player.dispatchCUIEvent(new SelectionPoint2DEvent(id, points.get(id), getArea()));
new SelectionPoint2DEvent(id, points.get(id), getArea()));
} }
player.dispatchCUIEvent( player.dispatchCUIEvent(new SelectionMinMaxEvent(region.minY, region.maxY));
new SelectionMinMaxEvent(region.minY, region.maxY));
} }
} }

View File

@ -52,9 +52,9 @@ public class RhinoCraftScriptEngine implements CraftScriptEngine {
throw new ScriptException(e.getMessage()); throw new ScriptException(e.getMessage());
} catch (RhinoException e) { } catch (RhinoException e) {
if (e instanceof WrappedException) { if (e instanceof WrappedException) {
Throwable cause = ((WrappedException)e).getCause(); Throwable cause = ((WrappedException) e).getCause();
if (cause instanceof WorldEditException) { if (cause instanceof WorldEditException) {
throw ((WrappedException)e).getCause(); throw ((WrappedException) e).getCause();
} }
} }
@ -62,7 +62,7 @@ public class RhinoCraftScriptEngine implements CraftScriptEngine {
int line = (line = e.lineNumber()) == 0 ? -1 : line; int line = (line = e.lineNumber()) == 0 ? -1 : line;
if (e instanceof JavaScriptException) { if (e instanceof JavaScriptException) {
msg = String.valueOf(((JavaScriptException)e).getValue()); msg = String.valueOf(((JavaScriptException) e).getValue());
} else { } else {
msg = e.getMessage(); msg = e.getMessage();
} }

View File

@ -42,7 +42,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
Scriptable scope = setupScope(cx, context); Scriptable scope = setupScope(cx, context);
String filename = (filename = (String)get(ScriptEngine.FILENAME)) == null String filename = (filename = (String) get(ScriptEngine.FILENAME)) == null
? "<unknown>" : filename; ? "<unknown>" : filename;
try { try {
@ -52,7 +52,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
int line = (line = e.lineNumber()) == 0 ? -1 : line; int line = (line = e.lineNumber()) == 0 ? -1 : line;
if (e instanceof JavaScriptException) { if (e instanceof JavaScriptException) {
msg = String.valueOf(((JavaScriptException)e).getValue()); msg = String.valueOf(((JavaScriptException) e).getValue());
} else { } else {
msg = e.getMessage(); msg = e.getMessage();
} }
@ -72,7 +72,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
Scriptable scope = setupScope(cx, context); Scriptable scope = setupScope(cx, context);
String filename = (filename = (String)get(ScriptEngine.FILENAME)) == null String filename = (filename = (String) get(ScriptEngine.FILENAME)) == null
? "<unknown>" : filename; ? "<unknown>" : filename;
try { try {
@ -82,7 +82,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
int line = (line = e.lineNumber()) == 0 ? -1 : line; int line = (line = e.lineNumber()) == 0 ? -1 : line;
if (e instanceof JavaScriptException) { if (e instanceof JavaScriptException) {
msg = String.valueOf(((JavaScriptException)e).getValue()); msg = String.valueOf(((JavaScriptException) e).getValue());
} else { } else {
msg = e.getMessage(); msg = e.getMessage();
} }

View File

@ -36,7 +36,6 @@ public class ClipboardBrush implements Brush {
public void build(EditSession editSession, Vector pos, Pattern mat, double size) public void build(EditSession editSession, Vector pos, Pattern mat, double size)
throws MaxChangedBlocksException { throws MaxChangedBlocksException {
clipboard.place(editSession, clipboard.place(editSession, pos.subtract(clipboard.getSize().divide(2)), noAir);
pos.subtract(clipboard.getSize().divide(2)), noAir);
} }
} }