From 75a3b73993d718fef32de0cc2d5d8f5a64829cc8 Mon Sep 17 00:00:00 2001 From: Project_IO Date: Fri, 27 Sep 2024 21:27:40 +0900 Subject: [PATCH] HOTFIX: message intent added --- gradle.properties | 2 +- .../main/kotlin/net/projecttl/p/x32/api/Plugin.kt | 10 ++++++++++ .../kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt | 13 +++++++++++-- px32-bot-core/src/main/resources/default.properties | 2 +- px32-bot-module/src/main/resources/plugin.json | 2 +- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 009879a..c3800df 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ kotlin.code.style=official org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 group=net.projecttl -version=0.2.0-SNAPSHOT +version=0.2.1-SNAPSHOT ktor_version=2.3.12 log4j_version=2.23.1 diff --git a/px32-bot-api/src/main/kotlin/net/projecttl/p/x32/api/Plugin.kt b/px32-bot-api/src/main/kotlin/net/projecttl/p/x32/api/Plugin.kt index 269b60d..d9b51c1 100644 --- a/px32-bot-api/src/main/kotlin/net/projecttl/p/x32/api/Plugin.kt +++ b/px32-bot-api/src/main/kotlin/net/projecttl/p/x32/api/Plugin.kt @@ -6,10 +6,20 @@ import net.projecttl.p.x32.api.model.PluginConfig import net.projecttl.p.x32.api.util.AsyncTaskContainer import org.slf4j.Logger import org.slf4j.LoggerFactory +import java.io.File abstract class Plugin { private val handlerContainer = mutableListOf() val taskContainer = AsyncTaskContainer() + val pluginDataDir: File + get() { + val f = File("plugins/${config.name}") + if (!f.exists()) { + f.mkdirs() + } + + return f + } val config = this.javaClass.getResourceAsStream("/plugin.json")!!.let { val raw = it.bufferedReader().readText() diff --git a/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt index 215d0db..b9a4be4 100644 --- a/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt +++ b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt @@ -6,10 +6,10 @@ import net.dv8tion.jda.api.JDA import net.dv8tion.jda.api.JDABuilder import net.dv8tion.jda.api.hooks.ListenerAdapter import net.dv8tion.jda.api.requests.GatewayIntent +import net.dv8tion.jda.api.utils.MemberCachePolicy 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.api.util.AsyncTaskContainer import net.projecttl.p.x32.config.Config import net.projecttl.p.x32.func.BundleModule import net.projecttl.p.x32.logger @@ -22,11 +22,12 @@ class CoreKernel(token: String) { private val builder = JDABuilder.createDefault(token, listOf( GatewayIntent.GUILD_PRESENCES, GatewayIntent.GUILD_MEMBERS, + GatewayIntent.GUILD_MESSAGES, GatewayIntent.MESSAGE_CONTENT, GatewayIntent.GUILD_VOICE_STATES, GatewayIntent.GUILD_EMOJIS_AND_STICKERS, GatewayIntent.SCHEDULED_EVENTS - )) + )).setMemberCachePolicy(MemberCachePolicy.ALL) private val handlers = mutableListOf() private val commandContainer = CommandHandler() @@ -159,6 +160,8 @@ class CoreKernel(token: String) { } fun destroy() { + val unloaded = mutableListOf() + plugins.forEach { (config, plugin) -> logger.info("disable ${config.name} plugin...") @@ -168,6 +171,12 @@ class CoreKernel(token: String) { logger.error("failed to destroy ${config.name} plugin") ex.printStackTrace() } + + unloaded += config + } + + unloaded.forEach { + plugins.remove(it) } } diff --git a/px32-bot-core/src/main/resources/default.properties b/px32-bot-core/src/main/resources/default.properties index defbd48..b63aefd 100644 --- a/px32-bot-core/src/main/resources/default.properties +++ b/px32-bot-core/src/main/resources/default.properties @@ -1 +1 @@ -version=${project.version} +version=${rootProject.version} diff --git a/px32-bot-module/src/main/resources/plugin.json b/px32-bot-module/src/main/resources/plugin.json index a513b5f..2685834 100644 --- a/px32-bot-module/src/main/resources/plugin.json +++ b/px32-bot-module/src/main/resources/plugin.json @@ -1,6 +1,6 @@ { "name": "bundle-module", - "version": "${project.version}", + "version": "${rootProject.version}", "main": "net.projecttl.p.x32.func.BundleModule" }