fix: optimized import

This commit is contained in:
Project_IO 2024-09-22 02:07:04 +09:00
parent be4e62ab7e
commit e9a57c9f6a
6 changed files with 14 additions and 6 deletions

View file

@ -2,7 +2,6 @@ package net.projecttl.p.x32.api
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import net.dv8tion.jda.api.hooks.ListenerAdapter import net.dv8tion.jda.api.hooks.ListenerAdapter
import net.projecttl.p.x32.api.command.CommandHandler
import net.projecttl.p.x32.api.model.PluginConfig import net.projecttl.p.x32.api.model.PluginConfig
import org.slf4j.Logger import org.slf4j.Logger
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory

View file

@ -11,6 +11,10 @@ object Reload : GlobalCommand {
override val data = CommandData.fromData(CommandDataImpl("reload", "플러그인을 다시 불러 옵니다").toData()) override val data = CommandData.fromData(CommandDataImpl("reload", "플러그인을 다시 불러 옵니다").toData())
override suspend fun execute(ev: SlashCommandInteractionEvent) { override suspend fun execute(ev: SlashCommandInteractionEvent) {
if (kernel.memLock) {
return
}
if (ev.user.id != Config.owner) { if (ev.user.id != Config.owner) {
return ev.reply(":warning: 권한을 가지고 있지 않아요").queue() return ev.reply(":warning: 권한을 가지고 있지 않아요").queue()
} }

View file

@ -1,17 +1,17 @@
package net.projecttl.p.x32.kernel package net.projecttl.p.x32.kernel
import kotlinx.serialization.json.Json
import net.dv8tion.jda.api.JDA import net.dv8tion.jda.api.JDA
import net.dv8tion.jda.api.JDABuilder import net.dv8tion.jda.api.JDABuilder
import net.dv8tion.jda.api.hooks.ListenerAdapter import net.dv8tion.jda.api.hooks.ListenerAdapter
import net.projecttl.p.x32.api.Plugin import net.projecttl.p.x32.api.Plugin
import net.projecttl.p.x32.api.command.CommandHandler import net.projecttl.p.x32.api.command.CommandHandler
import net.projecttl.p.x32.api.model.PluginConfig
import net.projecttl.p.x32.config.Config import net.projecttl.p.x32.config.Config
import net.projecttl.p.x32.func.General import net.projecttl.p.x32.func.General
import net.projecttl.p.x32.jda import net.projecttl.p.x32.jda
class CoreKernel(token: String) { class CoreKernel(token: String) {
var memLock = false
private set
private val builder = JDABuilder.createDefault(token) private val builder = JDABuilder.createDefault(token)
private val handlers = mutableListOf<ListenerAdapter>() private val handlers = mutableListOf<ListenerAdapter>()
private val commandContainer = CommandHandler() private val commandContainer = CommandHandler()
@ -70,6 +70,10 @@ class CoreKernel(token: String) {
} }
fun reload() { fun reload() {
if (!memLock) {
memLock = true
}
val newHandlers = mutableListOf<ListenerAdapter>() val newHandlers = mutableListOf<ListenerAdapter>()
PluginLoader.destroy() PluginLoader.destroy()
plugins().forEach { plugin -> plugins().forEach { plugin ->
@ -102,5 +106,7 @@ class CoreKernel(token: String) {
h.register(jda) h.register(jda)
} }
} }
memLock = false
} }
} }

View file

@ -1,7 +1,6 @@
package net.projecttl.p.x32.kernel package net.projecttl.p.x32.kernel
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import net.dv8tion.jda.api.hooks.ListenerAdapter
import net.projecttl.p.x32.api.Plugin import net.projecttl.p.x32.api.Plugin
import net.projecttl.p.x32.api.model.PluginConfig import net.projecttl.p.x32.api.model.PluginConfig
import net.projecttl.p.x32.logger import net.projecttl.p.x32.logger

View file

@ -1,11 +1,10 @@
package net.projecttl.p.x32.func package net.projecttl.p.x32.func
import net.dv8tion.jda.api.JDABuilder
import net.projecttl.p.x32.api.Plugin import net.projecttl.p.x32.api.Plugin
import net.projecttl.p.x32.api.command.CommandHandler import net.projecttl.p.x32.api.command.CommandHandler
import net.projecttl.p.x32.func.command.Avatar import net.projecttl.p.x32.func.command.Avatar
import net.projecttl.p.x32.func.command.MsgPurge
import net.projecttl.p.x32.func.command.MsgLength import net.projecttl.p.x32.func.command.MsgLength
import net.projecttl.p.x32.func.command.MsgPurge
import net.projecttl.p.x32.func.command.Ping import net.projecttl.p.x32.func.command.Ping
import net.projecttl.p.x32.func.handler.Ready import net.projecttl.p.x32.func.handler.Ready

View file

@ -1,5 +1,6 @@
package net.projecttl.p.x32.func.command package net.projecttl.p.x32.func.command
import Conf
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
import net.dv8tion.jda.api.interactions.commands.OptionType import net.dv8tion.jda.api.interactions.commands.OptionType
import net.dv8tion.jda.api.interactions.commands.build.CommandData import net.dv8tion.jda.api.interactions.commands.build.CommandData