Skip to content

Commit

Permalink
feat: add status subcommand
Browse files Browse the repository at this point in the history
Signed-off-by: Samarium <[email protected]>
  • Loading branch information
Samarium150 committed Mar 30, 2022
1 parent ceff454 commit 8ff768e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 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.7.0"
version = "1.8.0"

repositories {
mavenLocal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object MiraiConsoleDriftBottle : KotlinPlugin(
JvmPluginDescription(
id = "io.github.samarium150.mirai.plugin.mirai-console-drift-bottle",
name = "Drift Bottle",
version = "1.7.0",
version = "1.8.0",
) {
author("Samarium150")
info("简单的漂流瓶插件")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object Comment : SimpleCommand(
override val prefixOptional: Boolean = true

override val usage: String
get() = "评论 内容 漂流瓶序号"
get() = super.usage + " <内容> [漂流瓶序号]"

@Suppress("unused")
@Handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,29 @@ package io.github.samarium150.mirai.plugin.driftbottle.command

import io.github.samarium150.mirai.plugin.driftbottle.MiraiConsoleDriftBottle
import io.github.samarium150.mirai.plugin.driftbottle.config.CommandConfig
import io.github.samarium150.mirai.plugin.driftbottle.data.Item
import io.github.samarium150.mirai.plugin.driftbottle.data.Sea
import io.github.samarium150.mirai.plugin.driftbottle.util.*
import net.mamoe.mirai.console.command.CommandSender
import net.mamoe.mirai.console.command.CompositeCommand
import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
import net.mamoe.mirai.console.util.ConsoleExperimentalApi

/**
* @author LaoLittle
*/
@Suppress("unused")
object SeaOperation : CompositeCommand(
MiraiConsoleDriftBottle,
primaryName = "sea",
secondaryNames = CommandConfig.seaOperation,
description = "漂流瓶操作复合指令"
) {
@Suppress("unused")

@ExperimentalCommandDescriptors
@ConsoleExperimentalApi
override val prefixOptional: Boolean = true

@SubCommand("del", "rm")
suspend fun CommandSender.remove(
index: Int? = subject?.let { sub ->
Expand All @@ -52,7 +60,6 @@ object SeaOperation : CompositeCommand(
}
}

@Suppress("unused")
@SubCommand("query", "get")
suspend fun CommandSender.query(
index: Int? = subject?.let { sub ->
Expand All @@ -75,4 +82,15 @@ object SeaOperation : CompositeCommand(
sendMessage(result.getOrNull() ?: "无法找到漂流瓶$index")
}
}

@SubCommand("status")
suspend fun CommandSender.status() {
sendMessage(
"""
目前海中物品总数: ${Sea.contents.size}
其中漂流瓶数为: ${Sea.contents.count { it.type == Item.Type.BOTTLE }}
尸体数为: ${Sea.contents.count { it.type == Item.Type.BODY }}
""".trimIndent()
)
}
}

0 comments on commit 8ff768e

Please sign in to comment.