Repository navigation
Conversation
Signed-off-by: 秋雨落 <i@rain.cx>
Signed-off-by: 秋雨落 <i@rain.cx>
Reviewer's GuideAPIDefine the unattached-player restriction and expose the waiting-area server through the vServer adapter/provider contract.
Uses of the APIEnforce the restriction on pre-connect attempts, allowing unattached players only into the waiting area and denying or redirecting other connections.
ImplementationProvide the configured backend auth server as the waiting-area server, and wire the connection gate into plugin startup while treating invalid auth-server configuration as an error.
TestsAdd coverage for connection authorization and waiting-area lookup, and update existing tests to initialize and reset shared static state consistently.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="velocity/src/main/kotlin/icu/h2l/login/HyperZoneLoginMain.kt" line_range="139" />
<code_context>
- // 访问配置不再抛 UninitializedPropertyAccessException,而是返回安全默认配置。
- private var coreConfig: CoreConfig = CoreConfig()
- private var startConfig: StartConfig = StartConfig()
+ private lateinit var coreConfig: CoreConfig
@JvmStatic
</code_context>
<issue_to_address>
**Configuration callers crash before loading**
When a plugin or API caller accesses core configuration before `loadCoreConfig()` completes or after startup exits early, `getCoreConfig()` reads the uninitialized `lateinit` property and throws `UninitializedPropertyAccessException`, so callers no longer receive the safe default configuration.
Keep `coreConfig` initialized with a safe default or otherwise ensure the getter returns a safe configuration before loading completes.
</issue_to_address>
### Comment 2
<location path="api/src/main/kotlin/icu/h2l/api/vServer/HyperZoneVServer.kt" line_range="82" />
<code_context>
+ * 如果等待区不经过 Velocity 后端连接,或者没有配置可用的等待区时,返回 `null`。
+ * 一个 Velocity 服务器最多只能配置一个等待区。
+ */
+ fun getRegisteredVServer(): RegisteredServer? = null
+
/**
</code_context>
<issue_to_address>
**Players are disconnected instead of routed**
When a third-party adapter uses the existing waiting-area methods but does not override the new getter, the default `getRegisteredVServer()` returns `null`, so the connection gate treats the adapter's waiting area as unavailable and disconnects the player instead of routing them into that waiting area.
Preserve existing waiting-area behavior for adapters that do not override the new getter instead of treating its default `null` as proof that no waiting area is available.
Also at `velocity/src/main/kotlin/icu/h2l/login/listener/UnAttachedPlayerListener.kt:56-78`.
</issue_to_address>
### Comment 3
<location path="velocity/src/test/kotlin/icu/h2l/login/listener/UnAttachedPlayerListenerTest.kt" line_range="256-257" />
<code_context>
+ event: ServerPreConnectEvent,
+ otherListeners: (ServerPreConnectEvent) -> Unit = {},
+ ) {
+ otherListeners(event)
+ gate.onServerPreConnect(event)
+ }
+
</code_context>
<issue_to_address>
**Later listener can re-allow access**
When the gate’s event priority is removed or changed so another listener runs after it, when the event bus runs another listener after the gate, that listener can re-allow the connection, but `dispatch` always runs `otherListeners` before `gate.onServerPreConnect`; the named test’s `assertFalse` therefore passes even if the gate’s priority is broken.
Dispatch the event through Velocity’s event manager in this test and verify that a listener registered at a later priority cannot re-allow the connection.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 3 findings to address first, and if this gate is wrong or can be bypassed, a player without an attached user could connect to a game backend and access resources before authorization; that access may have consequences a revert cannot undo. Reverting restores the previous connection behavior but cannot retract anything accessed while the gate was ineffective.
Blocking findings: velocity/src/main/kotlin/icu/h2l/login/HyperZoneLoginMain.kt:139, api/src/main/kotlin/icu/h2l/api/vServer/HyperZoneVServer.kt:82, velocity/src/test/kotlin/icu/h2l/login/listener/UnAttachedPlayerListenerTest.kt:257
This is a behaviour change, enforce the unauthorized players' restriction. They may join the waiting area only.
Summary by Sourcery
Enforce waiting-area-only access for players who have not yet attached to a HyperZone user.
New Features:
Bug Fixes:
Enhancements:
Tests: