├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── settings.gradle.kts ├── src └── main │ ├── kotlin │ └── cn │ │ └── souts │ │ └── taboolibinitializr │ │ ├── Main.kt │ │ ├── utils │ │ ├── StringTemplateLoader.kt │ │ ├── InitializrUtil.kt │ │ └── BukkitColorAnsiBuilder.kt │ │ ├── Entities.kt │ │ ├── Initializr.kt │ │ └── InitializrCommand.kt │ └── resources │ ├── config.yml │ └── module-mapping.yml ├── .gitignore ├── README.md ├── gradlew.bat └── gradlew /gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderKuo/TabooLib-Initializr/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" 3 | } 4 | rootProject.name = "TabooLib-Initializr" -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Mar 13 00:39:45 CST 2024 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /src/main/kotlin/cn/souts/taboolibinitializr/Main.kt: -------------------------------------------------------------------------------- 1 | package cn.souts.taboolibinitializr 2 | 3 | import taboolib.platform.App 4 | 5 | object Main { 6 | 7 | @JvmStatic 8 | fun main(args: Array) { 9 | App.init() 10 | Initializr.start() 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /src/main/kotlin/cn/souts/taboolibinitializr/utils/StringTemplateLoader.kt: -------------------------------------------------------------------------------- 1 | package cn.souts.taboolibinitializr.utils 2 | 3 | import freemarker.cache.TemplateLoader 4 | import java.io.Reader 5 | import java.io.StringReader 6 | 7 | class StringTemplateLoader : TemplateLoader { 8 | override fun findTemplateSource(p0: String?): Any { 9 | return p0.toString() 10 | } 11 | 12 | override fun getLastModified(p0: Any?): Long { 13 | return System.currentTimeMillis() 14 | } 15 | 16 | override fun getReader(p0: Any?, p1: String?): Reader { 17 | return StringReader(p0.toString().replace("_zh_CN_#Hans", "")) 18 | } 19 | 20 | override fun closeTemplateSource(p0: Any?) { 21 | } 22 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | 7 | ### IntelliJ IDEA ### 8 | .idea/modules.xml 9 | .idea/jarRepositories.xml 10 | .idea/compiler.xml 11 | .idea/libraries/ 12 | *.iws 13 | *.iml 14 | *.ipr 15 | out/ 16 | !**/src/main/**/out/ 17 | !**/src/test/**/out/ 18 | 19 | ### Eclipse ### 20 | .apt_generated 21 | .classpath 22 | .factorypath 23 | .project 24 | .settings 25 | .springBeans 26 | .sts4-cache 27 | bin/ 28 | !**/src/main/**/bin/ 29 | !**/src/test/**/bin/ 30 | 31 | ### NetBeans ### 32 | /nbproject/private/ 33 | /nbbuild/ 34 | /dist/ 35 | /nbdist/ 36 | /.nb-gradle/ 37 | 38 | ### VS Code ### 39 | .vscode/ 40 | 41 | ### Mac OS ### 42 | .DS_Store 43 | 44 | .out 45 | -------------------------------------------------------------------------------- /src/main/kotlin/cn/souts/taboolibinitializr/Entities.kt: -------------------------------------------------------------------------------- 1 | package cn.souts.taboolibinitializr 2 | 3 | data class SettingTemplate( 4 | var group: String? = null, 5 | var name: String? = null, 6 | var description: Description? = null, 7 | var env: Env? = null 8 | ) 9 | 10 | 11 | data class Env( 12 | var modules: MutableList? = null 13 | ) 14 | 15 | data class Module(var name: String? = null, var desc: String? = null, var dependency: List? = null) 16 | 17 | data class Description( 18 | var contributors: List? = null, 19 | var links: List? = null, var name: String? = null 20 | ) 21 | 22 | data class Contributor(var name: String? = null, var description: String? = null) 23 | 24 | data class Link(var name: String? = null, var url: String? = null) 25 | 26 | 27 | data class Template(var name: String? = null, var path: String? = null) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TabooLib-模板生成器 2 | 3 | 快捷生成TabooLib项目解决方案,本项目使用`TabooLib`开发 4 | 5 | ## 构建 6 | 7 | ```shell 8 | ./gradlew build 9 | ``` 10 | 11 | ## 打开build/libs/文件夹 12 | 13 | ```shell 14 | java -jar TabooLib-Initializr-1.1.jar 15 | ``` 16 | 17 | ## 使用方法 18 | 19 | ### 命令 20 | 21 | ```shell 22 | # 主命令 23 | taboolib # 别名 taboo tb 24 | 25 | tb create 项目名 # 创建项目 26 | tb create 项目名 模板 # 使用模板创建项目 27 | 28 | tb edit 项目名 # 编辑项目 29 | tb edit 项目名 group xxx.xxx # 编辑项目组名 30 | tb edit 项目名 env list # 查看所有模块及索引 31 | tb edit 项目名 env add 1 2 3 # 给项目中加入索引为1 2 3 的模块 32 | 33 | tb write 项目名 路径 # 写出项目 路径为空时自动为当前目录下out文件夹 34 | ``` 35 | 36 | ![](https://souts.cn/upload/iShot_2024-03-14_02.06.05.png) 37 | 38 | ### 图片展示 39 | 40 | ![](https://souts.cn/upload/展示图片1.png) 41 | 42 | ## 相关链接 43 | 44 | [TabooLib](https://github.com/TabooLib/taboolib) 45 | 46 | [TabooLib-Initializr-Template](https://github.com/CoderKuo/TabooLib-Initializr-Template) 47 | -------------------------------------------------------------------------------- /src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | # 是否开启模板文件校验 2 | verify: true 3 | 4 | setting-template: 5 | example: 6 | group: 'com.dakuo' 7 | description: 8 | contributors: 9 | - name: 'dakuo' 10 | description: "abc" 11 | links: 12 | - name: 'blog' 13 | url: 'https://souts.cn' 14 | env: 15 | modules: 16 | - name: 'BUKKIT_ALL' 17 | 18 | 19 | wrapperDownloadFile: "https://gitee.com/dakuo/taboo-lib-initializr-template/raw/master/gradle-wrapper.jar" 20 | 21 | templateDownloadURL: "https://gitee.com/dakuo/taboo-lib-initializr-template/raw/master/template/" 22 | templates: 23 | - name: 'build.gradle.kts.ftl' 24 | path: '.' 25 | - name: 'Plugin.kt.ftl' 26 | path: './src/main/kotlin/${group}/${name?lower_case}/${name}.kt' 27 | - name: 'main.yml.ftl' 28 | path: './.github/workflows/.' 29 | - name: 'README.md.ftl' 30 | path: '.' 31 | - name: 'settings.gradle.kts.ftl' 32 | path: '.' 33 | - name: 'LINCENSE.ftl' 34 | path: '.' 35 | - name: 'gradlew.ftl' 36 | path: '.' 37 | - name: 'gradlew.bat.ftl' 38 | path: '.' 39 | - name: 'gradle-wrapper.properties.ftl' 40 | path: './gradle/wrapper/.' 41 | - name: 'gradle.properties.ftl' 42 | path: '.' 43 | - name: '.gitignore.ftl' 44 | path: '.' 45 | -------------------------------------------------------------------------------- /src/main/resources/module-mapping.yml: -------------------------------------------------------------------------------- 1 | modules: 2 | - name: CHAT 3 | desc: '聊天模块' 4 | - name: CONFIGURATION 5 | desc: '配置模块' 6 | - name: LANG 7 | desc: '语言模块' 8 | dependency: 9 | - CONFIGURATION 10 | - name: KETHER 11 | desc: 'kether模块' 12 | dependency: 13 | - CONFIGURATION 14 | - name: METRICS 15 | desc: 'bstat统计模块' 16 | dependency: 17 | - CONFIGURATION 18 | - name: DATABASE 19 | desc: '数据库模块' 20 | dependency: 21 | - CONFIGURATION 22 | - name: NMS 23 | desc: 'nms模块' 24 | - name: NMS_UTIL 25 | desc: 'nms工具库' 26 | dependency: 27 | - NMS 28 | - name: NAVIGATION 29 | desc: '导航模块' 30 | dependency: 31 | - NMS 32 | - name: AI 33 | desc: 'AI模块' 34 | dependency: 35 | - NMS 36 | - name: UI 37 | desc: 'UI模块' 38 | dependency: 39 | - CHAT 40 | - NMS 41 | - name: EFFECT 42 | desc: '莫式粒子库' 43 | - name: PORTICUS 44 | desc: 'BungeeCord 通讯工具' 45 | - name: EXPANSION_REDIS 46 | desc: 'Redis 扩展模块' 47 | - name: EXPANSION_COMMAND_HELPER 48 | desc: '命令帮助扩展模块' 49 | - name: EXPANSION_GEEK_TOOL 50 | - name: EXPANSION_IOC 51 | - name: EXPANSION_JAVASCRIPT 52 | desc: 'JavaScript 扩展模块' 53 | - name: EXPANSION_LANG_TOOL 54 | - name: EXPANSION_PLAYER_DATABASE 55 | desc: '玩家持久化数据扩展模块' 56 | - name: EXPANSION_PLAYER_FAKE_OP 57 | - name: EXPANSION_SUBMIT_CHAIN 58 | - name: EXPANSION_PTC 59 | - name: EXPANSION_PTC_OBJECT 60 | - name: EXPANSION_JEXL 61 | - name: EXPANSION_FOLIA 62 | - name: APPLICATION 63 | - name: BUKKIT 64 | - name: BUKKIT_HOOK 65 | - name: BUKKIT_UTIL 66 | - name: BUKKIT_XSERIES 67 | - name: BUNGEE 68 | - name: VELOCITY 69 | - name: BUKKIT_ALL 70 | desc: 'Bukkit 完整模块' 71 | dependency: 72 | - BUKKIT 73 | - BUKKIT_HOOK 74 | - BUKKIT_UTIL 75 | - BUKKIT_XSERIES 76 | - name: UNIVERSAL 77 | desc: '泛用模块' 78 | dependency: 79 | - CHAT 80 | - CONFIGURATION 81 | - LANG 82 | - EXPANSION_COMMAND_HELPER 83 | - name: UNIVERSAL_DATABASE 84 | desc: '通用数据存储' 85 | dependency: 86 | - DATABASE 87 | - EXPANSION_PTC_OBJECT 88 | 89 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /src/main/kotlin/cn/souts/taboolibinitializr/utils/InitializrUtil.kt: -------------------------------------------------------------------------------- 1 | package cn.souts.taboolibinitializr.utils 2 | 3 | import cn.souts.taboolibinitializr.Initializr 4 | import cn.souts.taboolibinitializr.Module 5 | import cn.souts.taboolibinitializr.SettingTemplate 6 | import freemarker.template.Configuration 7 | import freemarker.template.Template 8 | import taboolib.module.configuration.ConfigSection 9 | import taboolib.module.configuration.Configuration.Companion.getObject 10 | import java.awt.Desktop 11 | import java.io.* 12 | import java.nio.file.Files 13 | import java.nio.file.StandardCopyOption 14 | 15 | 16 | object InitializrUtil { 17 | 18 | val moduleList = getModuleListFromMapping() 19 | 20 | val settingTemplate = getSettingTemplateFromConfig() 21 | 22 | fun writeFile(settingTemplate: SettingTemplate, outFile: File) { 23 | val out = File(outFile, "${settingTemplate.name}").also { 24 | if (!it.exists()) { 25 | it.mkdirs() 26 | } 27 | } 28 | startWriteFromTemplate(settingTemplate, out) 29 | writeGradleWrapper(File(out, "gradle/wrapper/gradle-wrapper.jar")) 30 | 31 | openDir(outFile) 32 | } 33 | 34 | private fun openDir(folder: File) { 35 | if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { 36 | return 37 | } 38 | 39 | val desktop = Desktop.getDesktop() 40 | try { 41 | desktop.open(folder) 42 | } catch (e: IOException) { 43 | e.printStackTrace() 44 | } 45 | } 46 | 47 | private fun writeGradleWrapper(outFile: File) { 48 | if (!outFile.exists()) { 49 | if (!outFile.parentFile.exists()) { 50 | outFile.parentFile.mkdirs() 51 | } 52 | try { 53 | Files.copy(Initializr.wrapperFile.toPath(), outFile.toPath(), StandardCopyOption.REPLACE_EXISTING) 54 | } catch (e: IOException) { 55 | e.printStackTrace() 56 | println("复制文件时发生错误: ${e.message}") 57 | } 58 | } 59 | } 60 | 61 | private fun startWriteFromTemplate(settingTemplate: SettingTemplate, outFile: File) { 62 | val templateFile = File("./template") 63 | val configuration = Configuration() 64 | configuration.setDirectoryForTemplateLoading(templateFile) 65 | configuration.defaultEncoding = "utf-8" 66 | 67 | val stringTemplateLoaderConfiguration = Configuration() 68 | stringTemplateLoaderConfiguration.templateLoader = StringTemplateLoader() 69 | stringTemplateLoaderConfiguration.defaultEncoding = "utf-8" 70 | Initializr.templates.forEach { 71 | val template = stringTemplateLoaderConfiguration.getTemplate(it.path) 72 | val stw = StringWriter() 73 | template.process( 74 | mapOf( 75 | "name" to settingTemplate.name, "group" to settingTemplate.group?.replace(".", "/") 76 | ), stw 77 | ) 78 | stw.flush() 79 | stw.close() 80 | writeFTL(settingTemplate, it, File(outFile, stw.toString()), configuration) 81 | } 82 | } 83 | 84 | private fun writeFTL( 85 | settingTemplate: SettingTemplate, 86 | template: cn.souts.taboolibinitializr.Template, 87 | outFile: File, 88 | configuration: Configuration 89 | ) { 90 | val freemarkerTemplate: Template = configuration.getTemplate(template.name) 91 | val outFile = if (outFile.toString().last() != '/' && outFile.toString().last() != '.') { 92 | outFile.also { 93 | if (!it.parentFile.exists()) { 94 | it.parentFile.mkdirs() 95 | } 96 | } 97 | } else { 98 | File(outFile.toString().removeSuffix("."), template.name!!.removeSuffix(".ftl")).apply { 99 | if (!parentFile.exists()) { 100 | parentFile.mkdirs() 101 | } 102 | } 103 | } 104 | val out: Writer = FileWriter(outFile) 105 | freemarkerTemplate.process(settingTemplate, out) 106 | out.flush() 107 | out.close() 108 | } 109 | 110 | private fun getModuleListFromMapping(): MutableList { 111 | val list = mutableListOf() 112 | Initializr.moduleMapping.onEachIndexed { index, (key, module) -> 113 | list.add(index, module) 114 | } 115 | return list 116 | } 117 | 118 | 119 | private fun getSettingTemplateFromConfig(): Map { 120 | val settingTemplates = Initializr.config.get("setting-template") as ConfigSection 121 | return settingTemplates.getKeys(false).map { key -> 122 | key to settingTemplates.getObject(key) 123 | }.toMap() 124 | } 125 | 126 | } -------------------------------------------------------------------------------- /src/main/kotlin/cn/souts/taboolibinitializr/utils/BukkitColorAnsiBuilder.kt: -------------------------------------------------------------------------------- 1 | package cn.souts.taboolibinitializr.utils 2 | 3 | import java.awt.Color 4 | 5 | object BukkitColorAnsiBuilder { 6 | 7 | private const val MARKER = '&' 8 | private const val PREFIX = '{' 9 | private const val SUFFIX = '}' 10 | 11 | fun colored(string: String): String { 12 | val sb = StringBuilder() 13 | val charArray = string.toCharArray() 14 | var index = 0 15 | while (index < charArray.size) { 16 | val c = charArray[index] 17 | if (c == MARKER) { 18 | if (index + 1 < charArray.size) { 19 | val code = charArray[index + 1] 20 | if (code == PREFIX) { 21 | sb.append(AnsiBukkitCode.parse(appendEndSuffix(string.substring(index + 2)).also { 22 | index += it.length + 2 23 | })) 24 | 25 | } else { 26 | sb.append(AnsiBukkitCode.parse(code)) 27 | index++ 28 | } 29 | } 30 | } else { 31 | sb.append(c) 32 | } 33 | index++ 34 | } 35 | return sb.apply { append("\u001B[0m") }.toString() 36 | } 37 | 38 | fun addColor(key: String, color: Color, alias: Char? = null) { 39 | AnsiBukkitCode.customMap.put(key, object : AnsiBukkitCode { 40 | override val alias: Char? = alias 41 | 42 | override fun transform(): String { 43 | return "\u001B[38;2;${color.red};${color.green};${color.blue}m" 44 | } 45 | }) 46 | } 47 | 48 | private fun appendEndSuffix(string: String): String { 49 | val sb = StringBuilder() 50 | val charArray = string.toCharArray() 51 | charArray.forEachIndexed { index, c -> 52 | if (c == SUFFIX) { 53 | return sb.toString() 54 | } else { 55 | sb.append(c) 56 | } 57 | } 58 | return sb.toString() 59 | } 60 | 61 | } 62 | 63 | interface AnsiBukkitCode { 64 | 65 | val alias: Char? 66 | 67 | fun transform(): String 68 | 69 | companion object { 70 | 71 | val customMap: MutableMap = mutableMapOf() 72 | 73 | @JvmStatic 74 | fun parse(code: String): String { 75 | if (code.split(Regex("[, ,]")).size == 3) { 76 | val split = code.split(Regex("[, ,]")) 77 | return "\u001B[38;2;${split[0].trim()};${split[1].trim()};${split[2].trim()}m" 78 | } 79 | AnsiBukkitColorCode.entries.find { 80 | it.name.lowercase() == code.lowercase() || it.alias.toString().lowercase() == code.lowercase() 81 | }?.also { 82 | return it.transform() 83 | } 84 | AnsiBukkitFormatCode.entries.find { 85 | it.name.lowercase() == code.lowercase() || it.alias.toString().lowercase() == code.lowercase() 86 | }?.also { 87 | return it.transform() 88 | } 89 | customMap[code]?.also { return it.transform() } 90 | customMap.values.find { it.alias.toString().lowercase() == code.lowercase() } 91 | ?.also { return it.transform() } 92 | return code 93 | } 94 | 95 | @JvmStatic 96 | fun parse(code: Char): String { 97 | return parse(code.toString()) 98 | } 99 | 100 | } 101 | } 102 | 103 | enum class AnsiBukkitColorCode(val red: Int, val green: Int, val blue: Int, override val alias: Char? = null) : 104 | AnsiBukkitCode { 105 | GREEN(85, 255, 85, 'a'), 106 | RED(255, 85, 85, 'c'), 107 | BLUE(85, 255, 255, 'b'), 108 | LightPurple(255, 85, 255, 'd'), 109 | YELLOW(255, 255, 85, 'e'), 110 | WHITE(255, 255, 255, 'f'), 111 | DARKGRAY(85, 85, 85, '8'), 112 | GRAY(170, 170, 170, '7'), 113 | GOLD(255, 170, 0, '6'), 114 | DarkPurple(170, 0, 170, '5'), 115 | DarkRed(170, 0, 0, '4'), 116 | DarkAqua(0, 170, 170, '3'), 117 | DarkGreen(0, 170, 0, '2'), 118 | Black(0, 0, 0, '0') 119 | ; 120 | 121 | 122 | override fun transform(): String { 123 | return "\u001B[38;2;$red;$green;${blue}m" 124 | } 125 | 126 | 127 | } 128 | 129 | enum class AnsiBukkitFormatCode(val code: String, override val alias: Char?) : AnsiBukkitCode { 130 | // 重置样式 131 | RESET("0", 'r'), 132 | 133 | // 加粗 134 | BOLD("1", 'l'), 135 | 136 | // 斜体 137 | ITALIC("3", 'o'), 138 | 139 | // 删除线 140 | STRIKETHROUGH("9", 'm'), 141 | 142 | // 下划线 143 | UNDERLINE("4", 'n') 144 | ; 145 | 146 | override fun transform(): String { 147 | return "\u001B[${code}m" 148 | } 149 | 150 | 151 | } 152 | 153 | fun String.consoleColored(): String { 154 | return BukkitColorAnsiBuilder.colored(this) 155 | } 156 | 157 | fun println(message: Any) { 158 | System.out.println(message.toString().consoleColored()) 159 | } 160 | 161 | fun print(message: Any) { 162 | System.out.print(message.toString().consoleColored()) 163 | } 164 | 165 | fun println() { 166 | System.out.println() 167 | } -------------------------------------------------------------------------------- /src/main/kotlin/cn/souts/taboolibinitializr/Initializr.kt: -------------------------------------------------------------------------------- 1 | package cn.souts.taboolibinitializr 2 | 3 | import cn.souts.taboolibinitializr.utils.println 4 | import org.fusesource.jansi.Ansi 5 | import org.fusesource.jansi.AnsiConsole 6 | import taboolib.common.LifeCycle 7 | import taboolib.common.platform.Awake 8 | import taboolib.module.configuration.Config 9 | import taboolib.module.configuration.Configuration 10 | import java.io.* 11 | import java.net.URL 12 | import java.nio.file.Files 13 | import java.security.MessageDigest 14 | import java.security.NoSuchAlgorithmException 15 | import java.util.* 16 | 17 | 18 | object Initializr { 19 | 20 | @Config 21 | lateinit var config: Configuration 22 | val moduleMapping: LinkedHashMap = LinkedHashMap() 23 | val templates = mutableListOf