Skip to content

Commit

Permalink
addon: improve compatibility, release 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed Apr 3, 2022
1 parent fb53bf2 commit 52b219b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 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 = "org.itxtech"
version = "2.0.0"
version = "2.0.1"
description = "在 Mirai Console 中使用MCL管理包和其他高级功能"

kotlin {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/itxtech/mcl/addon/PluginMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object PluginMain : KotlinPlugin(
JvmPluginDescription(
id = "org.itxtech.mcl.addon",
name = "MCL Addon",
version = "2.0.0"
version = "2.0.1"
) {
author("PeratX")
info("MCL Addon 支持在 Mirai Console 中使用 Mirai Console Loader 管理包和其他高级功能")
Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/org/itxtech/mcl/addon/command.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import net.mamoe.mirai.message.data.MessageChain
import net.mamoe.mirai.message.data.content
import org.itxtech.mcl.addon.PluginMain.addon
import org.itxtech.mcl.addon.logger.ConsoleLogger
import org.itxtech.mcl.component.Config

fun CommandSender.installLogger() {
val logger = addon.mcl.logger
Expand Down Expand Up @@ -83,8 +82,8 @@ object MclCommand : CompositeCommand(
@SubCommand
@Description("安装包")
suspend fun CommandSender.install(
@Name("package") pkg: String, channel: String = "stable",
type: String = Config.Package.TYPE_PLUGIN, version: String = "",
@Name("package") pkg: String, channel: String = "",
type: String = "", version: String = "",
@Name("lock or unlock") lock: String = "unlock"
) {
runMclCommand(arrayListOf("--update-package", pkg, "--channel", channel, "--type", type).apply {
Expand Down
9 changes: 4 additions & 5 deletions src/main/kotlin/org/itxtech/mcl/addon/logger/ConsoleLogger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@

package org.itxtech.mcl.addon.logger

import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import net.mamoe.mirai.console.command.CommandSender
import net.mamoe.mirai.console.command.isUser
import net.mamoe.mirai.console.command.isNotConsole
import net.mamoe.mirai.console.util.sendAnsiMessage
import org.itxtech.mcl.addon.PluginMain
import org.itxtech.mcl.addon.PluginMain.logger
import org.itxtech.mcl.component.Logger
import org.itxtech.mcl.impl.DefaultLogger
Expand All @@ -47,8 +46,8 @@ open class ConsoleLogger : DefaultLogger() {
}
else -> s
}
if (sender != null && sender.isUser()) {
PluginMain.launch {
if (sender != null && sender.isNotConsole()) {
runBlocking {
try {
sender.sendAnsiMessage(str)
} catch (ignored: Exception) {
Expand Down

0 comments on commit 52b219b

Please sign in to comment.