This commit is contained in:
TONY_All 2022-02-04 23:15:27 +08:00
parent 42b584a123
commit 822b0a8208
2 changed files with 54 additions and 48 deletions

View File

@ -168,12 +168,16 @@ object InviteCodeCommands {
private fun CommandBuilder.CommandComponent.cmdRemove() = literal("remove") { private fun CommandBuilder.CommandComponent.cmdRemove() = literal("remove") {
execute<ConsoleCommandSender> { sender, _, arg -> execute<ConsoleCommandSender> { sender, _, arg ->
val findings = InviteCode.find { InviteCodes.inviteCode eq arg } PluginScope.launch {
if (findings.empty()) { transaction {
sender.sendMessage("§e| §7该邀请码不存在, 无需删除.") 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<ConsoleCommandSender> { sender, _, _ -> execute<ConsoleCommandSender> { sender, _, _ ->
PluginScope.launch { PluginScope.launch {
val codes = ArrayList<String>(2000) val codes = ArrayList<String>(2000)
InviteCode.find { InviteCodes.uid eq null }.forEach { transaction {
codes.add(it.inviteCode) InviteCode.find { InviteCodes.uid eq null }.forEach {
codes.add(it.inviteCode)
}
} }
val result = codes.joinToString("\n") val result = codes.joinToString("\n")
val output = File(getDataFolder(), "current.txt") val output = File(getDataFolder(), "current.txt")

View File

@ -1,41 +1,41 @@
package cc.maxmc.invite.command //package cc.maxmc.invite.command
//
import cc.maxmc.invite.data.InviteCode //import cc.maxmc.invite.data.InviteCode
import cc.maxmc.invite.data.InviteCodes //import cc.maxmc.invite.data.InviteCodes
import org.jetbrains.exposed.sql.SchemaUtils //import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.transactions.transaction //import org.jetbrains.exposed.sql.transactions.transaction
//
object DebugCommands { //object DebugCommands {
fun debug() { // 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|")
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| 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|")
taboolib.common.platform.function.console().sendMessage("§c|") // taboolib.common.platform.function.console().sendMessage("§c|")
//
taboolib.common.platform.command.command("idebug") { // taboolib.common.platform.command.command("idebug") {
literal("clean") { // literal("clean") {
execute<org.bukkit.entity.Player> { sender, _, _ -> // execute<org.bukkit.entity.Player> { sender, _, _ ->
transaction { // transaction {
SchemaUtils.drop(InviteCodes) // SchemaUtils.drop(InviteCodes)
SchemaUtils.create(InviteCodes) // SchemaUtils.create(InviteCodes)
sender.sendMessage("§a| §7成功清空数据库") // sender.sendMessage("§a| §7成功清空数据库")
} // }
} // }
} // }
literal("rename") { // literal("rename") {
dynamic { // dynamic {
execute<org.bukkit.entity.Player> { sender, _, arg -> // execute<org.bukkit.entity.Player> { sender, _, arg ->
transaction { // transaction {
InviteCode.find { InviteCodes.uid eq sender.uniqueId }.first().run { // InviteCode.find { InviteCodes.uid eq sender.uniqueId }.first().run {
name = arg // name = arg
} // }
} // }
} // }
} // }
} // }
} // }
} // }
} //}