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

View File

@ -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<org.bukkit.entity.Player> { sender, _, _ ->
transaction {
SchemaUtils.drop(InviteCodes)
SchemaUtils.create(InviteCodes)
sender.sendMessage("§a| §7成功清空数据库")
}
}
}
literal("rename") {
dynamic {
execute<org.bukkit.entity.Player> { sender, _, arg ->
transaction {
InviteCode.find { InviteCodes.uid eq sender.uniqueId }.first().run {
name = arg
}
}
}
}
}
}
}
}
//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<org.bukkit.entity.Player> { sender, _, _ ->
// transaction {
// SchemaUtils.drop(InviteCodes)
// SchemaUtils.create(InviteCodes)
// sender.sendMessage("§a| §7成功清空数据库")
// }
// }
// }
// literal("rename") {
// dynamic {
// execute<org.bukkit.entity.Player> { sender, _, arg ->
// transaction {
// InviteCode.find { InviteCodes.uid eq sender.uniqueId }.first().run {
// name = arg
// }
// }
// }
// }
// }
// }
// }
//}