45 lines
1.1 KiB
Java
45 lines
1.1 KiB
Java
package game.command;
|
|
|
|
import java.util.Map;
|
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
|
|
public abstract class ScriptExecutable implements Executable {
|
|
private final String name;
|
|
private final Map<String, Parameter> parameters = Maps.newHashMap();
|
|
|
|
private int parPos = 0;
|
|
private boolean parReq = true;
|
|
|
|
protected ScriptExecutable(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
protected ScriptExecutable setParamsOptional() {
|
|
this.parReq = false;
|
|
return this;
|
|
}
|
|
|
|
protected ScriptExecutable addParameter(String name, ArgumentParser ... parsers) {
|
|
this.parameters.put(name, new Parameter(name, (char)0, this.parPos++, this.parReq, Lists.newArrayList(parsers)));
|
|
return this;
|
|
}
|
|
|
|
protected ScriptExecutable addParameter(String name, char shortName, ArgumentParser ... parsers) {
|
|
this.parameters.put(name, new Parameter(name, shortName, -1, false, Lists.newArrayList(parsers)));
|
|
return this;
|
|
}
|
|
|
|
public Object exec(ScriptEnvironment env, ScriptArgs args) {
|
|
return null;
|
|
}
|
|
|
|
public Map<String, Parameter> getParameters() {
|
|
return this.parameters;
|
|
}
|
|
|
|
public String getName() {
|
|
return this.name;
|
|
}
|
|
}
|