Skip to content

Commit 9b759f3

Browse files
committed
🐛 修复事件处理
1 parent d484244 commit 9b759f3

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

bukkit/src/main/kotlin/org/crashvibe/FGateBukkit/listeners/OnJoin.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package org.crashvibe.FGateBukkit.listeners
22

33
import org.bukkit.event.EventHandler
44
import org.bukkit.event.Listener
5-
import org.bukkit.event.player.PlayerLoginEvent
5+
import org.bukkit.event.player.PlayerJoinEvent
66
import org.crashvibe.FGateClient.listeners.OnJoinService
77

88
class OnJoin : Listener {
99
@EventHandler
10-
fun onQuit(event: PlayerLoginEvent) {
10+
fun onJoin(event: PlayerJoinEvent) {
1111
OnJoinService.handleJoin(event.player.name)
1212
}
1313
}

bukkit/src/main/kotlin/org/crashvibe/FGateBukkit/listeners/OnLogin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class OnLogin : Listener {
1515
@EventHandler(priority = EventPriority.HIGHEST)
1616
fun onAsyncPlayerPreLogin(event: AsyncPlayerPreLoginEvent) {
1717
val config = ConfigManager.configData.eventResolve.join
18-
val result = OnLoginService.handleJoin(event.name, event.uniqueId.toString(), event.address.hostAddress)
18+
val result = OnLoginService.handleLogin(event.name, event.uniqueId.toString(), event.address.hostAddress)
1919

2020
when (result.action) {
2121
OnLoginService.Action.kick -> {

common/src/main/kotlin/org/crashvibe/FGateClient/listeners/OnLoginService.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,40 @@ object OnLoginService {
1212
enum class Action { kick, allow }
1313

1414
@Serializable
15-
data class JoinInfo(val player: String, val uuid: String, val ip: String, val timestamp: Long)
15+
data class LoginInfo(val player: String, val uuid: String, val ip: String, val timestamp: Long)
1616

1717
@Serializable
18-
data class JoinResult(val action: Action, val reason: String? = null)
18+
data class LoginResult(val action: Action, val reason: String? = null)
1919

20-
fun handleJoin(player: String, uuid: String, ip: String): JoinResult {
20+
fun handleLogin(player: String, uuid: String, ip: String): LoginResult {
2121
val config = ConfigManager.configData.eventResolve.join
2222

2323
if (!WebSocketManager.instance.isOpen) {
2424
return if (config.allowJoin) {
25-
JoinResult(Action.allow)
25+
LoginResult(Action.allow)
2626
} else {
27-
JoinResult(Action.kick, config.kickMessage)
27+
LoginResult(Action.kick, config.kickMessage)
2828
}
2929
}
3030

31-
val request = JoinInfo(player, uuid, ip, System.currentTimeMillis())
31+
val request = LoginInfo(player, uuid, ip, System.currentTimeMillis())
3232

3333
return try {
34-
val response: JsonRpcResponse<JoinResult, JsonElement> = runBlocking {
34+
val response: JsonRpcResponse<LoginResult, JsonElement> = runBlocking {
3535
WebSocketManager.instance.sendRequest("player.login", request)
3636
}
3737

3838
if (response.error != null) {
3939
logger.severe("加入事件错误: ${response.error.message}")
40-
return if (config.errorJoin) JoinResult(Action.allow)
41-
else JoinResult(Action.kick, config.errorMessage)
40+
return if (config.errorJoin) LoginResult(Action.allow)
41+
else LoginResult(Action.kick, config.errorMessage)
4242
}
4343

44-
response.result ?: JoinResult(Action.kick, config.errorMessage)
44+
response.result ?: LoginResult(Action.kick, config.errorMessage)
4545
} catch (e: Exception) {
4646
logger.severe("加入事件异常: ${e.message}")
47-
if (config.errorJoin) JoinResult(Action.allow)
48-
else JoinResult(Action.kick, config.errorMessage)
47+
if (config.errorJoin) LoginResult(Action.allow)
48+
else LoginResult(Action.kick, config.errorMessage)
4949
}
5050
}
5151
}

0 commit comments

Comments
 (0)