Skip to content

Commit f705323

Browse files
Add BLUEDRAGON_PUFFIN_PORT and BLUEDRAGON_GRPC_SERVER_PORT environment variables
1 parent ead3ba7 commit f705323

File tree

6 files changed

+42
-13
lines changed

6 files changed

+42
-13
lines changed

README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,79 @@
11
# Server
2-
![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/BlueDragonMC/Server/gradle.yml?branch=main&label=Java%20CI%20with%20Gradle&logo=github)
2+
3+
![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/BlueDragonMC/Server/docker-publish.yml?branch=main&label=Docker%20Build&logo=github)
34
![GitHub last commit](https://img.shields.io/github/last-commit/BlueDragonMC/Server)
45
![Jitpack CI Status](https://img.shields.io/badge/dynamic/json?color=blue&label=jitpack&query=%24.status&url=https%3A%2F%2Fjitpack.io%2Fapi%2Fbuilds%2Fcom.github.BlueDragonMC%2FServer%2Flatest&logo=gradle)
56

67
[![BlueDragon Logo](./favicon_64.png)](https://bluedragonmc.com)
78

89
BlueDragon's [Minestom](https://minestom.net/) implementation. It currently includes:
10+
911
- Creating isolated instances for different game types and modes
1012
- A modular system for adding functionality to games
11-
- This allows for a very high degree of code reusability and simplicity, and makes rapid prototyping of games very quick and easy.
13+
- This allows for a very high degree of code reusability and simplicity, and makes rapid prototyping of games very
14+
quick and easy.
1215
- System for handling player punishments
1316
- Database support linked to every `Player` using a player provider
1417
- Synchronization with other servers using gRPC messaging and a Mongo database
1518
- Routing players to the correct instance when they join
1619
- Separated, per-instance chat and tablist functionality
1720
- Basic commands
1821

19-
Minestom is a Minecraft server library targeted at developers. Their wiki is available [here](https://wiki.minestom.net).
22+
Minestom is a Minecraft server library targeted at developers. Their wiki is
23+
available [here](https://wiki.minestom.net).
2024

2125
## Usage
26+
2227
Build with `./gradlew build` and run the JAR created at `build/libs/Server-x.x.x-all.jar`.
2328
Requires Java 17 or higher.
2429

2530
## Development
31+
2632
This can be built as a docker container with the following command:
33+
2734
```shell
2835
$ DOCKER_BUILDKIT=1 docker build -t bluedragonmc/server:testing .
2936
```
37+
3038
This uses the `Dockerfile` in the current directory to build an image with the version string `"testing"`.
3139
*Note: A game named `Lobby` must be present for the server to run!*
3240

3341
Environment variables:
34-
* `PUFFIN_VELOCITY_SECRET` - Your Velocity proxy forwarding secret (optional). If not specified, Mojang authentication will be enabled.
42+
43+
* `PUFFIN_VELOCITY_SECRET` - Your Velocity proxy forwarding secret (optional). If not specified, Mojang authentication
44+
will be enabled.
3545
* `BLUEDRAGON_AGONES_HEALTHCHECK_INTERVAL_MS` - The amount of time in between Agones healthcheck pings, in milliseconds.
3646
* `BLUEDRAGON_AGONES_RESERVATION_TIME_MS` - The amount of time in between Agones server reservations, in milliseconds.
3747
* `BLUEDRAGON_AGONES_DISABLED` - Disables Agones integration if set to any value.
3848
* `BLUEDRAGON_ENV_TYPE` - Set to "DEV" to enable development mode.
39-
* `BLUEDRAGON_QUEUE_TYPE` - Set to "IPC" to use Puffin or "TEST" for the `TestQueue`. If not present, a default value is inferred.
49+
* `BLUEDRAGON_QUEUE_TYPE` - Set to "IPC" to use Puffin or "TEST" for the `TestQueue`. If not present, a default value is
50+
inferred.
4051
* `BLUEDRAGON_MONGO_CONNECTION_STRING` - The connection string used to connect to MongoDB.
4152
* `BLUEDRAGON_PUFFIN_HOSTNAME` - The hostname used to connect to Puffin.
4253
* `BLUEDRAGON_LUCKPERMS_HOSTNAME` - The hostname used to connect to LuckPerms.
4354
* `HOSTNAME` - Used to determine the server name. Provided by default in Docker or Kubernetes environments.
4455
* `SERVER_INSTANCE_MIN_INACTIVE_TIME` - The amount of time that an instance must be inactive before it is cleaned up.
4556
* `SERVER_INSTANCE_CLEANUP_PERIOD` - The amount of time in between instance cleanup tasks.
57+
* `BLUEDRAGON_PUFFIN_PORT` - The port used to connect to Puffin. Defaults to `50051`.
58+
* `BLUEDRAGON_GRPC_SERVER_PORT` - The port used to create a gRPC server. Defaults to `50051`.
59+
60+
> [!TIP]
61+
> If you are running Puffin, Komodo, or multiple game server instances on the same machine without some kind of
62+
> networking isolation, you must change the `BLUEDRAGON_GRPC_SERVER_PORT` environment variable for each server to
63+
> prevent port conflicts.
4664
4765
## Implementation
66+
4867
To learn how to integrate other server software with BlueDragon's systems, see the [Integration Guide](./INTEGRATION.md)
4968

5069
## Creating a Game
51-
To learn how to create a game using this library, see our [ExampleGame](https://github.com/BlueDragonMC/ExampleGame/blob/main/README.md) repository. It has guides and documentation for creating a simple game.
70+
71+
To learn how to create a game using this library, see
72+
our [ExampleGame](https://github.com/BlueDragonMC/ExampleGame/blob/main/README.md) repository. It has guides and
73+
documentation for creating a simple game.
5274

5375
## Project Structure
76+
5477
The project contains a `common` subproject, which is used by all games as an API to compile against.
5578
This subproject also contains many useful game modules that most games use.
5679

common/src/main/kotlin/com/bluedragonmc/server/api/Environment.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ abstract class Environment {
1212
val mongoConnectionString get() = current.mongoConnectionString
1313
val dbName get() = current.dbName
1414
val puffinHostname get() = current.puffinHostname
15+
val puffinPort get() = current.puffinPort
16+
val grpcServerPort get() = current.grpcServerPort
1517
val defaultGameName get() = current.defaultGameName
1618
val gameClasses get() = current.gameClasses
1719
val versionInfo get() = current.versionInfo
@@ -28,6 +30,8 @@ abstract class Environment {
2830
abstract val queue: Queue
2931
abstract val mongoConnectionString: String
3032
abstract val puffinHostname: String
33+
abstract val puffinPort: Int
34+
abstract val grpcServerPort: Int
3135
abstract val luckPermsHostname: String
3236
abstract val gameClasses: Collection<String>
3337
abstract val versionInfo: VersionInfo

src/main/kotlin/com/bluedragonmc/server/bootstrap/IntegrationsInit.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ object IntegrationsInit : Bootstrap() {
2626
Messaging.initializeOutgoing(OutgoingRPCHandlerStub())
2727
} else {
2828
logger.info("Attempting to connect to messaging at address ${InetAddress.getByName(Environment.puffinHostname).hostAddress}")
29-
Messaging.initializeIncoming(IncomingRPCHandlerImpl())
30-
Messaging.initializeOutgoing(OutgoingRPCHandlerImpl(Environment.puffinHostname))
29+
Messaging.initializeIncoming(IncomingRPCHandlerImpl(Environment.grpcServerPort))
30+
Messaging.initializeOutgoing(OutgoingRPCHandlerImpl(Environment.puffinHostname, Environment.puffinPort))
3131
runBlocking {
3232
Messaging.outgoing.initGameServer(Environment.getServerName())
3333
}

src/main/kotlin/com/bluedragonmc/server/impl/IncomingRPCHandlerImpl.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import org.slf4j.LoggerFactory
1212
import java.util.*
1313
import java.util.concurrent.TimeUnit
1414

15-
class IncomingRPCHandlerImpl : IncomingRPCHandler {
15+
class IncomingRPCHandlerImpl(serverPort: Int) : IncomingRPCHandler {
1616

17-
private val server = ServerBuilder.forPort(50051)
17+
private val server = ServerBuilder.forPort(serverPort)
1818
.addService(GameClientService())
1919
.addService(PlayerHolderService())
2020
.build()
@@ -23,7 +23,7 @@ class IncomingRPCHandlerImpl : IncomingRPCHandler {
2323

2424
init {
2525
server.start()
26-
logger.info("gRPC server started on port 50051")
26+
logger.info("gRPC server started on port $serverPort")
2727
}
2828

2929
override fun isConnected() = !server.isShutdown && !server.isTerminated

src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ import net.minestom.server.instance.Instance
2828
import java.util.*
2929
import java.util.concurrent.TimeUnit
3030

31-
class OutgoingRPCHandlerImpl(serverAddress: String) : OutgoingRPCHandler {
31+
class OutgoingRPCHandlerImpl(serverAddress: String, serverPort: Int) : OutgoingRPCHandler {
3232

3333
private lateinit var serverName: String
3434

3535
private val channel =
36-
ManagedChannelBuilder.forAddress(serverAddress, 50051)
36+
ManagedChannelBuilder.forAddress(serverAddress, serverPort)
3737
.defaultLoadBalancingPolicy("round_robin")
3838
.usePlaintext()
3939
.enableRetry()

src/main/kotlin/com/bluedragonmc/server/queue/environments.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class ConfiguredEnvironment : Environment() {
3030

3131
override val mongoConnectionString: String = System.getenv("BLUEDRAGON_MONGO_CONNECTION_STRING") ?: defaultMongoConnectionString()
3232
override val puffinHostname: String = System.getenv("BLUEDRAGON_PUFFIN_HOSTNAME") ?: defaultPuffinHostname()
33+
override val puffinPort: Int = System.getenv("BLUEDRAGON_PUFFIN_PORT")?.toIntOrNull() ?: 50051
34+
override val grpcServerPort: Int = System.getenv("BLUEDRAGON_GRPC_SERVER_PORT")?.toIntOrNull() ?: 50051
3335
override val luckPermsHostname: String = System.getenv("BLUEDRAGON_LUCKPERMS_HOSTNAME") ?: defaultLuckPermsHostname()
3436

3537
override val gameClasses: Collection<String> = GameLoader.gameNames

0 commit comments

Comments
 (0)