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