29 lines
732 B
Java
29 lines
732 B
Java
package net.minecraft.commands.builder;
|
|
|
|
public abstract class CommandBuilder {
|
|
private boolean finished;
|
|
private Runnable commandExecutor;
|
|
|
|
public void finish() {
|
|
if (finished) {
|
|
throw new IllegalStateException("Cannot finish() multiple times!");
|
|
}
|
|
if (commandExecutor == null) {
|
|
throw new IllegalStateException("Cannot finish() without a command executor!");
|
|
}
|
|
onFinish();
|
|
finished = true;
|
|
}
|
|
|
|
protected abstract void onFinish();
|
|
|
|
public CommandBuilder executes(Runnable runnable) {
|
|
this.commandExecutor = runnable;
|
|
return this;
|
|
}
|
|
|
|
public Runnable getCommandExecutor() {
|
|
return commandExecutor;
|
|
}
|
|
}
|