diff --git a/build.gradle.kts b/build.gradle.kts index d1bfc84..8438b7d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,11 +9,10 @@ plugins { } group = "io.github.solid-resourcepack" -version = "1.0.6" +version = "1.0.8" repositories { mavenCentral() - mavenLocal() maven("https://repo.papermc.io/repository/maven-public/") maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") } @@ -22,7 +21,7 @@ dependencies { testImplementation(rootProject.libs.kotlinTest) implementation(rootProject.libs.kotlinJvm) compileOnly(libs.paper) - api(libs.soldiMaterial) + api(libs.solidMaterial) api(libs.bundles.creative) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index df22272..eebef57 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,7 +15,7 @@ paper = { module = "io.papermc.paper:paper-api", version.ref = "paper" } creativeApi = { module = "team.unnamed:creative-api", version.ref = "creative" } creativeSerializer = { module = "team.unnamed:creative-serializer-minecraft", version.ref = "creative" } -soldiMaterial = { module = "io.github.solid-resourcepack:material-api", version.ref = "solidMaterial" } +solidMaterial = { module = "io.github.solid-resourcepack:solid-material-api", version.ref = "solidMaterial" } [bundles] creative = [ diff --git a/src/main/kotlin/io/github/solid/resourcepack/api/material/SolidMaterialMapper.kt b/src/main/kotlin/io/github/solid/resourcepack/api/material/SolidMaterialMapper.kt index 279b6d4..1cb0649 100644 --- a/src/main/kotlin/io/github/solid/resourcepack/api/material/SolidMaterialMapper.kt +++ b/src/main/kotlin/io/github/solid/resourcepack/api/material/SolidMaterialMapper.kt @@ -3,13 +3,14 @@ package io.github.solid.resourcepack.api.material import io.github.solid.resourcepack.material.SolidBlockMaterial import io.github.solid.resourcepack.material.SolidItemMaterial import io.github.solid.resourcepack.material.SolidMaterial +import net.kyori.adventure.key.Key import org.bukkit.Material import org.jetbrains.annotations.ApiStatus.Experimental object SolidMaterialMapper { /** - * Converts a [Material] to a [SolidMaterial] + * Gets a [SolidMaterial] by a [Material] * IMPORTANT: Only works in a server context */ @Experimental @@ -23,6 +24,17 @@ object SolidMaterialMapper { throw IllegalArgumentException("Material $material is not supported") } + /** + * Gets a [SolidMaterial] by a [Key] (if this key represents a material in a resource pack context) + */ + fun from(key: Key): SolidMaterial { + //For fastness, we use the key to determine the type, and then call from(Material, MaterialType) + val split = key.value().split("/") + val type = split.first().uppercase() + val material = split.last().uppercase() + return from(Material.valueOf(material), MaterialType.valueOf(type)) + } + fun from(material: Material, type: MaterialType): SolidMaterial { val returned = mutableListOf() if (type == MaterialType.ITEM || type == MaterialType.BOTH) {