Skip to content

Commit

Permalink
Experimental | Fix Build & Remove Legacy Argument
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFloodDragon committed Sep 17, 2024
1 parent 9f23c56 commit ccb0d92
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 201 deletions.
2 changes: 0 additions & 2 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ fun DependencyHandler.compileAll() {
project(":project").dependencyProject.childProjects.forEach { add(ACTION_COMPILE, it.value) }
}

val Project.allModules get() = project(":project").childProjects.values

/**
* 依赖Taboolib模块
* @param module Taboolib模块名称
Expand Down
8 changes: 5 additions & 3 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import io.izzel.taboolib.gradle.UNIVERSAL

plugins {
id("io.izzel.taboolib") version taboolibPluginVersion
}
Expand Down Expand Up @@ -62,10 +60,14 @@ subprojects {
}

tasks {
jar { allModules.forEach { dependsOn(it.tasks.jar) } }
shadowJar {
dependsOn(taboolibMainTask)
from(taboolibMainTask.get().inJar)
dependencies {
exclude {
it.moduleGroup == "io.izzel.taboolib"
}
}
combineFiles.forEach { append(it) }
}
build { dependsOn(shadowJar) }
Expand Down
2 changes: 0 additions & 2 deletions plugin/platform-all/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ taboolib {
}
}

tasks.jar { platforms.forEach { dependsOn(it.tasks.jar) } }

tasks.shadowJar {
archiveFileName.set("$rootName-$rootVersion.jar")
}
10 changes: 8 additions & 2 deletions plugin/platform-bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ taboolib {
}
}

tasks.shadowJar {
archiveFileName.set("$rootName-Bukkit-$rootVersion.jar")
tasks {
shadowJar {
dependencies {
exclude(project(":project:module-compat-inject"))
}
archiveFileName.set("$rootName-Bukkit-$rootVersion.jar")
}
jar { dependsOn(project(":project:module-compat-inject").tasks.jar) }
}
Original file line number Diff line number Diff line change
@@ -1,48 +1,8 @@
package cn.fd.ratziel.function

import cn.fd.ratziel.function.argument.Argument
import cn.fd.ratziel.function.argument.ArgumentSupplier
import cn.fd.ratziel.function.argument.exception.ArgumentException
import cn.fd.ratziel.function.uncheck
import java.util.function.Function

fun <T : Any> ArgumentSupplier.supplyOrNull(type: Class<T>): Argument<T>? =
try {
get(type)
} catch (ex: ArgumentException) {
null
}

/**
* 判断参数是否为目标类型
* 相当于 V is T
*/
infix fun <T> Argument<*>.instanceof(type: Class<T>): Boolean = type.isAssignableFrom(this.type)

/**
* 如果参数为目标类型, 则执行 [onTrue], 反之执行 [onFalse]
* 相当 if.. else...
*/
fun <T : Any, R, V : Any> Argument<V>.ascertain(
clazz: Class<T>,
onTrue: Function<Argument<T>, R>,
onFalse: Function<Argument<V>, R>
): R = if (this.instanceof(clazz)) onTrue.apply(uncheck(this)) else onFalse.apply(this)


/**
* Inline 集群
*/

inline fun <reified T : Any> ArgumentSupplier.supplyOrNull(): Argument<T>? = supplyOrNull(T::class.java)

inline fun <reified T> Argument<*>.instanceof(): Boolean = this.instanceof(T::class.java)

inline fun <reified T : Any, R, V : Any> Argument<V>.ascertain(
onTrue: Function<Argument<T>, R>,
onFalse: Function<Argument<V>, R>
): R = this.ascertain(T::class.java, onTrue, onFalse)

inline fun <reified T : Any> ArgumentContext.pop() = pop(T::class.java)

inline fun <reified T : Any> ArgumentContext.popAll() = popAll(T::class.java)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ open class RatzielItem private constructor(info: Info, data: ItemData) : NeoItem
@JvmStatic
fun of(itemStack: ItemStack): RatzielItem? {
if (itemStack.isAir()) return null
val itemData = RefItemStack.of(itemStack).getData()
val itemData = RefItemStack.of(itemStack)
return of(itemData)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ data class SimpleData(
override var amount: Int = 1
) : ItemData {

/**
* 克隆数据
*/
override fun clone() = this.copy()

/**
* 合并数据
*/
override fun merge(other: ItemData) {
if (other.material != ItemMaterial.EMPTY) this.material = other.material
if (other.amount >= 1) this.amount = other.amount
}

companion object {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cn.fd.ratziel.module.item.impl.builder

import cn.fd.ratziel.core.util.splitNonEscaped
import cn.fd.ratziel.function.ArgumentContext
import cn.fd.ratziel.function.argument.exception.ArgumentNotFoundException
import cn.fd.ratziel.function.exception.ArgumentNotFoundException
import cn.fd.ratziel.module.item.api.builder.ItemResolver
import cn.fd.ratziel.module.item.api.builder.SectionTagResolver
import cn.fd.ratziel.module.item.impl.builder.provided.PapiResolver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ class RefItemStack private constructor(
} else {
this.tag = this.tag.merge(other.tag)
}
material = other.material
amount = other.amount
if (other.material != ItemMaterial.EMPTY) this.material = other.material
if (other.amount >= 1) this.amount = other.amount
}

/**
Expand Down

0 comments on commit ccb0d92

Please sign in to comment.