Skip to content

Commit

Permalink
feat: separate settings of incremental items
Browse files Browse the repository at this point in the history
Closes #8

Signed-off-by: Samarium <[email protected]>
  • Loading branch information
Samarium150 committed Jan 7, 2022
1 parent 5e1dad8 commit aadebd6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group = "io.github.samarium150"
version = "1.3.1"
version = "1.4.0"

repositories {
mavenLocal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("简单的漂流瓶插件")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)

This comment has been minimized.

Copy link
@LaoLittle

LaoLittle Jan 7, 2022

Contributor

草?改名字会导致无法读取旧配置吧..

This comment has been minimized.

Copy link
@Samarium150

Samarium150 Jan 7, 2022

Author Owner

我记得不会啊,你测试一下?

This comment has been minimized.

Copy link
@LaoLittle

LaoLittle Jan 7, 2022

Contributor

貌似最近改了?以前中间插入配置或者改名就会报错,现在是重置为默认值


@ValueDescription("捡起命令不减少尸体总数")
val incrementalBody by value(false)

@ValueDescription("是否启用内容审核")
val enableContentCensor by value(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aadebd6

Please sign in to comment.