#1449 Fix copying of Commands, add tests with command delay

This commit is contained in:
ljacqu
2018-09-11 22:03:46 +02:00
parent 035c2f352a
commit 22c08c9fc3
7 changed files with 53 additions and 44 deletions
@@ -19,26 +19,21 @@ public class Command {
}
/**
* Constructor.
* Creates a copy of this Command object, setting the given command text on the copy.
*
* @param command the command
* @param executor the executor of the command
* @param command the command text to use in the copy
* @return copy of the source with the new command
*/
public Command(String command, Executor executor) {
this(command, executor, 0);
public Command copyWithCommand(String command) {
Command copy = new Command();
setValuesToCopyWithNewCommand(copy, command);
return copy;
}
/**
* Constructor.
*
* @param command the command
* @param executor the executor of the command
* @param delay the delay (in ticks) before executing command
*/
public Command(String command, Executor executor, long delay) {
this.command = command;
this.executor = executor;
this.delay = delay;
protected void setValuesToCopyWithNewCommand(Command copy, String newCommand) {
copy.command = newCommand;
copy.executor = this.executor;
copy.delay = this.delay;
}
public String getCommand() {