Added /s to repeat last script.

This commit is contained in:
sk89q 2011-01-23 02:09:51 -08:00
parent af1acd42b8
commit 56d69f9e77
3 changed files with 40 additions and 0 deletions

View File

@ -250,6 +250,9 @@ commands:
cs:
description: Execute a CraftScript
usage: /<command> <filename> [arg1 [args2 [arg3 [...]]]]
s:
description: Re-execute last CraftScript
usage: /<command> [arg1 [args2 [arg3 [...]]]]
reloadwe:
description: Reload WorldEdit's configuration

View File

@ -48,6 +48,7 @@ public class LocalSession {
private int maxBlocksChanged = -1;
private boolean useInventory;
private Snapshot snapshot;
private String lastScript;
/**
* Clear history.
@ -412,4 +413,18 @@ public class LocalSession {
public void setUseInventory(boolean useInventory) {
this.useInventory = useInventory;
}
/**
* @return the lastScript
*/
public String getLastScript() {
return lastScript;
}
/**
* @param lastScript the lastScript to set
*/
public void setLastScript(String lastScript) {
this.lastScript = lastScript;
}
}

View File

@ -178,6 +178,7 @@ public class WorldEditController {
commands.put("/rbrush", "[ID] <Radius> - Switch to the replacing sphere brush tool");
commands.put("/cs", "[Filename] <args...> - Execute a CraftScript");
commands.put("/s", "<args...> - Re-execute last CraftScript");
}
/**
@ -1714,8 +1715,29 @@ public class WorldEditController {
String[] args = new String[split.length - 1];
System.arraycopy(split, 1, args, 0, split.length - 1);
session.setLastScript(split[1]);
runScript(player, split[1], args);
return true;
// CraftScript
} else if (split[0].equalsIgnoreCase("/s")) {
checkArgs(split, 1, -1, split[0]);
String lastScript = session.getLastScript();
if (lastScript == null) {
player.printError("Use /cs with a script name first.");
return true;
}
String[] args = new String[split.length];
System.arraycopy(split, 0, args, 0, split.length);
args[0] = lastScript;
runScript(player, lastScript, args);
return true;
}