sk89q/worldedit — pull request #243 by afistofirony (2013-05-27 01:47:14+00:00)
Title: Support listing directions in //expand, //compact, and //shift.

This commit is designed primarily to facilitate laziness by allowing users to list multiple directions (i.e. **//shift 5 d,r** instead of **//shift 5 d** and **//shift 5 r**).

Support for this is added by replacing a single Vector with a List and then iterating through it in a foreach loop.

For example:

```
List dirs = new ArrayList();
int change = args.getInteger(0);
int reverseChange = 0;

switch (args.argsLength()) {
case 2:
// Either a reverse amount or a direction
try {
reverseChange = args.getInteger(1);
dirs.add(we.getDirection(player, "me"));
} catch (NumberFormatException e) {
if (args.getString(1).contains(",")) {
String[] split = args.getString(1).split(",");
for (String s : split){
dirs.add(we.getDirection(player, s.toLowerCase()));
}
} else dirs.add(we.getDirection(player,
args.getString(1).toLowerCase()));
}
break;

case 3:
// Both reverse amount and direction
reverseChange = args.getInteger(1);
if (args.getString(2).contains(",")) {
String[] split = args.getString(2).split(",");
for (String s : split){
dirs.add(we.getDirection(player, s.toLowerCase()));
}
} else dirs.add(we.getDirection(player,
args.getString(2).toLowerCase()));
break;
default:
dirs.add(we.getDirection(player, "me"));
}

Region region = session.getSelection(player.getWorld());
int oldSize = region.getArea();

if (reverseChange == 0) {
for (Vector dir : dirs) {
region.expand(dir.multiply(change));
}
} else {
for (Vector dir : dirs) {
region.expand(dir.multiply(change), dir.multiply(-reverseChange));
}
}
```