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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.2.1

### Changes
```diff
+ Send players to original initialServer instead of keeping them in limbo when initialServers is empty
```


## 0.2.0

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {

allprojects {
group = "pl.spcode.navauth"
version = "0.2.0-SNAPSHOT"
version = "0.2.1-SNAPSHOT"
}

tasks.register("formatAll") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ open class GeneralConfig : OkaeriConfig() {
@Comment(
"The backend servers players should be sent to after successful authentication.",
"Players are LoadBalanced with 'least conn' by default.",
"If no servers are defined, then we won't do anything on the initial server event.",
"If no servers are defined, player will be sent to the initial server defined in velocity config.",
)
var initialServers: List<String> = listOf("paper")
protected set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package pl.spcode.navauth.velocity.infra.player

import com.velocitypowered.api.proxy.Player
import com.velocitypowered.api.proxy.server.RegisteredServer
import net.kyori.adventure.text.Component
import pl.spcode.navauth.common.component.TextColors
import pl.spcode.navauth.common.domain.common.IPAddress
Expand All @@ -28,6 +29,8 @@ import pl.spcode.navauth.common.domain.user.UserUuid

class VelocityPlayerAdapter(val velocityPlayer: Player) : PlayerAdapter {

var originalInitialServer: RegisteredServer? = null

override fun getIPAddress(): IPAddress {
return IPAddress.fromInetAddress(velocityPlayer.remoteAddress.address)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.velocitypowered.api.event.connection.DisconnectEvent
import com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent
import com.velocitypowered.api.event.player.ServerPreConnectEvent
import com.velocitypowered.api.proxy.Player
import kotlin.jvm.optionals.getOrNull
import net.kyori.adventure.text.Component
import org.slf4j.Logger
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -136,7 +137,7 @@ constructor(
}

if (authSession.isAuthenticated) {
setInitialServerAuthenticated(event)
setInitialServerAuthenticated(event, authSession)
} else {
setInitialLimboUnauthenticated(event, authSession)
}
Expand All @@ -147,9 +148,14 @@ constructor(
* If server found then sets it as the initial server, if there's no initial server defined, then
* nothing happens.
*/
private fun setInitialServerAuthenticated(event: PlayerChooseInitialServerEvent) {
private fun setInitialServerAuthenticated(
event: PlayerChooseInitialServerEvent,
authSession: AuthSession<VelocityPlayerAdapter>,
) {
val player = event.player
val initialServer = serverSelectionService.getInitialServer(player)
val initialServer =
serverSelectionService.getInitialServer(player)
?: authSession.playerAdapter.originalInitialServer
if (initialServer == null) {
logger.debug(
"PlayerChooseInitialServer: initial server not found for an authenticated user '${player.username}'"
Expand Down Expand Up @@ -198,6 +204,8 @@ constructor(
return
}

authSession.playerAdapter.originalInitialServer = event.initialServer.getOrNull()

event.setInitialServer(limbo)
logger.debug(
"set user '{}' initial server to limbo server named {}",
Expand Down