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,9 +34,10 @@ 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

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

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

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

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

@ -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,12 +163,11 @@ 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:
@ -317,12 +317,11 @@ 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:
@ -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,10 +426,10 @@ 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;
@ -444,7 +437,6 @@ public final class BlockData {
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;
} }
@ -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;
@ -474,7 +465,6 @@ public final class BlockData {
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);
@ -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;
@ -519,28 +506,22 @@ public final class BlockData {
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;
} }
@ -570,7 +549,6 @@ public final class BlockData {
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;

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

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