From 29bcc1e545f0271dfb77cf30d9aa6ce5e9dbfaa3 Mon Sep 17 00:00:00 2001 From: TONY_All Date: Fri, 4 Feb 2022 23:29:33 +0800 Subject: [PATCH] fix merge --- .../invite/command/InviteCodeCommands.kt | 4 ++-- .../maxmc/invite/listener/InvitedListener.kt | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/cc/maxmc/invite/command/InviteCodeCommands.kt b/src/main/kotlin/cc/maxmc/invite/command/InviteCodeCommands.kt index abe606a..1b560ca 100644 --- a/src/main/kotlin/cc/maxmc/invite/command/InviteCodeCommands.kt +++ b/src/main/kotlin/cc/maxmc/invite/command/InviteCodeCommands.kt @@ -37,7 +37,7 @@ object InviteCodeCommands { tailrec suspend fun requireQQNumber(player: Player): String? { val input = chatInput(player, "§e| §7请输入您的QQ号进行绑定 (输入 §ecancel §7取消)") if (input == "cancel") return null - if (input.length >= 10) return requireQQNumber(player) + if (input.length > 13) return requireQQNumber(player) if (input.toLongOrNull() == null) return requireQQNumber(player) return input } @@ -196,7 +196,7 @@ object InviteCodeCommands { output.createNewFile() output.writeText(result) } - sender.sendMessage("现存可用邀请码已保存至plugins/BiliInviteCode/current.txt") + sender.sendMessage("§a| §7现存可用邀请码已保存至plugins/BiliInviteCode/current.txt") } } } diff --git a/src/main/kotlin/cc/maxmc/invite/listener/InvitedListener.kt b/src/main/kotlin/cc/maxmc/invite/listener/InvitedListener.kt index 2baab5d..15e9889 100644 --- a/src/main/kotlin/cc/maxmc/invite/listener/InvitedListener.kt +++ b/src/main/kotlin/cc/maxmc/invite/listener/InvitedListener.kt @@ -1,12 +1,14 @@ package cc.maxmc.invite.listener import cc.maxmc.invite.PluginScope +import cc.maxmc.invite.concurrent.chatInput import cc.maxmc.invite.data.InviteCode import cc.maxmc.invite.data.InviteCodes import kotlinx.coroutines.launch import org.bukkit.Location +import org.bukkit.entity.Player import org.bukkit.event.player.* -import org.jetbrains.exposed.sql.transactions.transaction +import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction import taboolib.common.platform.event.SubscribeEvent import taboolib.common.platform.function.console import java.util.* @@ -48,13 +50,24 @@ object InvitedListener { @SubscribeEvent fun onJoin(e: PlayerJoinEvent) { + tailrec suspend fun requireQQNumber(player: Player): String? { + val input = chatInput(player, "§e| §7请输入您的QQ号进行绑定 (输入 §ecancel §7取消)") + if (input == "cancel") return null + if (input.length > 13) return requireQQNumber(player) + if (input.toLongOrNull() == null) return requireQQNumber(player) + return input + } + cache[e.player.uniqueId] = e.player.location e.player.sendMessage("§e| §7正在检查您的邀请码...请稍等.") PluginScope.launch { - transaction { + newSuspendedTransaction { val playerInviteCode = InviteCode.find { InviteCodes.uid eq e.player.uniqueId } .firstOrNull() - ?: return@transaction e.player.sendMessage("§c| §7您的账号未激活, 请输入 §c/ic use <激活码> §7来进行激活.") + ?: return@newSuspendedTransaction e.player.sendMessage("§c| §7您的账号未激活, 请输入 §c/ic use <激活码> §7来进行激活.") + if (playerInviteCode.qq == null) { + playerInviteCode.qq = requireQQNumber(e.player) + } e.player.sendMessage("§a| §7检查通过, 您可以正常进行游戏.") cache.remove(e.player.uniqueId) val lastName = playerInviteCode.name