Skip to content

Commit

Permalink
feat: 添加关闭戳一戳帮助功能 #4
Browse files Browse the repository at this point in the history
  • Loading branch information
limbang committed Dec 18, 2024
1 parent 169734e commit b4c8b82
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "top.limbang"
version = "1.2.2"
version = "1.2.3"


repositories {
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/mirai/Minecraft.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ import net.mamoe.mirai.event.GlobalEventChannel
import net.mamoe.mirai.event.events.NudgeEvent
import net.mamoe.mirai.event.registerTo
import top.limbang.minecraft.mirai.PluginCompositeCommand.renameServer
import top.limbang.minecraft.mirai.PluginData.isNudgeHelp
import top.limbang.mirai.event.GroupRenameEvent

object Minecraft : KotlinPlugin(
JvmPluginDescription(
id = "top.limbang.minecraft",
name = "Minecraft",
version = "1.2.2",
version = "1.2.3",
) {
author("limbang")
info("""Minecraft插件""")
Expand Down Expand Up @@ -58,7 +59,7 @@ object Minecraft : KotlinPlugin(
MinecraftListener.registerTo(eventChannel)

eventChannel.subscribeAlways<NudgeEvent> {
if (target.id == bot.id) {
if (target.id == bot.id && isNudgeHelp) {
subject.sendMessage(
"Minecraft 插件使用说明:\n" +
"Ping服务器:$ping 服务器名称\n" +
Expand Down
8 changes: 8 additions & 0 deletions src/main/kotlin/mirai/PluginCompositeCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import net.mamoe.mirai.console.plugin.id
import net.mamoe.mirai.contact.Group
import net.mamoe.mirai.event.broadcast
import top.limbang.minecraft.mirai.PluginData.isAllToImg
import top.limbang.minecraft.mirai.PluginData.isNudgeHelp
import top.limbang.minecraft.mirai.PluginData.serverMap
import top.limbang.mirai.event.GroupRenameEvent

Expand Down Expand Up @@ -82,4 +83,11 @@ object PluginCompositeCommand : CompositeCommand(Minecraft, "mc") {
isAllToImg = value
sendMessage("All消息转换为图片功能:$isAllToImg")
}

@SubCommand
@Description("设置是否开启戳一戳帮助功能")
suspend fun CommandSender.setNudgeHelp(value: Boolean) {
isNudgeHelp = value
sendMessage("戳一戳帮助功能:$isNudgeHelp")
}
}
3 changes: 3 additions & 0 deletions src/main/kotlin/mirai/PluginData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ object PluginData : AutoSavePluginData("minecraft") {

@ValueDescription("All消息是否是图片,默认 false")
var isAllToImg: Boolean by value(false)

@ValueDescription("是否开启戳一戳帮助功能,默认 true")
var isNudgeHelp: Boolean by value(true)
}

0 comments on commit b4c8b82

Please sign in to comment.