Package de.craftsblock.craftsnet.builder
Class CraftsNetBuilder
java.lang.Object
de.craftsblock.craftsnet.builder.CraftsNetBuilder
- Direct Known Subclasses:
AddonContainingBuilder
Builder class for configuring the CraftsNet.
- Since:
- 3.0.3-SNAPSHOT
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newCraftsNetBuilderinstance with default configuration settings. -
Method Summary
Modifier and TypeMethodDescriptionaddCodeSource(CodeSource codeSource) Adds aCodeSourceto the code sources list.build()Builds and starts the CraftsNet framework with the configured settings.Retrieves the activation type configured for the addon system.Retrieves the list ofCodeSourcethat should be taken into account.Retrieves the activation type configured for the command system.Retrieves the custom logger which should be used by CraftsNet.longRetrieves the log rotation size threshold.intRetrieves the session cache size configured.Retrieves the activation type configured for the web server.intRetrieves the port number configured for the web server.Retrieves the activation type configured for the WebSocket server.intRetrieves the port number configured for the WebSocket server.booleanisAddonSystem(ActivateType type) Checks if the addon system is configured with the specified activation type.booleanisCommandSystem(ActivateType type) Checks if the command system is configured with the specified activation type.booleanisDebug()Checks if debug mode is enabled.booleanisFileLogger(ActivateType type) Checks if the file logger is configured with the specified activation type.booleanChecks if log rotation is disabled.booleanisSSL()Checks if SSL is enabled.booleanisWebServer(ActivateType type) Checks if the web server is configured with the specified activation type.booleanChecks if the WebSocket server is configured with the specified activation type.removeCodeSource(CodeSource codeSource) Removes aCodeSourcefrom the code sources list.booleanDetermines whether from the client requested response encoding should be applied or not.protected voidApplies a single argument and its value to the builder.booleanChecks if ips should be hidden in the log output.booleanDetermines whether temporary files should be placed in the normal file system.booleanDetermines whether the registration of the default route (if no other route was registered) should be skipped on startup.booleanDetermines whether the version check should be skipped on startup.withAddonSystem(ActivateType type) Specifies the activation type for the addon system.withApplyResponseEncoding(boolean allowed) Specifies whether from the client requested response encodings should be applied or not.Configures the builder using a set of command-line arguments.Specifies the activation type for the command system.withCustomLogger(Logger logger) Sets a custom logger which will be used by CraftsNet.withDebug(boolean enabled) Specifies whether debug mode should be enabled.withFileLogger(ActivateType type) Specifies the activation type for the file logger.withIpsInLog(boolean enabled) Specifies whether ips should be blurred in the log output.withLogger(ActivateType type) Specifies the activation type for the logger.withLogRotate(@org.jetbrains.annotations.Range(from=0L, to=9223372036854775807L) long logRotate) Sets the log rotation size threshold for this builder.Disables log rotation by setting the log rotation size threshold to 0.withSessionCache(int size) Specifies the size of the session cache.withSkipDefaultRoute(boolean skip) Specifies whether the registration of the default route (if no other route was registered) should be skipped on startup.withSkipVersionCheck(boolean skip) Specifies whether the version check should be skipped on startup.withSSL(boolean enabled) Specifies whether SSL should be enabled.withTempFilesOnNormalFileSystem(boolean tempFilesOnNormalFileSystem) Configures whether temporary files should be placed on the normal file system.withWebServer(int port) Specifies the port for the web server.withWebServer(ActivateType type) Specifies the port for the web server.withWebServer(ActivateType type, int port) Specifies the activation type and port for the web server.withWebSocketServer(int port) Specifies the port for the WebSocket server.Specifies the activation type and port for the WebSocket server.withWebSocketServer(ActivateType type, int port) Specifies the activation type and port for the WebSocket server.
-
Constructor Details
-
CraftsNetBuilder
public CraftsNetBuilder()Constructs a newCraftsNetBuilderinstance with default configuration settings.
-
-
Method Details
-
withArgs
Configures the builder using a set of command-line arguments.Parses the provided arguments and applies corresponding settings to the builder. If a specific argument is not recognized, an exception is thrown.
- Parameters:
args- An array of command-line arguments to parse.- Returns:
- The current instance of
CraftsNetBuilderfor chaining. - Throws:
RuntimeException- If there is an error accessing the underlying argument parser's data.
-
setArg
Applies a single argument and its value to the builder.Recognizes a predefined set of argument names and updates the corresponding settings. If the argument is not recognized, an
IllegalStateExceptionis thrown.- Parameters:
arg- The argument name, case-insensitive.value- The argument value, used for arguments requiring additional data.- Throws:
IllegalStateException- If the argument name is not recognized.
-
addCodeSource
Adds aCodeSourceto the code sources list.- Parameters:
codeSource- TheCodeSourcethat should be added.- Returns:
- The
CraftsNetBuilderinstance.
-
removeCodeSource
Removes aCodeSourcefrom the code sources list.- Parameters:
codeSource- TheCodeSourcethat should be removed.- Returns:
- The
CraftsNetBuilderinstance.
-
withWebServer
Specifies the port for the web server.- Parameters:
port- The port number for the web server.- Returns:
- The
CraftsNetBuilderinstance.
-
withWebServer
Specifies the port for the web server.- Parameters:
type- The activation type for the web server.- Returns:
- The
CraftsNetBuilderinstance. - Since:
- 3.0.5-SNAPSHOT
-
withWebServer
Specifies the activation type and port for the web server.- Parameters:
type- The activation type for the web server.port- The port number for the web server.- Returns:
- The
CraftsNetBuilderinstance.
-
withWebSocketServer
Specifies the port for the WebSocket server.- Parameters:
port- The port number for the WebSocket server.- Returns:
- The
CraftsNetBuilderinstance.
-
withWebSocketServer
Specifies the activation type and port for the WebSocket server.- Parameters:
type- The activation type for the WebSocket server.- Returns:
- The
CraftsNetBuilderinstance. - Since:
- 3.0.5-SNAPSHOT
-
withWebSocketServer
Specifies the activation type and port for the WebSocket server.- Parameters:
type- The activation type for the WebSocket server.port- The port number for the WebSocket server.- Returns:
- The
CraftsNetBuilderinstance.
-
withAddonSystem
Specifies the activation type for the addon system.- Parameters:
type- The activation type for the addon system.- Returns:
- The
CraftsNetBuilderinstance.
-
withCommandSystem
Specifies the activation type for the command system.- Parameters:
type- The activation type for the command system.- Returns:
- The
CraftsNetBuilderinstance.
-
withSessionCache
Specifies the size of the session cache.- Parameters:
size- The size of the session cache.- Returns:
- The
CraftsNetBuilderinstance.
-
withFileLogger
Specifies the activation type for the file logger.- Parameters:
type- The activation type for the file logger.- Returns:
- The
CraftsNetBuilderinstance. - Since:
- 3.0.5-SNAPSHOT
-
withApplyResponseEncoding
Specifies whether from the client requested response encodings should be applied or not.- Parameters:
allowed-trueif the requested response encoding should be applied,falseotherwise.- Returns:
- The
CraftsNetBuilderinstance. - Since:
- 3.3.3-SNAPSHOT
-
withTempFilesOnNormalFileSystem
Configures whether temporary files should be placed on the normal file system. When set totrue, the application will store temporary files in the local file system instead of using the system's default temporary file location.- Parameters:
tempFilesOnNormalFileSystem-trueto place temporary files in the normal file system,falseotherwise.- Returns:
- the current
CraftsNetBuilderinstance for method chaining.
-
withSkipDefaultRoute
Specifies whether the registration of the default route (if no other route was registered) should be skipped on startup.- Parameters:
skip-trueif the version check should be skipped,falseotherwise.- Returns:
- The
CraftsNetBuilderinstance. - Since:
- 3.3.3-SNAPSHOT
-
withSkipVersionCheck
Specifies whether the version check should be skipped on startup.- Parameters:
skip-trueif the version check should be skipped, false otherwise.- Returns:
- The
CraftsNetBuilderinstance.
-
withCustomLogger
Sets a custom logger which will be used by CraftsNet. It can be null when the default logger should be used.- Parameters:
logger- The instance of the custom logger.- Returns:
- The
CraftsNetBuilderinstance. - Since:
- 3.0.5-SNAPSHOT
-
withLogger
Specifies the activation type for the logger.- Parameters:
type- The activation type for the logger.- Returns:
- The
CraftsNetBuilderinstance. - Since:
- 3.0.5-SNAPSHOT
-
withDebug
Specifies whether debug mode should be enabled.- Parameters:
enabled-trueif debug mode should be enabled,falseotherwise.- Returns:
- The
CraftsNetBuilderinstance.
-
withIpsInLog
Specifies whether ips should be blurred in the log output.- Parameters:
enabled-trueif ips should be readable in the log,falseotherwise.- Returns:
- The
CraftsNetBuilderinstance. - Since:
- 3.4.0-SNAPSHOT
-
withSSL
Specifies whether SSL should be enabled.- Parameters:
enabled-trueif SSL should be enabled,falseotherwise.- Returns:
- The
CraftsNetBuilderinstance.
-
withLogRotate
public CraftsNetBuilder withLogRotate(@org.jetbrains.annotations.Range(from=0L, to=9223372036854775807L) long logRotate) Sets the log rotation size threshold for this builder.- Parameters:
logRotate- the log rotation size threshold, in bytes. A value of 0 disables log rotation. Must be non-negative.- Returns:
- this
CraftsNetBuilderinstance, enabling method chaining.
-
withoutLogRotate
Disables log rotation by setting the log rotation size threshold to 0.- Returns:
- this
CraftsNetBuilderinstance, enabling method chaining.
-
getCodeSources
Retrieves the list ofCodeSourcethat should be taken into account.- Returns:
- The list containing
CodeSource.
-
getWebServerPort
public int getWebServerPort()Retrieves the port number configured for the web server.- Returns:
- The port number for the web server.
-
getWebServer
Retrieves the activation type configured for the web server.- Returns:
- The activation type for the web server.
-
isWebServer
Checks if the web server is configured with the specified activation type.- Parameters:
type- The activation type to check.- Returns:
- true if the web server is configured with the specified activation type, false otherwise.
-
getWebSocketServerPort
public int getWebSocketServerPort()Retrieves the port number configured for the WebSocket server.- Returns:
- The port number for the WebSocket server.
-
getWebSocketServer
Retrieves the activation type configured for the WebSocket server.- Returns:
- The activation type for the WebSocket server.
-
isWebSocketServer
Checks if the WebSocket server is configured with the specified activation type.- Parameters:
type- The activation type to check.- Returns:
- true if the WebSocket server is configured with the specified activation type, false otherwise.
-
getAddonSystem
Retrieves the activation type configured for the addon system.- Returns:
- The activation type for the addon system.
-
isAddonSystem
Checks if the addon system is configured with the specified activation type.- Parameters:
type- The activation type to check.- Returns:
- true if the addon system is configured with the specified activation type, false otherwise.
-
getCommandSystem
Retrieves the activation type configured for the command system.- Returns:
- The activation type for the command system.
-
isCommandSystem
Checks if the command system is configured with the specified activation type.- Parameters:
type- The activation type to check.- Returns:
- true if the command system is configured with the specified activation type, false otherwise.
-
getSessionCacheSize
public int getSessionCacheSize()Retrieves the session cache size configured.- Returns:
- The session cache size.
-
isFileLogger
Checks if the file logger is configured with the specified activation type.- Parameters:
type- The activation type to check.- Returns:
- true if the file logger is configured with the specified activation type, false otherwise.
- Since:
- 3.0.5-SNAPSHOT
-
responseEncodingAllowed
public boolean responseEncodingAllowed()Determines whether from the client requested response encoding should be applied or not.- Returns:
trueif the request encoding should be applied,falseotherwise.- Since:
- 3.3.3-SNAPSHOT
-
shouldPlaceTempFilesOnNormalFileSystem
public boolean shouldPlaceTempFilesOnNormalFileSystem()Determines whether temporary files should be placed in the normal file system.- Returns:
trueif temporary files are placed on the normal file system,falseotherwise.
-
shouldSkipDefaultRoute
public boolean shouldSkipDefaultRoute()Determines whether the registration of the default route (if no other route was registered) should be skipped on startup.- Returns:
trueif the registration of the default rout should be skipped,falseotherwise.- Since:
- 3.3.3-SNAPSHOT
-
shouldSkipVersionCheck
public boolean shouldSkipVersionCheck()Determines whether the version check should be skipped on startup.- Returns:
trueif the version check should be skipped,falseotherwise.
-
getCustomLogger
Retrieves the custom logger which should be used by CraftsNet.- Returns:
- The logger instance.
- Since:
- 3.0.5
-
isDebug
public boolean isDebug()Checks if debug mode is enabled.- Returns:
trueif debug mode is enabled,falseotherwise.
-
shouldHideIps
public boolean shouldHideIps()Checks if ips should be hidden in the log output.- Returns:
trueif ips should be hidden,falseotherwise.- Since:
- 3.4.0-SNAPSHOT
-
isSSL
public boolean isSSL()Checks if SSL is enabled.- Returns:
trueif SSL is enabled,falseotherwise.
-
getLogRotate
public long getLogRotate()Retrieves the log rotation size threshold.- Returns:
- the log rotation size threshold in bytes, or 0 if log rotation is disabled.
-
isLogRotate
public boolean isLogRotate()Checks if log rotation is disabled.- Returns:
trueif log rotation is disabled (i.e., the threshold is 0),falseotherwise.
-
build
Builds and starts the CraftsNet framework with the configured settings.- Returns:
- The constructed CraftsNet instance.
- Throws:
IOException- If an I/O error occurs during the startup process.
-