Add more variable args for expressions, quoting

This commit is contained in:
Kenzie Togami
2019-04-28 22:03:54 -07:00
parent d4fce65abc
commit 82c4846436
5 changed files with 103 additions and 14 deletions

View File

@ -273,8 +273,8 @@ public class GenerationCommands {
@Selection Region region,
@Arg(desc = "The pattern of blocks to set")
Pattern pattern,
@Arg(desc = "Expression to test block placement locations and set block type")
String expression,
@Arg(desc = "Expression to test block placement locations and set block type", variable = true)
List<String> expression,
@Switch(name = 'h', desc = "Generate a hollow shape")
boolean hollow,
@Switch(name = 'r', desc = "Use the game's coordinate origin")
@ -312,7 +312,7 @@ public class GenerationCommands {
}
try {
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow, session.getTimeout());
final int affected = editSession.makeShape(region, zero, unit, pattern, String.join(" ", expression), hollow, session.getTimeout());
player.findFreePosition();
player.print(affected + " block(s) have been created.");
return affected;
@ -334,8 +334,8 @@ public class GenerationCommands {
@Selection Region region,
@Arg(desc = "The biome type to set")
BiomeType target,
@Arg(desc = "Expression to test block placement locations and set biome type")
String expression,
@Arg(desc = "Expression to test block placement locations and set biome type", variable = true)
List<String> expression,
@Switch(name = 'h', desc = "Generate a hollow shape")
boolean hollow,
@Switch(name = 'r', desc = "Use the game's coordinate origin")
@ -372,7 +372,7 @@ public class GenerationCommands {
}
try {
final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow, session.getTimeout());
final int affected = editSession.makeBiomeShape(region, zero, unit, target, String.join(" ", expression), hollow, session.getTimeout());
player.findFreePosition();
player.print("" + affected + " columns affected.");
return affected;

View File

@ -382,8 +382,8 @@ public class RegionCommands {
@Logging(ALL)
public int deform(Player player, LocalSession session, EditSession editSession,
@Selection Region region,
@Arg(desc = "The expression to use")
String expression,
@Arg(desc = "The expression to use", variable = true)
List<String> expression,
@Switch(name = 'r', desc = "Use the game's coordinate origin")
boolean useRawCoords,
@Switch(name = 'o', desc = "Use the selection's center as origin")
@ -410,7 +410,7 @@ public class RegionCommands {
}
try {
final int affected = editSession.deformRegion(region, zero, unit, expression, session.getTimeout());
final int affected = editSession.deformRegion(region, zero, unit, String.join(" ", expression), session.getTimeout());
player.findFreePosition();
player.print(affected + " block(s) have been deformed.");
return affected;

View File

@ -492,10 +492,10 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.calc")
public void calc(Actor actor,
@Arg(desc = "Expression to evaluate")
String input) {
@Arg(desc = "Expression to evaluate", variable = true)
List<String> input) {
try {
Expression expression = Expression.compile(input);
Expression expression = Expression.compile(String.join(" ", input));
double result = expression.evaluate(
new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
String formatted = formatter.format(result);