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 newCrowdControlinstance that acts as a server for Crowd Control clients to connect to.
-
-
Field Summary
Fields Modifier and Type Field Description protected intportThe port that the client/server will connect to or listen on.protected @NotNull Function<@NotNull CrowdControl,@NotNull SocketManager>socketManagerCreatorA function (usually a constructor) that creates a newSocketManagergiven aCrowdControlinstance.
-
Constructor Summary
Constructors Constructor Description CrowdControlServerBuilder()Creates a newCrowdControlserver builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull CrowdControlbuild()Builds a newCrowdControlinstance using the provided variables.@NotNull CrowdControlServerBuilderpassword(@NotNull String password)Sets the password required for Crowd Control clients to connect.@NotNull CrowdControlServerBuilderport(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 newSocketManagergiven aCrowdControlinstance.
-
port
protected int port
The port that the client/server will connect to or listen on.
-
-
Constructor Detail
-
CrowdControlServerBuilder
@CheckReturnValue public CrowdControlServerBuilder()
Creates a newCrowdControlserver builder.
-
-
Method Detail
-
password
@CheckReturnValue @Contract("_ -> this") @NotNull public @NotNull CrowdControlServerBuilder password(@NotNull @NotNull String password) throws IllegalArgumentExceptionSets 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 IllegalArgumentExceptionSets the port that will be used by the Crowd Control server.- Specified by:
portin 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 IllegalStateExceptionBuilds a newCrowdControlinstance using the provided variables.- Returns:
- new CrowdControl instance
- Throws:
IllegalStateException-port(int)orpassword(String)was not called
-
-