mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-13 06:30:13 +08:00
[IJ] Create RunTerminal.kt
in project creating; fix #362
This commit is contained in:
parent
98521f7206
commit
95620cd386
@ -0,0 +1,21 @@
|
|||||||
|
package $PACKAGE_NAME
|
||||||
|
|
||||||
|
import net.mamoe.mirai.alsoLogin
|
||||||
|
import net.mamoe.mirai.console.MiraiConsole
|
||||||
|
import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.enable
|
||||||
|
import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.load
|
||||||
|
import net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader
|
||||||
|
|
||||||
|
suspend fun main() {
|
||||||
|
MiraiConsoleTerminalLoader.startAsDaemon()
|
||||||
|
|
||||||
|
val pluginInstance = ${CLASS_NAME}#if (${NOT_KOTLIN} != "Kotlin").INSTANCE #end
|
||||||
|
|
||||||
|
|
||||||
|
pluginInstance.load() // 主动加载插件, Console 会调用 MyPluginMain.onLoad
|
||||||
|
pluginInstance.enable() // 主动启用插件, Console 会调用 MyPluginMain.onEnable
|
||||||
|
|
||||||
|
val bot = MiraiConsole.addBot(123456, "").alsoLogin() // 登录一个测试环境的 Bot
|
||||||
|
|
||||||
|
MiraiConsole.job.join()
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||||
|
~
|
||||||
|
~ 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
~ Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||||
|
~
|
||||||
|
~ https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
-->
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<p>This is a built-in file template used to create a new settings.gradle.kts for Mirai Console Plugin projects.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -32,4 +32,6 @@ object FT { // file template
|
|||||||
const val PluginMainJava = "Plugin main class Java.java"
|
const val PluginMainJava = "Plugin main class Java.java"
|
||||||
|
|
||||||
const val Gitignore = ".gitignore"
|
const val Gitignore = ".gitignore"
|
||||||
|
|
||||||
|
const val RunTerminal = "RunTerminal.kt"
|
||||||
}
|
}
|
@ -28,6 +28,8 @@ class FileTemplateRegistrar : com.intellij.ide.fileTemplates.FileTemplateGroupDe
|
|||||||
addTemplate(FileTemplateDescriptor(FT.SettingsGradle))
|
addTemplate(FileTemplateDescriptor(FT.SettingsGradle))
|
||||||
|
|
||||||
addTemplate(FileTemplateDescriptor(FT.Gitignore))
|
addTemplate(FileTemplateDescriptor(FT.Gitignore))
|
||||||
|
|
||||||
|
addTemplate(FileTemplateDescriptor(FT.RunTerminal))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,8 @@ val MiraiProjectModel.templateProperties: Map<String, String?>
|
|||||||
|
|
||||||
"PACKAGE_NAME" to packageName,
|
"PACKAGE_NAME" to packageName,
|
||||||
"CLASS_NAME" to mainClassSimpleName,
|
"CLASS_NAME" to mainClassSimpleName,
|
||||||
|
|
||||||
|
"LANGUAGE_TYPE" to languageType.toString(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ sealed class GradleProjectCreator(
|
|||||||
addFileChanged(root.writeChild(model.languageType.pluginMainClassFile(this)))
|
addFileChanged(root.writeChild(model.languageType.pluginMainClassFile(this)))
|
||||||
addFileChanged(root.writeChild("src/main/resources/META-INF/services/net.mamoe.mirai.console.plugin.jvm.JvmPlugin", model.mainClassQualifiedName))
|
addFileChanged(root.writeChild("src/main/resources/META-INF/services/net.mamoe.mirai.console.plugin.jvm.JvmPlugin", model.mainClassQualifiedName))
|
||||||
addFileChanged(root.writeChild("gradle.properties", getTemplate(FT.GradleProperties)))
|
addFileChanged(root.writeChild("gradle.properties", getTemplate(FT.GradleProperties)))
|
||||||
|
addFileChanged(root.writeChild("src/test/kotlin/RunTerminal.kt", getTemplate(FT.RunTerminal)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user