Added the commands variable to the SimpleAutoResponder to register & get commands
This commit is contained in:
parent
cde48b5480
commit
8f719cec41
@ -4,6 +4,7 @@ import com.sun.net.httpserver.HttpContext;
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
import de.gnmyt.autoresponder.authentication.AuthenticationDetails;
|
||||
import de.gnmyt.autoresponder.authentication.ResponderAuthentication;
|
||||
import de.gnmyt.autoresponder.commands.ResponderCommand;
|
||||
import de.gnmyt.autoresponder.event.api.EventManager;
|
||||
import de.gnmyt.autoresponder.event.api.Listener;
|
||||
import de.gnmyt.autoresponder.exceptions.ResponderException;
|
||||
@ -13,6 +14,8 @@ import de.gnmyt.autoresponder.http.contexts.ResponderContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class SimpleAutoResponder {
|
||||
|
||||
@ -23,6 +26,8 @@ public class SimpleAutoResponder {
|
||||
|
||||
private NotFoundHandler notFoundHandler = new SendNothingHandler();
|
||||
|
||||
private final ArrayList<ResponderCommand> commands = new ArrayList<>();
|
||||
|
||||
private int port = 8025;
|
||||
private String prefix = "/";
|
||||
|
||||
@ -57,6 +62,7 @@ public class SimpleAutoResponder {
|
||||
* Registers the provided listeners
|
||||
*
|
||||
* @param listeners The listeners that you want to register
|
||||
* @return the current {@link SimpleAutoResponder} instance
|
||||
*/
|
||||
public SimpleAutoResponder registerListener(Listener... listeners) {
|
||||
for (Listener listener : listeners)
|
||||
@ -64,6 +70,17 @@ public class SimpleAutoResponder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the provided responder command
|
||||
*
|
||||
* @param commands The commands you want to register
|
||||
* @return the current {@link SimpleAutoResponder} instance
|
||||
*/
|
||||
public SimpleAutoResponder registerCommand(ResponderCommand... commands) {
|
||||
this.commands.addAll(Arrays.asList(commands));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the responder to use an authentication.
|
||||
* <p>
|
||||
@ -145,4 +162,13 @@ public class SimpleAutoResponder {
|
||||
public NotFoundHandler getNotFoundHandler() {
|
||||
return notFoundHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all registered commands
|
||||
*
|
||||
* @return all registered commands
|
||||
*/
|
||||
public ArrayList<ResponderCommand> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user