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) {
Player player = server.getPlayer(name);
if (player == null)
if (player == null) {
return false; // Permissions are only registered for online players
if ( player.hasPermission("*") || player.hasPermission(permission))
}
if ( player.hasPermission("*") || player.hasPermission(permission)) {
return true;
}
int dotPos = permission.lastIndexOf(".");
while (dotPos > -1) {
if (player.hasPermission(permission.substring(0, dotPos + 1) + "*"))
if (player.hasPermission(permission.substring(0, dotPos + 1) + "*")) {
return true;
}
dotPos = permission.lastIndexOf(".", dotPos - 1);
}
return false;
@ -60,22 +63,25 @@ public class DinnerPermsResolver implements PermissionsResolver {
public boolean inGroup(String name, String group) {
Player player = server.getPlayer(name);
if (player == null)
if (player == null) {
return false;
}
return player.hasPermission(GROUP_PREFIX + group);
}
public String[] getGroups(String name) {
Player player = server.getPlayer(name);
if (player == null)
if (player == null) {
return new String[0];
}
List<String> groupNames = new ArrayList<String>();
for (PermissionAttachmentInfo permAttach : player.getEffectivePermissions()) {
String perm = permAttach.getPermission();
if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue()))
if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) {
continue;
}
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) {
throw new MissingPluginException();
}
if (!checkRealNijiPerms(ignoreBridges))
if (!checkRealNijiPerms(ignoreBridges)) {
throw new MissingPluginException();
}
try {
api = (Permissions)plugin;
@ -129,11 +130,13 @@ public class NijiPermissionsResolver implements PermissionsResolver {
}
public static boolean checkRealNijiPerms(boolean ignoreBridges) {
if (!ignoreBridges)
if (!ignoreBridges) {
return true;
}
PluginCommand permsCommand = Bukkit.getServer().getPluginCommand("permissions");
if (permsCommand == null)
if (permsCommand == null) {
return false;
}
return permsCommand.getPlugin().getDescription().getName().equals("Permissions");
}
}

View File

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

View File

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

View File

@ -133,8 +133,9 @@ public class CommandContext {
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.");
}
// If it is a value flag, read another argument and add it
this.valueFlags.put(flagName, argList.get(nextArg++));
@ -217,8 +218,9 @@ public class CommandContext {
public String getFlag(char ch, String def) {
final String value = valueFlags.get(ch);
if (value == null)
if (value == null) {
return def;
}
return value;
}
@ -229,8 +231,9 @@ public class CommandContext {
public int getFlagInteger(char ch, int def) throws NumberFormatException {
final String value = valueFlags.get(ch);
if (value == null)
if (value == null) {
return def;
}
return Integer.parseInt(value);
}
@ -241,8 +244,9 @@ public class CommandContext {
public double getFlagDouble(char ch, double def) throws NumberFormatException {
final String value = valueFlags.get(ch);
if (value == null)
if (value == null) {
return def;
}
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 {
method.invoke(instance, methodArgs);
} catch (IllegalArgumentException e) {

View File

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

View File

@ -89,8 +89,9 @@ public class HeightMap {
int[] newData = new int[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);
}
return apply(newData);
}

View File

@ -240,8 +240,7 @@ public abstract class LocalPlayer {
// Found a ceiling!
if (!BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
int platformY = Math.max(initialY, y - 3 - clearance);
world.setBlockType(new Vector(x, platformY, z),
BlockID.GLASS);
world.setBlockType(new Vector(x, platformY, z), BlockID.GLASS);
setPosition(new Vector(x + 0.5, platformY + 1, z + 0.5));
return true;
}
@ -273,8 +272,7 @@ public abstract class LocalPlayer {
} else if (y > maxY + 1) {
break;
} else if (y == maxY + 1) {
world.setBlockType(new Vector(x, y - 2, z),
BlockID.GLASS);
world.setBlockType(new Vector(x, y - 2, z), BlockID.GLASS);
setPosition(new Vector(x + 0.5, y - 1, z + 0.5));
return true;
}
@ -351,10 +349,12 @@ public abstract class LocalPlayer {
* @return
*/
public PlayerDirection getCardinalDirection() {
if (getPitch() > 67.5)
if (getPitch() > 67.5) {
return PlayerDirection.DOWN;
if (getPitch() < -67.5)
}
if (getPitch() < -67.5) {
return PlayerDirection.UP;
}
// From hey0's code
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.cui.CUIPointBasedRegion;
import com.sk89q.worldedit.cui.CUIEvent;
import com.sk89q.worldedit.cui.SelectionPointEvent;
import com.sk89q.worldedit.cui.SelectionShapeEvent;
import com.sk89q.worldedit.masks.Mask;
import com.sk89q.worldedit.regions.CuboidRegionSelector;
@ -66,8 +65,7 @@ public class LocalSession {
private boolean toolControl = true;
private boolean superPickaxe = false;
private BlockTool pickaxeMode = new SinglePickaxe();
private Map<Integer, Tool> tools
= new HashMap<Integer, Tool>();
private Map<Integer, Tool> tools = new HashMap<Integer, Tool>();
private int maxBlocksChanged = -1;
private boolean useInventory;
private Snapshot snapshot;
@ -122,7 +120,7 @@ public class LocalSession {
*/
public void remember(EditSession editSession) {
// 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
while (historyPointer < history.size()) {
@ -480,10 +478,6 @@ public class LocalSession {
public void setTool(int item, Tool tool) throws InvalidToolBindException {
if (item > 0 && item < 255) {
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) {
throw new InvalidToolBindException(item, "Already used for the wand");
} else if (item == config.navigationWand) {
@ -562,10 +556,6 @@ public class LocalSession {
* @param player
*/
public void dispatchCUISetup(LocalPlayer player) {
if (!hasCUISupport) {
return;
}
if (selector != null) {
dispatchCUISelection(player);
}
@ -581,8 +571,7 @@ public class LocalSession {
return;
}
player.dispatchCUIEvent(
new SelectionShapeEvent(selector.getTypeId()));
player.dispatchCUIEvent(new SelectionShapeEvent(selector.getTypeId()));
if (selector instanceof CUIPointBasedRegion) {
((CUIPointBasedRegion) selector).describeCUI(player);

View File

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

View File

@ -573,7 +573,7 @@ public class Vector {
if (!(obj instanceof Vector)) {
return false;
}
Vector other = (Vector)obj;
Vector other = (Vector) obj;
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
*/
public int getBlockX() {
return (int)Math.round(x);
return (int) Math.round(x);
}
/**
@ -122,7 +122,7 @@ public class Vector2D {
* @return the z
*/
public int getBlockZ() {
return (int)Math.round(z);
return (int) Math.round(z);
}
/**
@ -165,7 +165,7 @@ public class Vector2D {
if (!(obj instanceof Vector2D)) {
return false;
}
Vector other = (Vector)obj;
Vector other = (Vector) obj;
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
* not have a session object generated for them.
*/
private HashMap<String,LocalSession> sessions =
new HashMap<String,LocalSession>();
private HashMap<String,LocalSession> sessions = new HashMap<String,LocalSession>();
/**
* Initialize statically.
@ -113,13 +112,14 @@ public class WorldEdit {
final Logging loggingAnnotation = method.getAnnotation(Logging.class);
final Logging.LogMode logMode;
if (loggingAnnotation == null)
if (loggingAnnotation == null) {
logMode = null;
else
} else {
logMode = loggingAnnotation.value();
}
String msg = "WorldEdit: " + player.getName() + "(in " + player.getWorld().getName() + ")"
+ ": " + StringUtil.joinString(args, " ");
String msg = "WorldEdit: " + player.getName() + " (in \"" + player.getWorld().getName()
+ "\")" + ": " + StringUtil.joinString(args, " ");
if (logMode != null) {
Vector position = player.getPosition();
final LocalSession session = getSession(player);
@ -690,8 +690,7 @@ public class WorldEdit {
}
if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+\\.[A-Za-z0-9]+$")) {
throw new InvalidFilenameException(filename,
"Invalid characters or extension missing");
throw new InvalidFilenameException(filename, "Invalid characters or extension missing");
}
f = new File(dir, filename);
@ -749,7 +748,7 @@ public class WorldEdit {
* @return
*/
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")) {
// Bug workaround
// Blocks this from being used after the thru function
// @TODO do this right or make craftbukkit do it right
if (!session.canUseJumpto()){
session.toggleJumptoBlock();
return false;
@ -1085,8 +1085,9 @@ public class WorldEdit {
}
// Bug workaround, so it wont do the Jumpto compass function
// Right after this teleport
if (session.canUseJumpto())
if (session.canUseJumpto()) {
session.toggleJumptoBlock();
}
return true;
}

View File

@ -43,7 +43,7 @@ public class BaseBlock {
* @param type
*/
public BaseBlock(int type) {
this.type = (short)type;
this.type = (short) type;
}
/**
@ -53,22 +53,22 @@ public class BaseBlock {
* @param data
*/
public BaseBlock(int type, int data) {
this.type = (short)type;
this.data = (byte)data;
this.type = (short) type;
this.data = (byte) data;
}
/**
* @return the type
*/
public int getType() {
return (int)type;
return (int) type;
}
/**
* @param type the type to set
*/
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
*/
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.
*/
public void rotate90() {
data = (byte)BlockData.rotate90(type, data);
data = (byte) BlockData.rotate90(type, data);
}
/**
* Rotate this block -90 degrees.
*/
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)) {
return false;
}
return (type == ((BaseBlock)o).type)
&& (data == ((BaseBlock)o).data || data == -1 || ((BaseBlock)o).data == -1);
return (type == ((BaseBlock) o).type)
&& (data == ((BaseBlock) o).data || data == -1 || ((BaseBlock) o).data == -1);
}
@Override

View File

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

View File

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

View File

@ -49,8 +49,8 @@ public class ChunkCommands {
throws WorldEditException {
Vector pos = player.getBlockIn();
int chunkX = (int)Math.floor(pos.getBlockX() / 16.0);
int chunkZ = (int)Math.floor(pos.getBlockZ() / 16.0);
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
String folder1 = Integer.toString(WorldEdit.divisorMod(chunkX, 64), 36);
String folder2 = Integer.toString(WorldEdit.divisorMod(chunkZ, 64), 36);
@ -159,7 +159,10 @@ public class ChunkCommands {
player.printError("Error occurred: " + e.getMessage());
} finally {
if (out != null) {
try { out.close(); } catch (IOException ie) {}
try {
out.close();
} catch (IOException ie) {
}
}
}
} else {

View File

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

View File

@ -45,14 +45,19 @@ public class ScriptingCommands {
public static void execute(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
// @TODO: Check for worldedit.scripting.execute.<script> permission
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 f = we.getSafeOpenFile(player, dir, args.getString(0), "js",
File f = we.getSafeOpenFile(player, dir, name, "js",
new String[] {"js"});
we.runScript(player, f, scriptArgs);
@ -70,10 +75,14 @@ public class ScriptingCommands {
public static void executeLast(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
// @TODO: Check for worldedit.scripting.execute.<script> permission
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) {
player.printError("Use /cs with a script name first.");
return;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -66,8 +66,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
player.print("First position set to " + pos1 + ".");
}
session.dispatchCUIEvent(player,
new SelectionPointEvent(0, pos, getArea()));
session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos, getArea()));
}
public void explainSecondarySelection(LocalPlayer player,
@ -79,18 +78,15 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
player.print("Second position set to " + pos2 + ".");
}
session.dispatchCUIEvent(player,
new SelectionPointEvent(1, pos, getArea()));
session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos, getArea()));
}
public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
if (pos1 != null) {
session.dispatchCUIEvent(player,
new SelectionPointEvent(0, pos1, getArea()));
session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos1, getArea()));
}
if (pos2 != null) {
session.dispatchCUIEvent(player,
new SelectionPointEvent(1, pos2, getArea()));
session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos2, getArea()));
}
}
@ -151,12 +147,12 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
}
public void describeCUI(LocalPlayer player) {
if (pos1 != null)
player.dispatchCUIEvent(
new SelectionPointEvent(0, pos1, getArea()));
if (pos2 != null)
player.dispatchCUIEvent(
new SelectionPointEvent(1, pos2, getArea()));
if (pos1 != null) {
player.dispatchCUIEvent(new SelectionPointEvent(0, pos1, getArea()));
}
if (pos2 != null) {
player.dispatchCUIEvent(new SelectionPointEvent(1, pos2, 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.SelectionMinMaxEvent;
import com.sk89q.worldedit.cui.SelectionPoint2DEvent;
import com.sk89q.worldedit.cui.SelectionPointEvent;
import com.sk89q.worldedit.cui.SelectionShapeEvent;
/**
@ -83,15 +82,12 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedR
public void explainSecondarySelection(LocalPlayer player,
LocalSession session, Vector pos) {
player.print("Added point #" + region.size() + " at " + pos + ".");
session.dispatchCUIEvent(player,
new SelectionPoint2DEvent(region.size() - 1, pos, getArea()));
session.dispatchCUIEvent(player,
new SelectionMinMaxEvent(region.minY, region.maxY));
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getArea()));
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.minY, region.maxY));
}
public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
session.dispatchCUIEvent(player,
new SelectionMinMaxEvent(region.minY, region.maxY));
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.minY, region.maxY));
}
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
@ -153,11 +149,9 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedR
public void describeCUI(LocalPlayer player) {
List<BlockVector2D> points = region.getPoints();
for (int id = 0; id < points.size(); id++) {
player.dispatchCUIEvent(
new SelectionPoint2DEvent(id, points.get(id), getArea()));
player.dispatchCUIEvent(new SelectionPoint2DEvent(id, points.get(id), getArea()));
}
player.dispatchCUIEvent(
new SelectionMinMaxEvent(region.minY, region.maxY));
player.dispatchCUIEvent(new SelectionMinMaxEvent(region.minY, region.maxY));
}
}

View File

@ -52,9 +52,9 @@ public class RhinoCraftScriptEngine implements CraftScriptEngine {
throw new ScriptException(e.getMessage());
} catch (RhinoException e) {
if (e instanceof WrappedException) {
Throwable cause = ((WrappedException)e).getCause();
Throwable cause = ((WrappedException) e).getCause();
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;
if (e instanceof JavaScriptException) {
msg = String.valueOf(((JavaScriptException)e).getValue());
msg = String.valueOf(((JavaScriptException) e).getValue());
} else {
msg = e.getMessage();
}

View File

@ -42,7 +42,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
Scriptable scope = setupScope(cx, context);
String filename = (filename = (String)get(ScriptEngine.FILENAME)) == null
String filename = (filename = (String) get(ScriptEngine.FILENAME)) == null
? "<unknown>" : filename;
try {
@ -52,7 +52,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
int line = (line = e.lineNumber()) == 0 ? -1 : line;
if (e instanceof JavaScriptException) {
msg = String.valueOf(((JavaScriptException)e).getValue());
msg = String.valueOf(((JavaScriptException) e).getValue());
} else {
msg = e.getMessage();
}
@ -72,7 +72,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
Scriptable scope = setupScope(cx, context);
String filename = (filename = (String)get(ScriptEngine.FILENAME)) == null
String filename = (filename = (String) get(ScriptEngine.FILENAME)) == null
? "<unknown>" : filename;
try {
@ -82,7 +82,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
int line = (line = e.lineNumber()) == 0 ? -1 : line;
if (e instanceof JavaScriptException) {
msg = String.valueOf(((JavaScriptException)e).getValue());
msg = String.valueOf(((JavaScriptException) e).getValue());
} else {
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)
throws MaxChangedBlocksException {
clipboard.place(editSession,
pos.subtract(clipboard.getSize().divide(2)), noAir);
clipboard.place(editSession, pos.subtract(clipboard.getSize().divide(2)), noAir);
}
}