2020-07-10 16:37:18 +02:00
|
|
|
package net.minestom.server.command.builder;
|
|
|
|
|
|
|
|
import net.minestom.server.command.builder.arguments.Argument;
|
|
|
|
import net.minestom.server.command.builder.condition.CommandCondition;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.List;
|
|
|
|
|
2020-07-14 13:35:07 +02:00
|
|
|
public class Command {
|
2020-07-10 16:37:18 +02:00
|
|
|
|
|
|
|
private String name;
|
|
|
|
private String[] aliases;
|
|
|
|
|
|
|
|
private CommandExecutor defaultExecutor;
|
|
|
|
private CommandCondition condition;
|
|
|
|
private List<CommandSyntax> syntaxes;
|
|
|
|
|
|
|
|
public Command(String name, String... aliases) {
|
|
|
|
this.name = name;
|
|
|
|
this.aliases = aliases;
|
|
|
|
|
|
|
|
this.syntaxes = new ArrayList<>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Command(String name) {
|
|
|
|
this(name, new String[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public CommandCondition getCondition() {
|
|
|
|
return condition;
|
|
|
|
}
|
|
|
|
|
2020-07-14 13:35:07 +02:00
|
|
|
public void setCondition(CommandCondition commandCondition) {
|
2020-07-10 16:37:18 +02:00
|
|
|
this.condition = commandCondition;
|
|
|
|
}
|
|
|
|
|
2020-07-14 13:35:07 +02:00
|
|
|
public void addCallback(ArgumentCallback callback, Argument argument) {
|
2020-07-10 16:37:18 +02:00
|
|
|
argument.setCallback(callback);
|
|
|
|
}
|
|
|
|
|
2020-07-14 13:35:07 +02:00
|
|
|
public void addSyntax(CommandExecutor executor, Argument... args) {
|
2020-07-10 16:37:18 +02:00
|
|
|
CommandSyntax syntax = new CommandSyntax(args);
|
|
|
|
syntax.setExecutor(executor);
|
|
|
|
this.syntaxes.add(syntax);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String[] getAliases() {
|
|
|
|
return aliases;
|
|
|
|
}
|
|
|
|
|
|
|
|
public CommandExecutor getDefaultExecutor() {
|
|
|
|
return defaultExecutor;
|
|
|
|
}
|
|
|
|
|
2020-07-14 13:35:07 +02:00
|
|
|
public void setDefaultExecutor(CommandExecutor executor) {
|
2020-07-10 16:37:18 +02:00
|
|
|
this.defaultExecutor = executor;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Collection<CommandSyntax> getSyntaxes() {
|
|
|
|
return syntaxes;
|
|
|
|
}
|
|
|
|
}
|