From aadebd66cf92d1da715bd9e24d4af3a1102c23ee Mon Sep 17 00:00:00 2001 From: Samarium <28302241+Samarium150@users.noreply.github.com> Date: Fri, 7 Jan 2022 20:45:39 +0800 Subject: [PATCH] feat: separate settings of incremental items Closes #8 Signed-off-by: Samarium <28302241+Samarium150@users.noreply.github.com> --- build.gradle.kts | 2 +- .../mirai/plugin/driftbottle/MiraiConsoleDriftBottle.kt | 2 +- .../samarium150/mirai/plugin/driftbottle/command/Pickup.kt | 7 ++++++- .../mirai/plugin/driftbottle/config/GeneralConfig.kt | 7 +++++-- .../samarium150/mirai/plugin/driftbottle/data/Item.kt | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 458eeb0..be288dd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ plugins { } group = "io.github.samarium150" -version = "1.3.1" +version = "1.4.0" repositories { mavenLocal() diff --git a/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/MiraiConsoleDriftBottle.kt b/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/MiraiConsoleDriftBottle.kt index d30a526..8fa2ce5 100644 --- a/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/MiraiConsoleDriftBottle.kt +++ b/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/MiraiConsoleDriftBottle.kt @@ -37,7 +37,7 @@ object MiraiConsoleDriftBottle : KotlinPlugin( JvmPluginDescription( id = "io.github.samarium150.mirai.plugin.mirai-console-drift-bottle", name = "Drift Bottle", - version = "1.3.1", + version = "1.4.0", ) { author("Samarium150") info("简单的漂流瓶插件") diff --git a/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/command/Pickup.kt b/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/command/Pickup.kt index 1c42de1..b372efa 100644 --- a/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/command/Pickup.kt +++ b/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/command/Pickup.kt @@ -20,6 +20,7 @@ import io.github.samarium150.mirai.plugin.driftbottle.MiraiConsoleDriftBottle import io.github.samarium150.mirai.plugin.driftbottle.config.CommandConfig import io.github.samarium150.mirai.plugin.driftbottle.config.GeneralConfig import io.github.samarium150.mirai.plugin.driftbottle.config.ReplyConfig +import io.github.samarium150.mirai.plugin.driftbottle.data.Item import io.github.samarium150.mirai.plugin.driftbottle.data.Sea import net.mamoe.mirai.console.command.CommandSenderOnMessage import net.mamoe.mirai.console.command.SimpleCommand @@ -45,7 +46,11 @@ object Pickup : SimpleCommand( return } val index = Random().nextInt(Sea.contents.size) - val item = if (GeneralConfig.incremental) Sea.contents[index] else Sea.contents.removeAt(index) + val item = Sea.contents[index] + if ((item.type == Item.Type.BOTTLE && !GeneralConfig.incrementalBottle) + || (item.type == Item.Type.BODY && !GeneralConfig.incrementalBody) + ) + Sea.contents.removeAt(index) sendMessage(item.toMessageChain(fromEvent.subject)) } } diff --git a/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/config/GeneralConfig.kt b/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/config/GeneralConfig.kt index 7839c55..2f233d9 100644 --- a/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/config/GeneralConfig.kt +++ b/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/config/GeneralConfig.kt @@ -22,8 +22,11 @@ import net.mamoe.mirai.console.data.value object GeneralConfig : AutoSavePluginConfig("General") { - @ValueDescription("捡起漂流瓶不减少物品总数") - val incremental by value(true) + @ValueDescription("捡起命令不减少漂流瓶总数") + val incrementalBottle by value(true) + + @ValueDescription("捡起命令不减少尸体总数") + val incrementalBody by value(false) @ValueDescription("是否启用内容审核") val enableContentCensor by value(false) diff --git a/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/data/Item.kt b/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/data/Item.kt index 4957975..26ec4c6 100644 --- a/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/data/Item.kt +++ b/src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/data/Item.kt @@ -44,7 +44,7 @@ class Item { BODY } - private val type: Type + val type: Type private val owner: Owner private val source: Source? private var content: String? = null