Skip to content

Commit

Permalink
Experimental | Prepartions for NEXT and Taboolib 6.2 Update [3/3]
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFloodDragon committed Sep 17, 2024
1 parent 9040f9a commit 9f23c56
Show file tree
Hide file tree
Showing 34 changed files with 151 additions and 537 deletions.
2 changes: 0 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ subprojects {
maven("https://papermc.io/repo/repository/maven-public/")
// OSS
maven("https://s01.oss.sonatype.org/content/groups/public/")
// PlaceholderAPI
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const val rootVersion = "A.0.3.0.9"

const val kotlinVersion = "2.0.20"
const val serializationVersion = "1.7.2"
const val coroutineVersion = "1.8.1"
const val coroutineVersion = "1.9.0"
const val shadowJarVersion = "8.3.0"
const val taboolibPluginVersion = "2.0.17"

const val taboolibVersion = "6.2.0-beta5"
const val taboolibVersion = "6.2.0-beta6"

val adventureModules = setOf(
"net.kyori:adventure-api:4.17.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface ItemData {
var material: ItemMaterial

/**
* 物品总标签数据
* 物品标签数据
*/
var tag: NBTCompound

Expand All @@ -25,21 +25,28 @@ interface ItemData {
*/
var amount: Int

/**
* 合并数据
*/
fun merge(other: ItemData)

/**
* 克隆数据
*/
fun clone(): ItemData

companion object {

/**
* 空 [ItemData]
*/
@JvmField
val EMPTY = object : ItemData {
override var material: ItemMaterial
get() = ItemMaterial.EMPTY
set(_) = throw UnsupportedOperationException("ItemData#EMPTY cannot be changed")
override var tag: NBTCompound
get() = NBTCompound()
set(_) = throw UnsupportedOperationException("ItemData#EMPTY cannot be changed")
override var amount: Int
get() = 0
set(_) = throw UnsupportedOperationException("ItemData#EMPTY cannot be changed")
override var material: ItemMaterial get() = ItemMaterial.EMPTY; set(_) = Unit
override var tag: NBTCompound get() = NBTCompound(); set(_) = Unit
override var amount: Int get() = 0; set(_) = Unit
override fun merge(other: ItemData) = Unit
override fun clone() = this
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ interface ItemMaterial {
/**
* 判断材料是否为空
*/
fun isEmpty() = this.id == EMPTY.id
fun isEmpty() = this == EMPTY

companion object {

/**
* 空材料
*/
@JvmField
val EMPTY = object : ItemMaterial {
override val name = "AIR"
override val maxStackSize = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ interface ItemNode {
/**
* 根节点
*/
val ROOT: ItemNode = object : ItemNode {
@JvmField
val ROOT = object : ItemNode {
override val name = "\$R\$O\$O\$T\$"
override val parent: ItemNode = this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ import kotlinx.serialization.json.JsonElement
* @author TheFloodDragon
* @since 2024/4/14 12:01
*/
@Deprecated("Use JsonTransofmer")
interface ItemResolver : ArgumentResolver<JsonElement, JsonElement>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ data class ItemDurability(
data.write(ItemSheet.REPAIR_COST, component.repairCost?.let { NBTInt(it) })
data.write(ItemSheet.MAX_DAMAGE, component.maxDurability?.let { NBTInt(it) })
// 无法破坏部分的特殊处理
if (MinecraftVersion.majorLegacy >= 12005) {
if (MinecraftVersion.versionId >= 12005) {
if (component.unbreakable == true && data.tag[ItemSheet.UNBREAKABLE.name] == null) {
data.tag[ItemSheet.UNBREAKABLE.name] = NBTCompound()
} else {
Expand All @@ -60,7 +60,7 @@ data class ItemDurability(
data.read<NBTInt>(ItemSheet.MAX_DAMAGE) { this.maxDurability = it.content }
// 无法破坏部分的特殊处理
val unsure = data.tag[ItemSheet.UNBREAKABLE.name]
if (MinecraftVersion.majorLegacy >= 12005) this.unbreakable = unsure != null
if (MinecraftVersion.versionId >= 12005) this.unbreakable = unsure != null
else if (unsure != null) this.unbreakable = NBTByte.parseBooleanOrFalse((unsure as NBTByte).content)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ object AttributeSerializer : KSerializer<Attribute> {

override fun serialize(encoder: Encoder, value: Attribute) = encoder.encodeString(value.key.key)

override fun deserialize(decoder: Decoder) = MetaMatcher.matchAttribute(decoder.decodeString())
override fun deserialize(decoder: Decoder) = MetaMatcher.matchAttribute(decoder.decodeString()).toBukkit()

}
Loading

0 comments on commit 9f23c56

Please sign in to comment.