Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ class ServerConnectListener(
val config = plugin.connectionPlugin.connectionConfig.get()
val messages = plugin.connectionPlugin.messageConfig.get()

val virtualHost = event.player.pendingConnection.virtualHost?.hostName
if (virtualHost != null) {
val route = config.address.routes.find { it.subdomain == virtualHost }
if (route != null) {
val connection = ConnectionResolver.findConnection(route.targetConnection, config.connections)
if (connection != null) {
val serverNames = plugin.proxy.servers.keys.toList()
val matchingNames = ConnectionResolver.findMatchingServerNames(connection, serverNames)
val targetServer = matchingNames
.mapNotNull { plugin.proxy.servers[it] }
.minByOrNull { it.players.size }
if (targetServer != null) {
event.target = targetServer
return
}
}
}
}

if (!config.networkJoinTargets.enabled) return

val serverNames = plugin.proxy.servers.keys.toList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.spongepowered.configurate.objectmapping.ConfigSerializable
data class ConnectionConfig(
val version: Char = ConfigVersion.VERSION,
val registration: RegistrationConfig = RegistrationConfig(),
val address: AddressConfig = AddressConfig(),
val connections: List<ConnectionEntry> = DefaultConfigs.CONNECTIONS,
val networkJoinTargets: NetworkJoinTargetsConfig = DefaultConfigs.NETWORK_JOIN_TARGETS,
val fallback: FallbackConfig = DefaultConfigs.FALLBACK,
Expand All @@ -31,6 +32,17 @@ data class RegistrationServer(
val port: Long = 0L
)

@ConfigSerializable
data class AddressConfig(
val routes: List<SubdomainRoute> = listOf()
)

@ConfigSerializable
data class SubdomainRoute(
val subdomain: String = "",
val targetConnection: String = ""
)

@ConfigSerializable
data class ConnectionEntry(
val name: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ class PlayerChooseInitialServerListener(
val config = plugin.connectionPlugin.connectionConfig.get()
val messages = plugin.connectionPlugin.messageConfig.get()

val virtualHost = event.player.virtualHost.map { it.hostName }.orElse(null)
if (virtualHost != null) {
val route = config.address.routes.find { it.subdomain == virtualHost }
if (route != null) {
val connection = ConnectionResolver.findConnection(route.targetConnection, config.connections)
if (connection != null) {
val serverNames = proxy.allServers.map { it.serverInfo.name }
val matchingNames = ConnectionResolver.findMatchingServerNames(connection, serverNames)
val server = matchingNames
.mapNotNull { proxy.getServer(it).orElse(null) }
.minByOrNull { it.playersConnected.size }
if (server != null) {
event.setInitialServer(server)
return
}
}
}
}

if (!config.networkJoinTargets.enabled) return

val serverNames = proxy.allServers.map { it.serverInfo.name }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ class WaterdogJoinHandler(
override fun determineServer(player: ProxiedPlayer): ServerInfo? {
val config = plugin.connectionPlugin.connectionConfig.get()

val virtualHost = player.loginData.joinHostname
val route = config.address.routes.find { it.subdomain == virtualHost }
if (route != null) {
val connection = ConnectionResolver.findConnection(route.targetConnection, config.connections)
if (connection != null) {
val serverNames = plugin.proxy.servers.map { it.serverName }
val matchingNames = ConnectionResolver.findMatchingServerNames(connection, serverNames)
val serverInfo = matchingNames
.mapNotNull { name -> plugin.proxy.getServerInfo(name) }
.minByOrNull { it.players.size }
if (serverInfo != null) return serverInfo
}
}

if (!config.networkJoinTargets.enabled) return null

val serverNames = plugin.proxy.servers.map { it.serverName }
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
kotlin = "2.2.20"
kotlin-coroutines = "1.10.2"

shadow = "9.3.2"
minotaur = "2.8.10"
shadow = "9.4.1"
minotaur = "2.9.0"

simplecloud-api = "0.1.0-platform.20-dev.1771710355025-becd984"
simplecloud-api = "0.1.0-platform.22-dev.1774376168759-1e20f57"
simplecloud-plugin-api = "0.0.1-platform.1766000824440-e57ed95"

velocity = "3.5.0-SNAPSHOT"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down