Skip to content

Commit

Permalink
Merge pull request #3 from way-zer/fix-jitpack
Browse files Browse the repository at this point in the history
修复内容包在Jitpack上的maven发布
  • Loading branch information
way-zer authored Feb 16, 2022
2 parents 1258f08 + ceceeef commit 4f8fb9b
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 6 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -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:CONTENT_TYPE:VERSION'
}
```
* VERSION: 编译版本号 build version
* CONTENT_TYPE: 内容包类型(如flood) name of `Contents Pack`(ex `flood`)

## 安装 Setup
安装Release中的MOD即可(多人游戏兼容)
Install mod in Release(multiplayer compatible)
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ plugins {
kotlin("jvm") version "1.6.10"
}

group = "cf.wayzer.mindustryContents"
group = "cf.wayzer.MindustryContents"
version = System.getenv().getOrDefault("VERSION", "1.0-SNAPSHOT")
2 changes: 1 addition & 1 deletion contents/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ subprojects {
compileOnly("com.github.Anuken.Mindustry:core:v135")
}

publishing{
publishing {
publications {
create<MavenPublication>("maven") {
groupId = rootProject.group.toString()
Expand Down
2 changes: 2 additions & 0 deletions contents/origin/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
使用游戏原版,无源代码
No Source, using game original contents.
15 changes: 12 additions & 3 deletions loaderMod/src/main/kotlin/cf/wayzer/contentsMod/Contents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
rootProject.name = "MindustryContents"
include("contents")
include("contents:flood")
include("contents:origin")
include("loaderMod")

0 comments on commit 4f8fb9b

Please sign in to comment.