This commit is contained in:
Wizjany 2011-10-26 16:50:46 -04:00
parent 8797d8ac3c
commit 699807665d
19 changed files with 175 additions and 110 deletions

View File

@ -39,9 +39,9 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
"worldedit.reload",
"worldedit.selection",
"worlds.creative.worldedit.region"});
section.setProperty("permissions.groups.admins.permissions", new String[]{"*"});
section.setProperty("permissions.users.sk89q.permissions", new String[]{"worldedit"});
section.setProperty("permissions.users.sk89q.groups", new String[]{"admins"});
section.setProperty("permissions.groups.admins.permissions", new String[] {"*"});
section.setProperty("permissions.users.sk89q.permissions", new String[] {"worldedit"});
section.setProperty("permissions.users.sk89q.groups", new String[] {"admins"});
return section;
}

View File

@ -38,7 +38,6 @@ public class DinnerPermsResolver implements PermissionsResolver {
}
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
return new DinnerPermsResolver(server);
}

View File

@ -139,8 +139,7 @@ public class CommandContext {
// If it is a value flag, read another argument and add it
this.valueFlags.put(flagName, argList.get(nextArg++));
}
else {
} else {
booleanFlags.add(flagName);
}
}

View File

@ -721,7 +721,7 @@ public class YAMLNode {
return null;
} else if (o instanceof Number) {
return ((Number)o).intValue();
} else {
} else {
return null;
}
}
@ -737,7 +737,7 @@ public class YAMLNode {
return null;
} else if (o instanceof Number) {
return ((Number)o).doubleValue();
} else {
} else {
return null;
}
}

View File

@ -100,6 +100,11 @@ public class EditSession {
*/
private boolean fastMode = false;
/**
* Use fast lighting as well if using fast mode.
*/
private boolean fastLighting = false;
/**
* Block bag to use for getting blocks.
*/
@ -209,13 +214,13 @@ public class EditSession {
if (BlockType.usesData(type)) {
if (fastMode) {
result = world.setTypeIdAndDataFast(pt, type, block.getData() > -1 ? block.getData() : 0);
result = world.setTypeIdAndDataFast(pt, type, block.getData() > -1 ? block.getData() : 0, fastLighting);
} else {
result = world.setTypeIdAndData(pt, type, block.getData() > -1 ? block.getData() : 0);
}
} else {
if (fastMode) {
result = world.setBlockTypeFast(pt, type);
result = world.setBlockTypeFast(pt, type, fastLighting);
} else {
result = world.setBlockType(pt, type);
}
@ -227,8 +232,7 @@ public class EditSession {
if (blockBag == null) {
world.copyToWorld(pt, block);
}
}
else if (block instanceof TileEntityBlock) {
} else if (block instanceof TileEntityBlock) {
world.copyToWorld(pt, block);
}
}
@ -522,12 +526,30 @@ public class EditSession {
* Disable the queue. This will flush the queue.
*/
public void disableQueue() {
if (queued != false) {
if (queued) {
flushQueue();
}
queued = false;
}
/**
* Set fast lighting.
*
* @param fastLighting
*/
public void setFastLighting(boolean fastLighting) {
this.fastLighting = fastLighting;
}
/**
* Return fast lighting status.
*
* @return
*/
public boolean hasFastLighting() {
return fastLighting;
}
/**
* Set fast mode.
*
@ -561,7 +583,9 @@ public class EditSession {
rawSetBlock(pt, (BaseBlock) entry.getValue());
// TODO: use ChunkStore.toChunk(pt) after optimizing it.
if (fastMode) dirtyChunks.add(new BlockVector2D(pt.getBlockX() >> 4, pt.getBlockZ() >> 4));
if (fastMode) {
dirtyChunks.add(new BlockVector2D(pt.getBlockX() >> 4, pt.getBlockZ() >> 4));
}
}
// We don't want to place these blocks if other blocks were missing
@ -629,7 +653,9 @@ public class EditSession {
blocks.remove(pt);
// TODO: use ChunkStore.toChunk(pt) after optimizing it.
if (fastMode) dirtyChunks.add(new BlockVector2D(pt.getBlockX() >> 4, pt.getBlockZ() >> 4));
if (fastMode) {
dirtyChunks.add(new BlockVector2D(pt.getBlockX() >> 4, pt.getBlockZ() >> 4));
}
}
}
}
@ -1794,9 +1820,24 @@ public class EditSession {
}
/**
* Makes a sphere or ellipsoid.
* Makes a cylinder.
*
* @param pos Center of the sphere or ellipsoid
* @param pos Center of the cylinder
* @param block The block pattern to use
* @param radius The cylinder's radius
* @param height The cylinder's up/down extent. If negative, extend downward.
* @param filled If false, only a shell will be generated.
* @return number of blocks changed
* @throws MaxChangedBlocksException
*/
public int makeCylinder(Vector pos, Pattern block, double radius, int height, boolean filled) throws MaxChangedBlocksException {
return makeCylinder(pos, block, radius, radius, height, filled);
}
/**
* Makes a cylinder.
*
* @param pos Center of the cylinder
* @param block The block pattern to use
* @param radiusX The cylinder's largest north/south extent
* @param radiusZ The cylinder's largest east/west extent
@ -1875,6 +1916,20 @@ public class EditSession {
return affected;
}
/**
* Makes a sphere.
*
* @param pos Center of the sphere or ellipsoid
* @param block The block pattern to use
* @param radius The sphere's radius
* @param filled If false, only a shell will be generated.
* @return number of blocks changed
* @throws MaxChangedBlocksException
*/
public int makeSphere(Vector pos, Pattern block, double radius, boolean filled) throws MaxChangedBlocksException {
return makeSphere(pos, block, radius, radius, radius, filled);
}
/**
* Makes a sphere or ellipsoid.
*
@ -2538,8 +2593,7 @@ public class EditSession {
}
/**
* @param blockBag
* the blockBag to set
* @param blockBag the blockBag to set
*/
public void setBlockBag(BlockBag blockBag) {
this.blockBag = blockBag;

View File

@ -73,6 +73,7 @@ public class LocalSession {
private boolean beenToldVersion = false;
private boolean hasCUISupport = false;
private boolean fastMode = false;
private boolean fastLighting = false;
private Mask mask;
private TimeZone timezone = TimeZone.getDefault();
private Boolean jumptoBlock = true;
@ -644,6 +645,7 @@ public class LocalSession {
new EditSession(player.getWorld(),
getBlockChangeLimit(), blockBag);
editSession.setFastMode(fastMode);
editSession.setFastLighting(fastLighting);
editSession.setMask(mask);
return editSession;
@ -667,6 +669,24 @@ public class LocalSession {
this.fastMode = fastMode;
}
/**
* Checks if the session has fast lighting enabled.
*
* @return
*/
public boolean hasFastLighting() {
return fastLighting;
}
/**
* Set fast lighting.
*
* @param fastLighting
*/
public void setFastLighting(boolean fastLighting) {
this.fastLighting = fastLighting;
}
/**
* Get the mask.
*

View File

@ -63,6 +63,10 @@ public abstract class LocalWorld {
return setBlockType(pt, type);
}
public boolean setBlockTypeFast(Vector pt, int type, boolean fastLighting) {
return setBlockTypeFast(pt, type);
}
/**
* Get block type.
*
@ -100,7 +104,7 @@ public abstract class LocalWorld {
setBlockData(pt, data);
return ret;
}
/**
* set block type & data
* @param pt
@ -113,7 +117,11 @@ public abstract class LocalWorld {
setBlockDataFast(pt, data);
return ret;
}
public boolean setTypeIdAndDataFast(Vector pt, int type, int data, boolean fastLighting) {
return setTypeIdAndDataFast(pt, type, data);
}
/**
* Get block data.
*

View File

@ -34,8 +34,8 @@ public class BukkitServerInterface extends ServerInterface {
@Override
public int resolveItem(String name) {
// TODO Auto-generated method stub
return 0;
Material mat = Material.matchMaterial(name);
return mat == null ? 0 : mat.getId();
}
@Override

View File

@ -111,8 +111,21 @@ public class BukkitWorld extends LocalWorld {
*/
@Override
public boolean setBlockTypeFast(Vector pt, int type) {
return setBlockTypeFast(pt, type, false);
}
/**
* Set block type.
*
* @param pt
* @param type
* @param fastLighting
* @return
*/
@Override
public boolean setBlockTypeFast(Vector pt, int type, boolean fastLighting) {
final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (fastLightingAvailable) {
if (fastLightingAvailable && fastLighting) {
type = type & 255;
final int previousOpacity = Block_lightOpacity[type];
Block_lightOpacity[type] = 0;
@ -145,8 +158,13 @@ public class BukkitWorld extends LocalWorld {
*/
@Override
public boolean setTypeIdAndDataFast(Vector pt, int type, int data){
return setTypeIdAndDataFast(pt, type, data, false);
}
@Override
public boolean setTypeIdAndDataFast(Vector pt, int type, int data, boolean fastLighting) {
final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (fastLightingAvailable) {
if (fastLightingAvailable && fastLighting) {
type = type & 255;
final int previousOpacity = Block_lightOpacity[type];
Block_lightOpacity[type] = 0;
@ -157,7 +175,7 @@ public class BukkitWorld extends LocalWorld {
return block.setTypeIdAndData(type, (byte) data, false);
}
/**
* Get block type.
*
@ -788,8 +806,7 @@ public class BukkitWorld extends LocalWorld {
lightEmitters.add(chunk.getBlock(x, y, z).getState());
if (blockID == 20) {
blocks[index] = 0;
}
else {
} else {
blocks[index] = 20;
}
@ -808,8 +825,7 @@ public class BukkitWorld extends LocalWorld {
lightEmitter.update(true);
}
}
}
catch (Exception e) {
} catch (Exception e) {
System.out.println("Fast Mode: Could not fix lighting. Probably an incompatible version of CraftBukkit.");
e.printStackTrace();
}
@ -843,8 +859,7 @@ public class BukkitWorld extends LocalWorld {
NibbleArray_ctor = Class.forName("net.minecraft.server.NibbleArray").getConstructor(int.class, int.class);
fastLightingAvailable = true;
}
catch (Throwable e) {
} catch (Throwable e) {
e.printStackTrace();
}
}

View File

@ -63,6 +63,7 @@ public class GeneralCommands {
@Command(
aliases = { "/fast" },
flags = "l",
usage = "[on|off]",
desc = "Toggle fast mode",
min = 0,
@ -73,25 +74,24 @@ public class GeneralCommands {
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
boolean light = args.hasFlag('f');
String newState = args.getString(0, null);
if (session.hasFastMode()) {
if ("on".equals(newState)) {
player.printError("Fast mode already enabled.");
return;
}
Boolean dir = newState.equals("on") ? true : newState.equals("off") ? false : null;
session.setFastMode(false);
player.print("Fast mode disabled.");
}
else {
if ("off".equals(newState)) {
player.printError("Fast mode already disabled.");
return;
}
boolean hadFast = session.hasFastMode();
boolean hadLight = session.hasFastLighting();
session.setFastMode(true);
player.print("Fast mode enabled. Lighting in the affected chunks may be wrong and/or you may need to rejoin to see changes.");
boolean setFast = dir == null ? !hadFast : dir;
boolean setLight = dir == null ? !hadLight : dir;
session.setFastMode(setFast);
if (light) {
session.setFastLighting(setLight);
}
player.print("Fast mode " + (!setFast ? "disabled." :
("enabled. You may need to rejoin to see changes"
+ (setLight ? "and lighting in affected chunks may be wrong." : "."))));
}
@Command(

View File

@ -322,8 +322,7 @@ public class GenerationCommands {
try {
expression = Expression.compile(args.getJoinedStrings(1), "x", "y", "z");
expression.optimize();
}
catch (ExpressionException e) {
} catch (ExpressionException e) {
player.printError(e.getMessage());
return;
}
@ -336,15 +335,13 @@ public class GenerationCommands {
protected boolean isInside(double x, double y, double z) {
try {
return expression.evaluate(x, y, z) > 0;
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
};
}
else if (args.hasFlag('o')) {
} else if (args.hasFlag('o')) {
final Vector placement = session.getPlacementPosition(player);
final double placementX = placement.getX();
@ -356,15 +353,13 @@ public class GenerationCommands {
protected boolean isInside(double x, double y, double z) {
try {
return expression.evaluate(x - placementX, y - placementY, z - placementZ) > 0;
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
};
}
else {
} else {
final Vector min = region.getMinimumPoint();
final Vector max = region.getMaximumPoint();
final Vector center = max.add(min).multiply(0.5);
@ -376,8 +371,7 @@ public class GenerationCommands {
try {
return expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ()) > 0;
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
return false;
}

View File

@ -194,8 +194,7 @@ public class SelectionCommands {
player.print("Chunks selected: ("
+ min2D.getBlockX() + ", " + min2D.getBlockZ() + ") - ("
+ max2D.getBlockX() + ", " + max2D.getBlockZ() + ")");
}
else {
} else {
final Vector2D min2D = ChunkStore.toChunk(player.getBlockIn());
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);

View File

@ -54,8 +54,7 @@ public class ToolUtilCommands {
session.disableSuperPickAxe();
player.print("Super pick axe disabled.");
}
else {
} else {
if ("off".equals(newState)) {
player.printError("Super pick axe already disabled.");
return;

View File

@ -140,8 +140,7 @@ public class Lexer {
if (!numberPart.isEmpty()) {
try {
tokens.add(new NumberToken(position, Double.parseDouble(numberPart)));
}
catch (NumberFormatException e) {
} catch (NumberFormatException e) {
throw new LexerException(position, "Number parsing failed", e);
}
@ -156,8 +155,7 @@ public class Lexer {
if (!identifierPart.isEmpty()) {
if (keywords.contains(identifierPart)) {
tokens.add(new KeywordToken(position, identifierPart));
}
else {
} else {
tokens.add(new IdentifierToken(position, identifierPart));
}
@ -167,8 +165,7 @@ public class Lexer {
}
throw new LexerException(position, "Unknown character '" + ch + "'");
}
while (position < expression.length());
} while (position < expression.length());
return tokens;
}

View File

@ -100,8 +100,7 @@ public class Parser {
final Token next = peek();
if (next.id() == '(') {
halfProcessed.add(parseFunctionCall(identifierToken));
}
else {
} else {
RValue variable = variables.get(identifierToken.value);
if (variable == null) {
throw new ParserException(current.getPosition(), "Variable '" + identifierToken.value + "' not found");
@ -130,8 +129,7 @@ public class Parser {
case 'o':
if (expressionStart) {
halfProcessed.add(new PrefixOperator((OperatorToken) current));
}
else {
} else {
halfProcessed.add(current);
}
++position;
@ -148,8 +146,7 @@ public class Parser {
if (isStatement) {
return ParserProcessors.processStatement(halfProcessed);
}
else {
} else {
return ParserProcessors.processExpression(halfProcessed);
}
}
@ -195,8 +192,7 @@ public class Parser {
}
return Functions.getFunction(identifierToken.getPosition(), identifierToken.value, args.toArray(new RValue[args.size()]));
}
catch (NoSuchMethodException e) {
} catch (NoSuchMethodException e) {
throw new ParserException(identifierToken.getPosition(), "Function not found", e);
}
}

View File

@ -134,12 +134,10 @@ public final class ParserProcessors {
for (Identifiable identifiable : input) {
if (semicolonFound) {
rhs.addLast(identifiable);
}
else {
} else {
if (identifiable.id() == ';') {
semicolonFound = true;
}
else {
} else {
lhs.addLast(identifiable);
}
}
@ -151,12 +149,10 @@ public final class ParserProcessors {
}
return processExpression(lhs);
}
else if (lhs.isEmpty()) {
} else if (lhs.isEmpty()) {
return processStatement(rhs);
}
else {
assert(semicolonFound);
} else {
assert (semicolonFound);
RValue lhsInvokable = processExpression(lhs);
RValue rhsInvokable = processStatement(rhs);
@ -193,8 +189,7 @@ public final class ParserProcessors {
}
rhs.removeFirst();
}
else {
} else {
lhs.addFirst(identifiable);
}
}
@ -206,8 +201,7 @@ public final class ParserProcessors {
try {
return Operators.getOperator(input.get(0).getPosition(), operator, lhsInvokable, rhsInvokable);
}
catch (NoSuchMethodException e) {
} catch (NoSuchMethodException e) {
final Token operatorToken = (Token) input.get(lhs.size());
throw new ParserException(operatorToken.getPosition(), "Couldn't find operator '" + operator + "'");
}
@ -236,8 +230,7 @@ public final class ParserProcessors {
}
lhs.removeLast();
}
else {
} else {
rhs.addLast(identifiable);
}
}
@ -249,8 +242,7 @@ public final class ParserProcessors {
try {
return Operators.getOperator(input.get(0).getPosition(), operator, lhsInvokable, rhsInvokable);
}
catch (NoSuchMethodException e) {
} catch (NoSuchMethodException e) {
final Token operatorToken = (Token) input.get(lhs.size());
throw new ParserException(operatorToken.getPosition(), "Couldn't find operator '" + operator + "'");
}
@ -280,19 +272,16 @@ public final class ParserProcessors {
try {
ret = Operators.getOperator(lastPosition, opName, ret);
continue;
}
catch (NoSuchMethodException e) {
} catch (NoSuchMethodException e) {
throw new ParserException(lastPosition, "No such prefix operator: " + operator);
}
}
}
if (last instanceof Token) {
throw new ParserException(lastPosition, "Extra token found in expression: " + last);
}
else if (last instanceof RValue) {
} else if (last instanceof RValue) {
throw new ParserException(lastPosition, "Extra expression found: " + last);
}
else {
} else {
throw new ParserException(lastPosition, "Extra element found: " + last);
}
}

View File

@ -49,14 +49,12 @@ public class Function extends RValue {
public final double getValue() throws EvaluationException {
try {
return (Double) method.invoke(null, (Object[]) args);
}
catch (InvocationTargetException e) {
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof EvaluationException) {
throw (EvaluationException) e.getTargetException();
}
throw new EvaluationException(-1, "Exception caught while evaluating expression", e.getTargetException());
}
catch (IllegalAccessException e) {
} catch (IllegalAccessException e) {
throw new EvaluationException(-1, "Internal error while evaluating expression", e);
}
}
@ -99,8 +97,7 @@ public class Function extends RValue {
if (optimizable) {
return new Constant(position, getValue());
}
else {
} else {
return new Function(position, method, optimizedArgs);
}
}

View File

@ -29,8 +29,8 @@ public final class Operators {
if (lhs instanceof LValue) {
try {
return new Function(position, Operators.class.getMethod(name, LValue.class, RValue.class), lhs, rhs);
} catch (NoSuchMethodException e) {
}
catch (NoSuchMethodException e) {}
}
return new Function(position, Operators.class.getMethod(name, RValue.class, RValue.class), lhs, rhs);
}
@ -39,8 +39,8 @@ public final class Operators {
if (argument instanceof LValue) {
try {
return new Function(position, Operators.class.getMethod(name, LValue.class), argument);
} catch (NoSuchMethodException e) {
}
catch (NoSuchMethodException e) {}
}
return new Function(position, Operators.class.getMethod(name, RValue.class), argument);
}

View File

@ -75,8 +75,7 @@ public class Sequence extends RValue {
for (RValue subInvokable : ((Sequence) invokable).sequence) {
newSequence.add(subInvokable);
}
}
else {
} else {
newSequence.add(invokable);
}
}