Package dev.qixils.crowdcontrol.builder
Class CrowdControlServerBuilder
- java.lang.Object
-
- dev.qixils.crowdcontrol.builder.CrowdControlServerBuilder
-
- All Implemented Interfaces:
CrowdControlBuilder
public final class CrowdControlServerBuilder extends Object
Builds a newCrowdControl
instance that acts as a server for Crowd Control clients to connect to.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
port
The port that the client/server will connect to or listen on.protected @NotNull Function<@NotNull CrowdControl,@NotNull SocketManager>
socketManagerCreator
A function (usually a constructor) that creates a newSocketManager
given aCrowdControl
instance.
-
Constructor Summary
Constructors Constructor Description CrowdControlServerBuilder()
Creates a newCrowdControl
server builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull CrowdControl
build()
Builds a newCrowdControl
instance using the provided variables.@NotNull CrowdControlServerBuilder
password(@NotNull String password)
Sets the password required for Crowd Control clients to connect.@NotNull CrowdControlServerBuilder
port(int port)
Sets the port that will be used by the Crowd Control server.
-
-
-
Field Detail
-
socketManagerCreator
@NotNull protected final @NotNull Function<@NotNull CrowdControl,@NotNull SocketManager> socketManagerCreator
A function (usually a constructor) that creates a newSocketManager
given aCrowdControl
instance.
-
port
protected int port
The port that the client/server will connect to or listen on.
-
-
Constructor Detail
-
CrowdControlServerBuilder
@CheckReturnValue public CrowdControlServerBuilder()
Creates a newCrowdControl
server builder.
-
-
Method Detail
-
password
@CheckReturnValue @Contract("_ -> this") @NotNull public @NotNull CrowdControlServerBuilder password(@NotNull @NotNull String password) throws IllegalArgumentException
Sets the password required for Crowd Control clients to connect.- Parameters:
password
- password clients must enter to connect- Returns:
- this builder
- Throws:
IllegalArgumentException
- the password was null or blank
-
port
@CheckReturnValue @Contract("_ -> this") @NotNull public @NotNull CrowdControlServerBuilder port(int port) throws IllegalArgumentException
Sets the port that will be used by the Crowd Control server.- Specified by:
port
in interfaceCrowdControlBuilder
- Parameters:
port
- port to listen for new connections on- Returns:
- this builder
- Throws:
IllegalArgumentException
- the port was outside the expected bounds of [1,65536]
-
build
@CheckReturnValue @Contract("-> new") @NotNull public @NotNull CrowdControl build() throws IllegalStateException
Builds a newCrowdControl
instance using the provided variables.- Returns:
- new CrowdControl instance
- Throws:
IllegalStateException
-port(int)
orpassword(String)
was not called
-
-