From 822b0a8208ce8dfb1183d84669436edade2e63fa Mon Sep 17 00:00:00 2001 From: TONY_All Date: Fri, 4 Feb 2022 23:15:27 +0800 Subject: [PATCH] bug fix --- .../invite/command/InviteCodeCommands.kt | 20 +++-- .../cc/maxmc/invite/command/DebugCommands.kt | 82 +++++++++---------- 2 files changed, 54 insertions(+), 48 deletions(-) diff --git a/src/main/kotlin/cc/maxmc/invite/command/InviteCodeCommands.kt b/src/main/kotlin/cc/maxmc/invite/command/InviteCodeCommands.kt index 7bf601f..4868690 100644 --- a/src/main/kotlin/cc/maxmc/invite/command/InviteCodeCommands.kt +++ b/src/main/kotlin/cc/maxmc/invite/command/InviteCodeCommands.kt @@ -168,12 +168,16 @@ object InviteCodeCommands { private fun CommandBuilder.CommandComponent.cmdRemove() = literal("remove") { execute { sender, _, arg -> - val findings = InviteCode.find { InviteCodes.inviteCode eq arg } - if (findings.empty()) { - sender.sendMessage("§e| §7该邀请码不存在, 无需删除.") + PluginScope.launch { + transaction { + val findings = InviteCode.find { InviteCodes.inviteCode eq arg } + if (findings.empty()) { + sender.sendMessage("§e| §7该邀请码不存在, 无需删除.") + } + findings.first().delete() + sender.sendMessage("§a| §7成功删除该邀请码.") + } } - findings.first().delete() - sender.sendMessage("§a| §7成功删除该邀请码.") } } @@ -181,8 +185,10 @@ object InviteCodeCommands { execute { sender, _, _ -> PluginScope.launch { val codes = ArrayList(2000) - InviteCode.find { InviteCodes.uid eq null }.forEach { - codes.add(it.inviteCode) + transaction { + InviteCode.find { InviteCodes.uid eq null }.forEach { + codes.add(it.inviteCode) + } } val result = codes.joinToString("\n") val output = File(getDataFolder(), "current.txt") diff --git a/src/test/kotlin/cc/maxmc/invite/command/DebugCommands.kt b/src/test/kotlin/cc/maxmc/invite/command/DebugCommands.kt index 9dbfecc..80d1ff9 100644 --- a/src/test/kotlin/cc/maxmc/invite/command/DebugCommands.kt +++ b/src/test/kotlin/cc/maxmc/invite/command/DebugCommands.kt @@ -1,41 +1,41 @@ -package cc.maxmc.invite.command - -import cc.maxmc.invite.data.InviteCode -import cc.maxmc.invite.data.InviteCodes -import org.jetbrains.exposed.sql.SchemaUtils -import org.jetbrains.exposed.sql.transactions.transaction - -object DebugCommands { - fun debug() { - taboolib.common.platform.function.console().sendMessage("§c|") - taboolib.common.platform.function.console().sendMessage("§c|") - taboolib.common.platform.function.console().sendMessage("§c|") - taboolib.common.platform.function.console().sendMessage("§c| DEBUG 模式已开启!") - taboolib.common.platform.function.console().sendMessage("§c|") - taboolib.common.platform.function.console().sendMessage("§c|") - taboolib.common.platform.function.console().sendMessage("§c|") - - taboolib.common.platform.command.command("idebug") { - literal("clean") { - execute { sender, _, _ -> - transaction { - SchemaUtils.drop(InviteCodes) - SchemaUtils.create(InviteCodes) - sender.sendMessage("§a| §7成功清空数据库") - } - } - } - literal("rename") { - dynamic { - execute { sender, _, arg -> - transaction { - InviteCode.find { InviteCodes.uid eq sender.uniqueId }.first().run { - name = arg - } - } - } - } - } - } - } -} \ No newline at end of file +//package cc.maxmc.invite.command +// +//import cc.maxmc.invite.data.InviteCode +//import cc.maxmc.invite.data.InviteCodes +//import org.jetbrains.exposed.sql.SchemaUtils +//import org.jetbrains.exposed.sql.transactions.transaction +// +//object DebugCommands { +// fun debug() { +// taboolib.common.platform.function.console().sendMessage("§c|") +// taboolib.common.platform.function.console().sendMessage("§c|") +// taboolib.common.platform.function.console().sendMessage("§c|") +// taboolib.common.platform.function.console().sendMessage("§c| DEBUG 模式已开启!") +// taboolib.common.platform.function.console().sendMessage("§c|") +// taboolib.common.platform.function.console().sendMessage("§c|") +// taboolib.common.platform.function.console().sendMessage("§c|") +// +// taboolib.common.platform.command.command("idebug") { +// literal("clean") { +// execute { sender, _, _ -> +// transaction { +// SchemaUtils.drop(InviteCodes) +// SchemaUtils.create(InviteCodes) +// sender.sendMessage("§a| §7成功清空数据库") +// } +// } +// } +// literal("rename") { +// dynamic { +// execute { sender, _, arg -> +// transaction { +// InviteCode.find { InviteCodes.uid eq sender.uniqueId }.first().run { +// name = arg +// } +// } +// } +// } +// } +// } +// } +//} \ No newline at end of file