From 721ece1e5f76450f5b5ec02128042f60c6f3fb68 Mon Sep 17 00:00:00 2001 From: way-zer Date: Wed, 16 Feb 2022 13:07:39 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0jitpack=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 16 ++++++++++++++++ build.gradle.kts | 2 +- contents/build.gradle.kts | 8 ++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 62c41cc..e193de4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build](https://github.com/way-zer/MindustryContents/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/way-zer/MindustryContents/actions/workflows/build.yml) +[![](https://jitpack.io/v/way-zer/MindustryContents.svg)](https://jitpack.io/#way-zer/MindustryContents) # MindustryContentsLoader 一个`内容包`加载器的像素工厂MOD A Mindustry MOD to dynamicly load `Contents Pack` @@ -15,6 +17,20 @@ A group of ContentList code, NO member, ONLY functionn `load` to assign new inst 例子参见[洪水模式内容包](./contents/flood) For example, see [flood ContentPack](./contents/flood) +### maven引用 import from maven +供插件或其他项目引用 +For plugin or other projects to import. +```groovy +repositories { + maven { url 'https://jitpack.io' } +} +dependencies { + implementation 'cf.wayzer:MindustryContents:VERSION:CONTENT_TYPE' +} +``` +* VERSION: 编译版本号 build version +* CONTENT_TYPE: 内容包类型(如flood) name of `Contents Pack`(ex `flood`) + ## 安装 Setup 安装Release中的MOD即可(多人游戏兼容) Install mod in Release(multiplayer compatible) diff --git a/build.gradle.kts b/build.gradle.kts index d681a55..8c6401d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,5 +2,5 @@ plugins { kotlin("jvm") version "1.6.10" } -group = "cf.wayzer.mindustryContents" +group = "cf.wayzer" version = System.getenv().getOrDefault("VERSION", "1.0-SNAPSHOT") \ No newline at end of file diff --git a/contents/build.gradle.kts b/contents/build.gradle.kts index 4879210..5876c19 100644 --- a/contents/build.gradle.kts +++ b/contents/build.gradle.kts @@ -19,11 +19,15 @@ subprojects { compileOnly("com.github.Anuken.Mindustry:core:v135") } - publishing{ + tasks.getByName("jar") { + archiveClassifier.set(project.name) + } + + publishing { publications { create("maven") { groupId = rootProject.group.toString() - artifactId = project.name + artifactId = rootProject.name version = rootProject.version.toString() from(components["kotlin"]) From 13a6b494d7d74700a9f3674a1eb13810b1364fb4 Mon Sep 17 00:00:00 2001 From: way-zer Date: Wed, 16 Feb 2022 13:24:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0origin=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- build.gradle.kts | 2 +- contents/build.gradle.kts | 6 +----- contents/origin/README | 2 ++ .../main/kotlin/cf/wayzer/contentsMod/Contents.kt | 15 ++++++++++++--- settings.gradle.kts | 1 + 6 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 contents/origin/README diff --git a/README.md b/README.md index e193de4..f5539a0 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ repositories { maven { url 'https://jitpack.io' } } dependencies { - implementation 'cf.wayzer:MindustryContents:VERSION:CONTENT_TYPE' + implementation 'cf.wayzer.MindustryContents:CONTENT_TYPE:VERSION' } ``` * VERSION: 编译版本号 build version diff --git a/build.gradle.kts b/build.gradle.kts index 8c6401d..06313e8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,5 +2,5 @@ plugins { kotlin("jvm") version "1.6.10" } -group = "cf.wayzer" +group = "cf.wayzer.MindustryContents" version = System.getenv().getOrDefault("VERSION", "1.0-SNAPSHOT") \ No newline at end of file diff --git a/contents/build.gradle.kts b/contents/build.gradle.kts index 5876c19..707eec3 100644 --- a/contents/build.gradle.kts +++ b/contents/build.gradle.kts @@ -19,15 +19,11 @@ subprojects { compileOnly("com.github.Anuken.Mindustry:core:v135") } - tasks.getByName("jar") { - archiveClassifier.set(project.name) - } - publishing { publications { create("maven") { groupId = rootProject.group.toString() - artifactId = rootProject.name + artifactId = project.name version = rootProject.version.toString() from(components["kotlin"]) diff --git a/contents/origin/README b/contents/origin/README new file mode 100644 index 0000000..a4ebfaf --- /dev/null +++ b/contents/origin/README @@ -0,0 +1,2 @@ +使用游戏原版,无源代码 +No Source, using game original contents. \ No newline at end of file diff --git a/loaderMod/src/main/kotlin/cf/wayzer/contentsMod/Contents.kt b/loaderMod/src/main/kotlin/cf/wayzer/contentsMod/Contents.kt index 453303e..f0c9836 100644 --- a/loaderMod/src/main/kotlin/cf/wayzer/contentsMod/Contents.kt +++ b/loaderMod/src/main/kotlin/cf/wayzer/contentsMod/Contents.kt @@ -8,17 +8,26 @@ import mindustry.ctype.ContentType @Suppress("MemberVisibilityCanBePrivate") object Contents { - fun flood():String{ + fun flood(): String { ContentsLoader.overwriteContents(ContentType.block, Blocks()) ContentsLoader.overwriteContents(ContentType.bullet, Bullets()) ContentsLoader.overwriteContents(ContentType.unit, UnitTypes()) return "OK" } - fun loadType(type: String) = when(type.lowercase()){ - "flood"-> flood() + fun origin(): String { + MyContentLoader.contents.forEach { + it.content = it.default + } + return "OK" + } + + fun loadType(type: String) = when (type.lowercase()) { + "flood" -> flood() + "origin" -> origin() else -> { Log.infoTag("ContentsLoader", "Unknown contents type $type") + origin() "NOTFOUND" } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 811d605..5a99df2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,5 @@ rootProject.name = "MindustryContents" include("contents") include("contents:flood") +include("contents:origin") include("loaderMod") \ No newline at end of file From ceceeefcd8af3461a0c5f3785584af4b980357ff Mon Sep 17 00:00:00 2001 From: way-zer Date: Wed, 16 Feb 2022 13:30:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=87=8F=E5=B0=91=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E9=87=8D=E5=A4=8D=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/cf/wayzer/contentsMod/ContentsLoader.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/loaderMod/src/main/kotlin/cf/wayzer/contentsMod/ContentsLoader.kt b/loaderMod/src/main/kotlin/cf/wayzer/contentsMod/ContentsLoader.kt index babc961..3fb53ec 100644 --- a/loaderMod/src/main/kotlin/cf/wayzer/contentsMod/ContentsLoader.kt +++ b/loaderMod/src/main/kotlin/cf/wayzer/contentsMod/ContentsLoader.kt @@ -16,7 +16,7 @@ class ContentsLoader : Mod() { override fun init() { Events.on(ResetEvent::class.java) { //fastPath - if (MyContentLoader.contents.all { it.content == it.lastContent }) { + if (MyContentLoader.contents.all { it.content eq it.lastContent }) { MyContentLoader.contents.forEach { it.content = it.default } return@on } @@ -45,6 +45,10 @@ class ContentsLoader : Mod() { @Suppress("unused", "MemberVisibilityCanBePrivate") companion object API { + infix fun ContentList.eq(contentList: ContentList?): Boolean { + return javaClass == contentList?.javaClass + } + fun maskChanged(type: ContentType) { val c = MyContentLoader.contentMap[type] ?: throw IllegalArgumentException("Not Support Overwrite ContentType") c.maskChanged()