Skip to content

Commit

Permalink
addon: update to mcl 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed Mar 31, 2022
1 parent d7f590a commit fb53bf2
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 30 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
/mcl install <package> [channel] [type] [version] [lock or unlock] # 安装包
/mcl list # 列出已安装的包
/mcl remove <package> [delete] # 移除包
/mcl run <script> # 执行脚本load阶段
/mcl update # 执行updater脚本
/mcl run <script> # 执行模块load阶段
/mcl update # 执行updater模块
列出mirai-console包的信息
> mcl info net.mamoe:mirai-console
Expand All @@ -50,16 +50,17 @@
移除mirai-api-http,并删除其文件(保留配置文件)
> mcl remove net.mamoe:mirai-api-http delete
执行announcement脚本抓取MCL公告
执行announcement模块抓取MCL公告
> mcl run announcement
执行updater脚本(将应用包的修改)
执行updater模块(将应用包的修改)
> mcl update
```

## 开源许可证

Copyright (C) 2021 iTX Technologies
iTXTech MCL Addon
Copyright (C) 2021-2022 iTX Technologies

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
Expand Down
15 changes: 7 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
plugins {
id("net.mamoe.maven-central-publish") version "0.6.0-dev-2"
val kotlinVersion = "1.5.20"
id("me.him188.maven-central-publish") version "1.0.0-dev-3"
val kotlinVersion = "1.6.0"
kotlin("jvm") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion

id("net.mamoe.mirai-console") version "2.7-M2"
id("net.mamoe.mirai-console") version "2.11.0-M1"
}

group = "org.itxtech"
version = "1.2.2"
version = "2.0.0"
description = "在 Mirai Console 中使用MCL管理包和其他高级功能"

kotlin {
sourceSets {
all {
languageSettings.enableLanguageFeature("InlineClasses")
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
languageSettings.optIn("kotlin.Experimental")
}
}
}
Expand All @@ -26,9 +25,9 @@ repositories {
}

dependencies {
implementation("org.itxtech:mirai-console-loader:1.2.2")
implementation("org.itxtech:mcl:2.0.0-beta.1")
//Mirai Console Terminal Deps
implementation("net.mamoe:mirai-console-terminal:2.7-M2")
implementation("net.mamoe:mirai-console-terminal:2.11.0-M2.1")
implementation("org.jline:jline:3.15.0")
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/itxtech/mcl/addon/InternalAccessor.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.itxtech.mcl.addon;

import net.mamoe.mirai.console.MiraiConsole;
import net.mamoe.mirai.console.internal.plugin.PluginManagerImpl;
import net.mamoe.mirai.console.plugin.Plugin;

/*
*
* MCL Addon
*
* Copyright (C) 2021 iTX Technologies
* Copyright (C) 2021-2022 iTX Technologies
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand All @@ -28,6 +30,6 @@
@SuppressWarnings("ALL")
public class InternalAccessor {
public static void addResolvedPlugin(Plugin plugin) {
net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.INSTANCE.resolvedPlugins.add(plugin);
((PluginManagerImpl) MiraiConsole.INSTANCE.getPluginManager()).resolvedPlugins.add(plugin);
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/org/itxtech/mcl/addon/Addon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* MCL Addon
*
* Copyright (C) 2021 iTX Technologies
* Copyright (C) 2021-2022 iTX Technologies
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/itxtech/mcl/addon/PluginMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* MCL Addon
*
* Copyright (C) 2021 iTX Technologies
* Copyright (C) 2021-2022 iTX Technologies
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -31,7 +31,7 @@ object PluginMain : KotlinPlugin(
JvmPluginDescription(
id = "org.itxtech.mcl.addon",
name = "MCL Addon",
version = "1.2.2"
version = "2.0.0"
) {
author("PeratX")
info("MCL Addon 支持在 Mirai Console 中使用 Mirai Console Loader 管理包和其他高级功能")
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/org/itxtech/mcl/addon/command.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* MCL Addon
*
* Copyright (C) 2021 iTX Technologies
* Copyright (C) 2021-2022 iTX Technologies
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -111,21 +111,21 @@ object MclCommand : CompositeCommand(
}

@SubCommand
@Description("执行脚本load阶段")
@Description("执行模块load阶段")
suspend fun CommandSender.run(script: String) {
installLogger()
with(addon.mcl) {
manager.getScript(script)?.apply {
phase.load?.run()
manager.getModule(script)?.apply {
load()
return
}
logger.error("未找到脚本${script}")
logger.error("未找到模块${script}")
}
uninstallLogger()
}

@SubCommand
@Description("执行updater脚本")
@Description("执行updater模块")
suspend fun CommandSender.update() {
run("updater")
JvmPluginLoader.listPlugins().forEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* MCL Addon
*
* Copyright (C) 2021 iTX Technologies
* Copyright (C) 2021-2022 iTX Technologies
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -32,7 +32,6 @@ 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
import org.itxtech.mcl.utils.AnsiMsg

open class ConsoleLogger : DefaultLogger() {
val sender: ThreadLocal<CommandSender?> = ThreadLocal()
Expand All @@ -43,9 +42,6 @@ open class ConsoleLogger : DefaultLogger() {
}
val sender = this.sender.get()
val str = when (s) {
is AnsiMsg -> {
s.renderWithAnsi()
}
!is String -> {
s.toString()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* MCL Addon
*
* Copyright (C) 2021 iTX Technologies
* Copyright (C) 2021-2022 iTX Technologies
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down

0 comments on commit fb53bf2

Please sign in to comment.