Skip to content

Commit

Permalink
fix: optimized import
Browse files Browse the repository at this point in the history
  • Loading branch information
devproje committed Sep 21, 2024
1 parent be4e62a commit e9a57c9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package net.projecttl.p.x32.api

import kotlinx.serialization.json.Json
import net.dv8tion.jda.api.hooks.ListenerAdapter
import net.projecttl.p.x32.api.command.CommandHandler
import net.projecttl.p.x32.api.model.PluginConfig
import org.slf4j.Logger
import org.slf4j.LoggerFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ object Reload : GlobalCommand {
override val data = CommandData.fromData(CommandDataImpl("reload", "플러그인을 다시 불러 옵니다").toData())

override suspend fun execute(ev: SlashCommandInteractionEvent) {
if (kernel.memLock) {
return
}

if (ev.user.id != Config.owner) {
return ev.reply(":warning: 권한을 가지고 있지 않아요").queue()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package net.projecttl.p.x32.kernel

import kotlinx.serialization.json.Json
import net.dv8tion.jda.api.JDA
import net.dv8tion.jda.api.JDABuilder
import net.dv8tion.jda.api.hooks.ListenerAdapter
import net.projecttl.p.x32.api.Plugin
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.func.General
import net.projecttl.p.x32.jda

class CoreKernel(token: String) {
var memLock = false
private set
private val builder = JDABuilder.createDefault(token)
private val handlers = mutableListOf<ListenerAdapter>()
private val commandContainer = CommandHandler()
Expand Down Expand Up @@ -70,6 +70,10 @@ class CoreKernel(token: String) {
}

fun reload() {
if (!memLock) {
memLock = true
}

val newHandlers = mutableListOf<ListenerAdapter>()
PluginLoader.destroy()
plugins().forEach { plugin ->
Expand Down Expand Up @@ -102,5 +106,7 @@ class CoreKernel(token: String) {
h.register(jda)
}
}

memLock = false
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.projecttl.p.x32.kernel

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.model.PluginConfig
import net.projecttl.p.x32.logger
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
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.command.CommandHandler
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.MsgPurge
import net.projecttl.p.x32.func.command.Ping
import net.projecttl.p.x32.func.handler.Ready

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.projecttl.p.x32.func.command

import Conf
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
import net.dv8tion.jda.api.interactions.commands.OptionType
import net.dv8tion.jda.api.interactions.commands.build.CommandData
Expand Down

0 comments on commit e9a57c9

Please sign in to comment.