diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index a50cacd8..a68ab4d8 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -8,12 +8,9 @@ name: Java CI with Gradle on: - push: - branches: [ "v1.x.x", "v2.x.x" ] - pull_request: - branches: [ "v1.x.x", "v2.x.x" ] release: types: [published] + branches: [ "v1.x.x" ] concurrency: group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} @@ -26,46 +23,37 @@ jobs: contents: write env: - MODRINTH_VERSIONS: '["1.18.x", "1.19.x", "1.20.x", "1.21.x", "26.1.x", "26.2.x"]' + MODRINTH_VERSIONS: '["1.18.x", "1.19.x", "1.20.x"]' MODRINTH_PLATFORMS: '["spigot", "paper", "purpur", "folia"]' steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up JDKs - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: java-version: | 21 distribution: 'temurin' - cache: gradle - - - name: Cache Gradle root and wrapper - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: gradle-root-${{ runner.os }}-${{ hashFiles('build.gradle*') }} - restore-keys: gradle-root-${{ runner.os }}- - - # Setup paperweight cache - - name: Cache paperweight - uses: actions/cache@v3 - with: - path: | - ./nms/*/.gradle/caches/paperweight - key: paperweight-submodules-${{ runner.os }}-${{ hashFiles('nms/*/build.gradle*') }} - restore-keys: | - paperweight-submodules-${{ runner.os }}- # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md - name: Setup Gradle - uses: gradle/actions/setup-gradle@v5 + uses: gradle/actions/setup-gradle@v6 - name: Make gradlew executable run: chmod +x ./gradlew + # Setup paperweight cache + - name: Cache paperweight + uses: actions/cache@v6 + with: + path: | + ./nms/*/.gradle/caches/paperweight + ./.gradle/caches/paperweight + key: paperweight-submodules-${{ runner.os }}-${{ hashFiles('nms/*/build.gradle*') }} + restore-keys: | + paperweight-submodules-${{ runner.os }}- + - name: Get small commit hash if: ${{ github.event_name != 'release' && success() }} run: echo "SMALL_COMMIT_HASH=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV @@ -75,7 +63,7 @@ jobs: # only submit dependency on push - name: Generate and submit dependency graph - uses: gradle/actions/dependency-submission@v4 + uses: gradle/actions/dependency-submission@v6 if: ${{ github.event_name == 'push' && success() }} continue-on-error: true @@ -91,16 +79,16 @@ jobs: # upload the named jars as artifact - name: Upload online JAR artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: - name: CustomAnvil.jar path: build/libs/${{ env.ONLINE_JAR_NAME }} + archive: false - name: Upload offline JAR file - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: - name: CustomAnvil-offline.jar path: build/libs/${{ env.OFFLINE_JAR_NAME }} + archive: false - name: Summarize tests results uses: jeantessier/test-summary-action@v1 @@ -109,33 +97,12 @@ jobs: # upload the jar to release - name: Upload jar to release if: ${{ github.event_name == 'release' && success() }} - uses: softprops/action-gh-release@v2 + uses: softprops/action-gh-release@v3 with: files: | build/libs/${{ env.ONLINE_JAR_NAME }} build/libs/${{ env.OFFLINE_JAR_NAME }} - - name: Hangar release - if: ${{ (github.event_name != 'release' || github.event_name != 'push') && github.repository_owner == 'alexcrea' && success() }} - env: - HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }} - RELEASE_CHANGELOG: ${{ github.event.release.body }} - run: ./gradlew publishAllPublicationsToHangar --stacktrace - - - name: Modrinth publish alpha - if: ${{ github.event_name == 'push' && github.repository_owner == 'alexcrea' && success() }} - uses: cloudnode-pro/modrinth-publish@v2 - with: - token: ${{ secrets.MODRINTH_TOKEN }} - project: S75Ueiq9 - name: dev-${{ env.SMALL_COMMIT_HASH }} - version: dev-${{ env.SMALL_COMMIT_HASH }} - loaders: ${{ env.MODRINTH_PLATFORMS }} - game-versions: ${{ env.MODRINTH_VERSIONS }} - channel: alpha - files: build/libs/${{ env.ONLINE_JAR_NAME }} - changelog: ${{ github.event.head_commit.message }} - - name: Modrinth publish release if: ${{ github.event_name == 'release' && github.repository_owner == 'alexcrea' && success() }} uses: cloudnode-pro/modrinth-publish@v2 @@ -156,8 +123,7 @@ jobs: with: webhook-url: ${{ secrets.RELEASE_WEBHOOK_URL }} content: | - ${{ github.event.release.prerelease == false && '<@&1338546156325568642>' || '<@&1352296092989001768>' }} - # New ${{ github.event.release.prerelease && 'beta ' || '' }}version of custom anvil ! <:CustomAnvil:1262550667986342001>([Modrinth](https://modrinth.com/plugin/customanvil), [Hangar](https://hangar.papermc.io/alexcrea/CustomAnvil) and [GitHub](${{ github.event.release.html_url }}) links) - -# note: automated release. spigot is not uploaded yet. + <@&1525259349423947867> + # New bugfix for CustomAnvil v1 ! <:CustomAnvil:1262550667986342001> [Modrinth](https://modrinth.com/plugin/customanvil) and [GitHub](${{ github.event.release.html_url }}) links ${{ github.event.release.body }} diff --git a/build.gradle.kts b/build.gradle.kts index dcf8a5a6..fcde08c8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,24 +5,23 @@ import groovy.util.NodeList import io.papermc.hangarpublishplugin.model.HangarPublication import io.papermc.hangarpublishplugin.model.Platforms import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import java.io.ByteArrayOutputStream plugins { - kotlin("jvm") version "2.3.0" + kotlin("jvm") version "2.4.0" java - id("org.jetbrains.dokka").version("1.9.20") - id("com.gradleup.shadow").version("9.3.0") + id("org.jetbrains.dokka").version("2.2.0") + id("com.gradleup.shadow").version("9.6.1") // Maven publish `maven-publish` signing - id("cn.lalaki.central").version("1.2.8") + id("cn.lalaki.central").version("2.0.8") // Paper - id("io.papermc.paperweight.userdev") version "2.0.0-beta.17" apply false - id("io.papermc.hangar-publish-plugin") version "0.1.2" + id("io.papermc.paperweight.userdev") version "2.0.0-beta.21" apply false + id("io.papermc.hangar-publish-plugin") version "0.1.4" } group = "xyz.alexcrea" -version = "1.18.0" +version = "1.20.1" val isDevBuild = System.getenv("SMALL_COMMIT_HASH") != null val isPreRelease = System.getenv("IS_GITHUB_PRERELEASE") == "true" @@ -34,9 +33,6 @@ repositories { // EcoEnchants maven(url = "https://repo.auxilor.io/repository/maven-public/") - // ExcellentEnchants - maven(url = "https://repo.nightexpressdev.com/releases") - // ItemsAdder maven(url = "https://maven.devs.beer/") @@ -58,7 +54,7 @@ dependencies { compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT") // fast stats - implementation("dev.faststats.metrics:bukkit:0.27.2") + implementation("dev.faststats.metrics:bukkit:0.29.0") // minimessage implementation("net.kyori:adventure-text-minimessage:4.25.0") @@ -72,21 +68,22 @@ dependencies { compileOnly(files("libs/EnchantsSquared.jar")) // EcoEnchants & item - compileOnly("com.willfp:libreforge:4.79.0:all") - compileOnly("com.willfp:eco:6.74.5") + compileOnly("com.willfp:libreforge:2026.32:all") + compileOnly("com.willfp:eco:2026.32") - compileOnly("com.willfp:EcoEnchants:12.11.1") + compileOnly("com.willfp:EcoEnchants:2026.32:all") compileOnly(project(":impl:LegacyEcoEnchant")) compileOnly("com.willfp:EcoItems:5.66.0") // ExcellentEnchants implementation(project(":impl:ExcellentEnchant5_4")) - compileOnly("su.nightexpress.excellentenchants:Core:5.1.0") { - exclude("org.spigotmc") - } - compileOnly(files("libs/ExcellentEnchants-4.3.3-striped.jar")) // For pre v5 excellent enchants - compileOnly(files("libs/ExcellentEnchants-4.1.0-striped.jar")) // For legacy excellent enchants + compileOnly(files("libs/ExcellentEnchants/ExcellentEnchants-4.3.3-striped.jar")) // For pre v5 excellent enchants + compileOnly(files("libs/ExcellentEnchants/ExcellentEnchants-4.1.0-striped.jar")) // For legacy excellent enchants + // early v5 excellent enchants + compileOnly(files("libs/ExcellentEnchants/Core-5.1.0.jar")) + compileOnly(files("libs/ExcellentEnchants/API-5.1.0.jar")) + compileOnly(files("libs/ExcellentEnchants/main-2.7.9.jar")) // Disenchantment compileOnly(files("libs/Disenchantment-6.1.5.jar")) @@ -168,7 +165,7 @@ allprojects { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_16) } } @@ -180,7 +177,10 @@ tasks { fun ShadowJar.configureBaseShadow(suffix: String, libraries: Array) { val processedSuffix = if(suffix.isEmpty()) "" else "-$suffix" - val name = "${rootProject.name}-${effectiveVersion}${processedSuffix}.jar" + val version = effectiveVersion + val name = "${rootProject.name}-${version}${processedSuffix}.jar" + val librariesExpendTo = libraries.joinToString(transform = { "\"$it\"" }) + archiveFileName.set(name) // Shadow necessary dependency @@ -189,8 +189,8 @@ tasks { filesMatching("plugin.yml") { expand( - "version" to effectiveVersion + processedSuffix, - "libraries" to libraries.joinToString(transform = { "\"$it\"" }), + "version" to version + processedSuffix, + "libraries" to librariesExpendTo, ) } @@ -202,7 +202,7 @@ tasks { shadowJar { configureBaseShadow("", arrayOf( - "org.jetbrains.kotlin:kotlin-stdlib:2.3.0", + "org.jetbrains.kotlin:kotlin-stdlib:2.4.0", "net.kyori:adventure-text-minimessage:4.25.0", "net.kyori:adventure-text-serializer-plain:4.25.0", "net.kyori:adventure-text-serializer-legacy:4.25.0", @@ -214,7 +214,7 @@ tasks { exclude("net/kyori/**") } - val offlineJar by registering(ShadowJar::class) { + val offlineJar = register("offlineJar") { configureBaseShadow("offline", emptyArray()) from(sourceSets.main.get().output) @@ -228,12 +228,12 @@ tasks { } -val sourcesJar by tasks.registering(Jar::class) { +val sourcesJar = tasks.register("sourcesJar") { archiveClassifier.set("sources") from(kotlin.sourceSets.main.get().kotlin) } -val javadocJar by tasks.registering(Jar::class, fun Jar.() { +val javadocJar = tasks.register("javadocJar", fun Jar.() { group = JavaBasePlugin.DOCUMENTATION_GROUP description = "Assembles Javadoc JAR" archiveClassifier.set("javadoc") @@ -357,36 +357,25 @@ publishing { } // hangar publish - -fun executeGitCommand(vararg command: String): String { - val byteOut = ByteArrayOutputStream() - exec { - commandLine = listOf("git", *command) - standardOutput = byteOut - } - return byteOut.toString(Charsets.UTF_8.name()).trim() +fun latestCommitMessage(): Provider { + return providers.exec { + commandLine("git", "log", "-1", "--pretty=%B") + }.standardOutput.asText.map(String::trim) } - -fun latestCommitMessage(): String { - return executeGitCommand("log", "-1", "--pretty=%B") -} - -fun changelog(isOnline: Boolean): String { - var changelog = if(isDevBuild) latestCommitMessage() - else System.getenv("RELEASE_CHANGELOG") - - if(!isOnline) { - changelog = "This is an offline version of the plugin. \\\n" + - "This mean that this plugin libraries are shaded into this plugin \\\n" + - "You likely want to use the normal version of this plugin\n\n" + changelog - } - - if(changelog == null || changelog.isEmpty()) { - changelog = "empty changelog" - } +fun changelog(isOnline: Boolean): Provider { + val changelog = if(isDevBuild) latestCommitMessage() + else providers.environmentVariable("RELEASE_CHANGELOG") return changelog + .filter{!it.isEmpty()} + .map { + if(!isOnline) + return@map "This is an offline version of the plugin. \\\n" + + "This mean that this plugin libraries are shaded into this plugin \\\n" + + "You likely want to use the normal version of this plugin\n\n" + it + else return@map it + }.orElse("empty changelog") } hangarPublish { @@ -400,6 +389,7 @@ hangarPublish { channel.set(if (isDevBuild || isPreRelease) devChannel else releaseChannel) changelog.set(changelog(isOnline)) + id.set("CustomAnvil") apiKey.set(System.getenv("HANGAR_API_TOKEN")) diff --git a/defaultconfigs/1.21.11/config.yml b/defaultconfigs/1.21.11/config.yml index c3ea6204..22de446f 100644 --- a/defaultconfigs/1.21.11/config.yml +++ b/defaultconfigs/1.21.11/config.yml @@ -476,6 +476,32 @@ monetary_cost: work_penalty: 1.0 # for work penalty (aka use penalty) recipe: 1.0 # for custom anvil recipe cost +# Chance that an anvil get degraded +# set it to zero if you wish to disable it +anvil_degradation: 0.12 + +# see https://www.digminecraft.com/lists/sound_list_pc.php +# for a list of most of the sounds +anvil_sound: + enabled: true + # The sound are weighted so if there is multiples of them one is selected randomly + # so if you want to add a "rare sound" as an easter egg you can ! + # If invalid, it will be removed from the list. and if empty it will use the default + use: + default: + sound: block.anvil.use + category: blocks + volume: 1.0 + pitch: 1.0 + weight: 1.0 + destroy: + default: + sound: block.anvil.destroy + category: blocks + volume: 1.0 + pitch: 1.0 + weight: 1.0 + # Whether to show debug logging debug_log: false diff --git a/defaultconfigs/1.21.9/config.yml b/defaultconfigs/1.21.9/config.yml index 614c8df0..4d1ae9d6 100644 --- a/defaultconfigs/1.21.9/config.yml +++ b/defaultconfigs/1.21.9/config.yml @@ -468,6 +468,33 @@ monetary_cost: work_penalty: 1.0 # for work penalty (aka use penalty) recipe: 1.0 # for custom anvil recipe cost +# Chance that an anvil get degraded +# set it to zero if you wish to disable it +anvil_degradation: 0.12 + +# see https://www.digminecraft.com/lists/sound_list_pc.php +# for a list of most of the sounds +anvil_sound: + enabled: true + # The sound are weighted so if there is multiples of them one is selected randomly + # so if you want to add a "rare sound" as an easter egg you can ! + # If invalid, it will be removed from the list. and if empty it will use the default + use: + default: + sound: block.anvil.use + category: blocks + volume: 1.0 + pitch: 1.0 + weight: 1.0 + destroy: + default: + sound: block.anvil.destroy + category: blocks + volume: 1.0 + pitch: 1.0 + weight: 1.0 + + # Whether to show debug logging debug_log: false diff --git a/defaultconfigs/1.21/config.yml b/defaultconfigs/1.21/config.yml index a0bcbd86..50b94f1b 100644 --- a/defaultconfigs/1.21/config.yml +++ b/defaultconfigs/1.21/config.yml @@ -456,6 +456,33 @@ monetary_cost: work_penalty: 1.0 # for work penalty (aka use penalty) recipe: 1.0 # for custom anvil recipe cost +# Chance that an anvil get degraded +# set it to zero if you wish to disable it +anvil_degradation: 0.12 + +# see https://www.digminecraft.com/lists/sound_list_pc.php +# for a list of most of the sounds +anvil_sound: + enabled: true + # The sound are weighted so if there is multiples of them one is selected randomly + # so if you want to add a "rare sound" as an easter egg you can ! + # If invalid, it will be removed from the list. and if empty it will use the default + use: + default: + sound: block.anvil.use + category: blocks + volume: 1.0 + pitch: 1.0 + weight: 1.0 + destroy: + default: + sound: block.anvil.destroy + category: blocks + volume: 1.0 + pitch: 1.0 + weight: 1.0 + + # Whether to show debug logging debug_log: false diff --git a/gradle.properties b/gradle.properties index 4397d2e8..b9c47c92 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,5 @@ kotlin.code.style=official +org.gradle.configuration-cache=true # Signing signing.secretKeyRingFile=~/.gnupg/secring.gpg @@ -6,8 +7,8 @@ signing.secretKeyRingFile=~/.gnupg/secring.gpg kotlin.daemon.jvmargs=-Xmx8G # list of nms -subprojects.reobfnms=v1_17R1,v1_18R1,v1_18R2,v1_19R1,v1_19R2,v1_19R3,v1_20R1,v1_20R2,v1_20R3,v1_20R4,v1_21R1,v1_21R2,v1_21R3,v1_21R4,v1_21R5,v1_21R6,v1_21R7 +subprojects.reobfnms=v1_17R1,v1_18R1,v1_18R2 # list of version for hangar release -paperVersion=1.18-26.2 +paperVersion=1.18-1.20.5 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0b55a3bd..8bf5ce26 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/impl/ExcellentEnchant5_4/build.gradle.kts b/impl/ExcellentEnchant5_4/build.gradle.kts index 9fe598b1..e624d159 100644 --- a/impl/ExcellentEnchant5_4/build.gradle.kts +++ b/impl/ExcellentEnchant5_4/build.gradle.kts @@ -2,7 +2,7 @@ group = rootProject.group version = rootProject.version plugins { - kotlin("jvm") version "2.3.0" + kotlin("jvm") version "2.4.0" } repositories { diff --git a/impl/LegacyEcoEnchant/build.gradle.kts b/impl/LegacyEcoEnchant/build.gradle.kts index 83057a73..00ecd1b8 100644 --- a/impl/LegacyEcoEnchant/build.gradle.kts +++ b/impl/LegacyEcoEnchant/build.gradle.kts @@ -2,7 +2,7 @@ group = rootProject.group version = rootProject.version plugins { - kotlin("jvm") version "2.3.0" + kotlin("jvm") version "2.4.0" } // Imitate needed class and method to support legacy version of EcoEnchant diff --git a/libs/ExcellentEnchants/API-5.1.0.jar b/libs/ExcellentEnchants/API-5.1.0.jar new file mode 100644 index 00000000..855724b5 Binary files /dev/null and b/libs/ExcellentEnchants/API-5.1.0.jar differ diff --git a/libs/ExcellentEnchants/Core-5.1.0.jar b/libs/ExcellentEnchants/Core-5.1.0.jar new file mode 100644 index 00000000..8899ac49 Binary files /dev/null and b/libs/ExcellentEnchants/Core-5.1.0.jar differ diff --git a/libs/ExcellentEnchants-4.1.0-striped.jar b/libs/ExcellentEnchants/ExcellentEnchants-4.1.0-striped.jar similarity index 100% rename from libs/ExcellentEnchants-4.1.0-striped.jar rename to libs/ExcellentEnchants/ExcellentEnchants-4.1.0-striped.jar diff --git a/libs/ExcellentEnchants-4.3.3-striped.jar b/libs/ExcellentEnchants/ExcellentEnchants-4.3.3-striped.jar similarity index 100% rename from libs/ExcellentEnchants-4.3.3-striped.jar rename to libs/ExcellentEnchants/ExcellentEnchants-4.3.3-striped.jar diff --git a/libs/ExcellentEnchants/main-2.7.9.jar b/libs/ExcellentEnchants/main-2.7.9.jar new file mode 100644 index 00000000..8ae699ed Binary files /dev/null and b/libs/ExcellentEnchants/main-2.7.9.jar differ diff --git a/nms/nms-common/build.gradle.kts b/nms/nms-common/build.gradle.kts index 950d8072..a75f9477 100644 --- a/nms/nms-common/build.gradle.kts +++ b/nms/nms-common/build.gradle.kts @@ -29,7 +29,7 @@ tasks.withType().configureEach { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_16) } } diff --git a/nms/nms-common/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/util/PaperSpigotUtil.kt b/nms/nms-common/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/util/PlatformUtil.kt similarity index 70% rename from nms/nms-common/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/util/PaperSpigotUtil.kt rename to nms/nms-common/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/util/PlatformUtil.kt index 3f709c7f..aaa218fa 100644 --- a/nms/nms-common/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/util/PaperSpigotUtil.kt +++ b/nms/nms-common/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/util/PlatformUtil.kt @@ -37,7 +37,7 @@ object PlatformUtil { // Lore fun ItemMeta.componentLore(): MutableList { val lore: List? - if(isPaper){ + if (isPaper) { lore = this.lore() } else { val legacyLores = this.lore ?: return ArrayList() @@ -52,49 +52,41 @@ object PlatformUtil { } fun ItemMeta.setComponentLore(lore: List) { - if(isPaper){ + if (isPaper) { this.lore(lore) } else { val legacyLore = ArrayList(lore.size) for (component in lore) { - legacyLore.add(if(component == null) null - else legacy_mm.serialize(component)) + legacyLore.add( + if (component == null) null + else legacy_mm.serialize(component) + ) } this.lore = legacyLore } } - // Display name - private val useCustomName = hasMethod(ItemStack::class.java, "customName") - fun ItemMeta.componentDisplayName(): Component? { - if(useCustomName){ - if(!this.hasCustomName()) return null - return this.customName() - }else if(isPaper){ - if(!this.hasDisplayName()) return null - return this.displayName() - } else { - if(!this.hasDisplayName()) return null + if (!this.hasDisplayName()) return null - val legacy = this.displayName - return legacy_mm.deserialize(legacy) + return if (isPaper) { + this.displayName() + } else { + legacy_mm.deserialize(this.displayName) } } - fun ItemMeta.setComponentDisplayName(component: Component?) { - if(useCustomName){ - this.customName(component) - }else if(isPaper){ + fun ItemMeta.setComponentDisplayName(component: Component?, fallback: String? = null) { + if (isPaper) { this.displayName(component) } else { - if(component == null){ + if (component == null) { this.setDisplayName(null) return } - val legacy = legacy_mm.serialize(component) + val legacy = fallback ?: legacy_mm.serialize(component) this.setDisplayName(legacy) } } diff --git a/nms/nms-paper/build.gradle.kts b/nms/nms-paper/build.gradle.kts index d0e12a76..85a5537e 100644 --- a/nms/nms-paper/build.gradle.kts +++ b/nms/nms-paper/build.gradle.kts @@ -29,7 +29,7 @@ tasks.withType().configureEach { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_18) } } diff --git a/nms/nms-paper/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/datapack/DataPackTester.kt b/nms/nms-paper/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/datapack/DataPackTester.kt index 9003fdf4..4ec2349b 100644 --- a/nms/nms-paper/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/datapack/DataPackTester.kt +++ b/nms/nms-paper/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/datapack/DataPackTester.kt @@ -1,3 +1,4 @@ +@file:Suppress("DEPRECATION", "removal") package xyz.alexcrea.cuanvil.dependency.datapack import io.papermc.paper.datapack.Datapack @@ -21,18 +22,21 @@ object DataPackTester { return Bukkit.getDatapackManager().enabledPacks .stream().map { obj: Datapack -> obj.name } .toList() - } catch (e: NoSuchMethodException) { + } catch (_: NoSuchMethodException) { try { DataPack::class.java.getDeclaredMethod("getKey") - } catch (e: NoSuchMethodException) { + } catch (_: NoSuchMethodException) { System.err.println("Could not find compatible datapack manager") System.err.println("If you are using a datapack that should be compatible with CustomAnvil. It will not get detected...") return emptyList() } return legacyNames - } catch (e: Exception){ + } catch (_: Exception){ // Assume cause UnimplementedOperationException on mock server return Collections.emptyList() + } catch(_: NoSuchMethodError) { + // Idk newer spigot may not have that ? + return Collections.emptyList() } } } diff --git a/nms/nms-paper/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilTitleUtil.kt b/nms/nms-paper/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilTitleUtil.kt index e40e7ede..cf9686c4 100644 --- a/nms/nms-paper/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilTitleUtil.kt +++ b/nms/nms-paper/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilTitleUtil.kt @@ -12,6 +12,7 @@ object AnvilTitleUtil { private val runTaskMap = HashMap() + @Suppress("DEPRECATION") private fun actualRename(view: InventoryView, name: String, player: HumanEntity, anvilDialog: AnvilRenameDialog) { runTaskMap.remove(player.uniqueId) if (view.title == name) return diff --git a/nms/v1_17R1/build.gradle.kts b/nms/v1_17R1/build.gradle.kts index c354b1ce..45599335 100644 --- a/nms/v1_17R1/build.gradle.kts +++ b/nms/v1_17R1/build.gradle.kts @@ -29,7 +29,7 @@ tasks.withType().configureEach { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_16) } } diff --git a/nms/v1_18R1/build.gradle.kts b/nms/v1_18R1/build.gradle.kts index 44873d5a..9c334f3c 100644 --- a/nms/v1_18R1/build.gradle.kts +++ b/nms/v1_18R1/build.gradle.kts @@ -29,7 +29,7 @@ tasks.withType().configureEach { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_17) } } diff --git a/nms/v1_18R2/build.gradle.kts b/nms/v1_18R2/build.gradle.kts index cf349ec6..3d31ad63 100644 --- a/nms/v1_18R2/build.gradle.kts +++ b/nms/v1_18R2/build.gradle.kts @@ -29,7 +29,7 @@ tasks.withType().configureEach { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_17) } } diff --git a/nms/v1_19R1/build.gradle.kts b/nms/v1_19R1/build.gradle.kts index 9791b9b9..fdd9d07a 100644 --- a/nms/v1_19R1/build.gradle.kts +++ b/nms/v1_19R1/build.gradle.kts @@ -29,7 +29,7 @@ tasks.withType().configureEach { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_17) } } diff --git a/nms/v1_19R2/build.gradle.kts b/nms/v1_19R2/build.gradle.kts index 88f1a8ad..bab486de 100644 --- a/nms/v1_19R2/build.gradle.kts +++ b/nms/v1_19R2/build.gradle.kts @@ -29,7 +29,7 @@ tasks.withType().configureEach { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_17) } } diff --git a/nms/v1_19R3/build.gradle.kts b/nms/v1_19R3/build.gradle.kts index 3d609af4..41d70647 100644 --- a/nms/v1_19R3/build.gradle.kts +++ b/nms/v1_19R3/build.gradle.kts @@ -29,7 +29,7 @@ tasks.withType().configureEach { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_17) } } diff --git a/nms/v1_20R1/build.gradle.kts b/nms/v1_20R1/build.gradle.kts index 67b46b5e..3bec3f81 100644 --- a/nms/v1_20R1/build.gradle.kts +++ b/nms/v1_20R1/build.gradle.kts @@ -29,7 +29,7 @@ tasks.withType().configureEach { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_18) } } diff --git a/nms/v1_20R2/build.gradle.kts b/nms/v1_20R2/build.gradle.kts index e8417cd8..0b28d317 100644 --- a/nms/v1_20R2/build.gradle.kts +++ b/nms/v1_20R2/build.gradle.kts @@ -29,7 +29,7 @@ tasks.withType().configureEach { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_18) } } diff --git a/nms/v1_20R3/build.gradle.kts b/nms/v1_20R3/build.gradle.kts index c49ff48d..2a6d822d 100644 --- a/nms/v1_20R3/build.gradle.kts +++ b/nms/v1_20R3/build.gradle.kts @@ -29,7 +29,7 @@ tasks.withType().configureEach { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_18) } } diff --git a/nms/v1_20R4/build.gradle.kts b/nms/v1_20R4/build.gradle.kts index 3b98361e..821c3cd3 100644 --- a/nms/v1_20R4/build.gradle.kts +++ b/nms/v1_20R4/build.gradle.kts @@ -29,7 +29,7 @@ tasks.withType().configureEach { kotlin { compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0) + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4) jvmTarget.set(JvmTarget.JVM_18) } } diff --git a/nms/v1_21R1/.gitignore b/nms/v1_21R1/.gitignore deleted file mode 100644 index 47374f17..00000000 --- a/nms/v1_21R1/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_21R1/build.gradle.kts b/nms/v1_21R1/build.gradle.kts deleted file mode 100644 index bf2152cc..00000000 --- a/nms/v1_21R1/build.gradle.kts +++ /dev/null @@ -1,35 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -group = rootProject.group -version = rootProject.version - -plugins { - id("io.papermc.paperweight.userdev") -} - -dependencies { - implementation(project(":nms:nms-common")) - - // Used for nms - paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT") -} - -repositories { - maven("https://repo.papermc.io/repository/maven-public/") - -} - -// Set target version -tasks.withType().configureEach { - sourceCompatibility = "21" - targetCompatibility = "21" - - options.encoding = "UTF-8" -} - -kotlin { - compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) - jvmTarget.set(JvmTarget.JVM_21) - } -} diff --git a/nms/v1_21R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R1_PacketManager.kt b/nms/v1_21R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R1_PacketManager.kt deleted file mode 100644 index 4ea99508..00000000 --- a/nms/v1_21R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R1_PacketManager.kt +++ /dev/null @@ -1,33 +0,0 @@ -package xyz.alexcrea.cuanvil.dependency.packet.versions - -import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket -import net.minecraft.world.entity.player.Abilities -import org.bukkit.craftbukkit.entity.CraftPlayer -import org.bukkit.entity.Player -import xyz.alexcrea.cuanvil.dependency.packet.PacketManager -import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase - -class V1_21R1_PacketManager : PacketManagerBase(), PacketManager { - override val canSetInstantBuild: Boolean - get() = true - - override fun setInstantBuild(player: Player, instantBuild: Boolean) { - val nmsPlayer = (player as CraftPlayer).handle - val playerAbilities = nmsPlayer.abilities - val sendedAbilities: Abilities - if (playerAbilities.instabuild == instantBuild) { - sendedAbilities = playerAbilities - } else { - sendedAbilities = Abilities() - sendedAbilities.invulnerable = playerAbilities.invulnerable - sendedAbilities.flying = playerAbilities.flying - sendedAbilities.mayfly = playerAbilities.mayfly - sendedAbilities.instabuild = instantBuild - sendedAbilities.mayBuild = playerAbilities.mayBuild - sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed - sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed - } - val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities) - nmsPlayer.connection.send(packet) - } -} diff --git a/nms/v1_21R2/.gitignore b/nms/v1_21R2/.gitignore deleted file mode 100644 index 47374f17..00000000 --- a/nms/v1_21R2/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_21R2/build.gradle.kts b/nms/v1_21R2/build.gradle.kts deleted file mode 100644 index e65f6fd8..00000000 --- a/nms/v1_21R2/build.gradle.kts +++ /dev/null @@ -1,35 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -group = rootProject.group -version = rootProject.version - -plugins { - id("io.papermc.paperweight.userdev") -} - -dependencies { - implementation(project(":nms:nms-common")) - - // Used for nms - paperweight.paperDevBundle("1.21.3-R0.1-SNAPSHOT") -} - -repositories { - maven("https://repo.papermc.io/repository/maven-public/") - -} - -// Set target version -tasks.withType().configureEach { - sourceCompatibility = "21" - targetCompatibility = "21" - - options.encoding = "UTF-8" -} - -kotlin { - compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) - jvmTarget.set(JvmTarget.JVM_21) - } -} diff --git a/nms/v1_21R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R2_PacketManager.kt b/nms/v1_21R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R2_PacketManager.kt deleted file mode 100644 index 9d88c20b..00000000 --- a/nms/v1_21R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R2_PacketManager.kt +++ /dev/null @@ -1,33 +0,0 @@ -package xyz.alexcrea.cuanvil.dependency.packet.versions - -import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket -import net.minecraft.world.entity.player.Abilities -import org.bukkit.craftbukkit.entity.CraftPlayer -import org.bukkit.entity.Player -import xyz.alexcrea.cuanvil.dependency.packet.PacketManager -import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase - -class V1_21R2_PacketManager : PacketManagerBase(), PacketManager { - override val canSetInstantBuild: Boolean - get() = true - - override fun setInstantBuild(player: Player, instantBuild: Boolean) { - val nmsPlayer = (player as CraftPlayer).handle - val playerAbilities = nmsPlayer.abilities - val sendedAbilities: Abilities - if (playerAbilities.instabuild == instantBuild) { - sendedAbilities = playerAbilities - } else { - sendedAbilities = Abilities() - sendedAbilities.invulnerable = playerAbilities.invulnerable - sendedAbilities.flying = playerAbilities.flying - sendedAbilities.mayfly = playerAbilities.mayfly - sendedAbilities.instabuild = instantBuild - sendedAbilities.mayBuild = playerAbilities.mayBuild - sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed - sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed - } - val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities) - nmsPlayer.connection.send(packet) - } -} diff --git a/nms/v1_21R3/.gitignore b/nms/v1_21R3/.gitignore deleted file mode 100644 index 47374f17..00000000 --- a/nms/v1_21R3/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_21R3/build.gradle.kts b/nms/v1_21R3/build.gradle.kts deleted file mode 100644 index d06816cc..00000000 --- a/nms/v1_21R3/build.gradle.kts +++ /dev/null @@ -1,35 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -group = rootProject.group -version = rootProject.version - -plugins { - id("io.papermc.paperweight.userdev") -} - -dependencies { - implementation(project(":nms:nms-common")) - - // Used for nms - paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT") -} - -repositories { - maven("https://repo.papermc.io/repository/maven-public/") - -} - -// Set target version -tasks.withType().configureEach { - sourceCompatibility = "21" - targetCompatibility = "21" - - options.encoding = "UTF-8" -} - -kotlin { - compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) - jvmTarget.set(JvmTarget.JVM_21) - } -} diff --git a/nms/v1_21R3/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R3_PacketManager.kt b/nms/v1_21R3/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R3_PacketManager.kt deleted file mode 100644 index 0f581d96..00000000 --- a/nms/v1_21R3/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R3_PacketManager.kt +++ /dev/null @@ -1,33 +0,0 @@ -package xyz.alexcrea.cuanvil.dependency.packet.versions - -import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket -import net.minecraft.world.entity.player.Abilities -import org.bukkit.craftbukkit.entity.CraftPlayer -import org.bukkit.entity.Player -import xyz.alexcrea.cuanvil.dependency.packet.PacketManager -import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase - -class V1_21R3_PacketManager : PacketManagerBase(), PacketManager { - override val canSetInstantBuild: Boolean - get() = true - - override fun setInstantBuild(player: Player, instantBuild: Boolean) { - val nmsPlayer = (player as CraftPlayer).handle - val playerAbilities = nmsPlayer.abilities - val sendedAbilities: Abilities - if (playerAbilities.instabuild == instantBuild) { - sendedAbilities = playerAbilities - } else { - sendedAbilities = Abilities() - sendedAbilities.invulnerable = playerAbilities.invulnerable - sendedAbilities.flying = playerAbilities.flying - sendedAbilities.mayfly = playerAbilities.mayfly - sendedAbilities.instabuild = instantBuild - sendedAbilities.mayBuild = playerAbilities.mayBuild - sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed - sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed - } - val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities) - nmsPlayer.connection.send(packet) - } -} diff --git a/nms/v1_21R4/.gitignore b/nms/v1_21R4/.gitignore deleted file mode 100644 index 47374f17..00000000 --- a/nms/v1_21R4/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_21R4/build.gradle.kts b/nms/v1_21R4/build.gradle.kts deleted file mode 100644 index 8bd22b9f..00000000 --- a/nms/v1_21R4/build.gradle.kts +++ /dev/null @@ -1,34 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -group = rootProject.group -version = rootProject.version - -plugins { - id("io.papermc.paperweight.userdev") -} - -dependencies { - implementation(project(":nms:nms-common")) - - // Used for nms - paperweight.paperDevBundle("1.21.5-R0.1-SNAPSHOT") -} - -repositories { - maven("https://repo.papermc.io/repository/maven-public/") -} - -// Set target version -tasks.withType().configureEach { - sourceCompatibility = "21" - targetCompatibility = "21" - - options.encoding = "UTF-8" -} - -kotlin { - compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) - jvmTarget.set(JvmTarget.JVM_21) - } -} diff --git a/nms/v1_21R4/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R4_PacketManager.kt b/nms/v1_21R4/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R4_PacketManager.kt deleted file mode 100644 index b1236256..00000000 --- a/nms/v1_21R4/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R4_PacketManager.kt +++ /dev/null @@ -1,33 +0,0 @@ -package xyz.alexcrea.cuanvil.dependency.packet.versions - -import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket -import net.minecraft.world.entity.player.Abilities -import org.bukkit.craftbukkit.entity.CraftPlayer -import org.bukkit.entity.Player -import xyz.alexcrea.cuanvil.dependency.packet.PacketManager -import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase - -class V1_21R4_PacketManager : PacketManagerBase(), PacketManager { - override val canSetInstantBuild: Boolean - get() = true - - override fun setInstantBuild(player: Player, instantBuild: Boolean) { - val nmsPlayer = (player as CraftPlayer).handle - val playerAbilities = nmsPlayer.abilities - val sendedAbilities: Abilities - if (playerAbilities.instabuild == instantBuild) { - sendedAbilities = playerAbilities - } else { - sendedAbilities = Abilities() - sendedAbilities.invulnerable = playerAbilities.invulnerable - sendedAbilities.flying = playerAbilities.flying - sendedAbilities.mayfly = playerAbilities.mayfly - sendedAbilities.instabuild = instantBuild - sendedAbilities.mayBuild = playerAbilities.mayBuild - sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed - sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed - } - val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities) - nmsPlayer.connection.send(packet) - } -} diff --git a/nms/v1_21R5/.gitignore b/nms/v1_21R5/.gitignore deleted file mode 100644 index 47374f17..00000000 --- a/nms/v1_21R5/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_21R5/build.gradle.kts b/nms/v1_21R5/build.gradle.kts deleted file mode 100644 index e7f7c47c..00000000 --- a/nms/v1_21R5/build.gradle.kts +++ /dev/null @@ -1,34 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -group = rootProject.group -version = rootProject.version - -plugins { - id("io.papermc.paperweight.userdev") -} - -dependencies { - implementation(project(":nms:nms-common")) - - // Used for nms - paperweight.paperDevBundle("1.21.6-R0.1-SNAPSHOT") -} - -repositories { - maven("https://repo.papermc.io/repository/maven-public/") -} - -// Set target version -tasks.withType().configureEach { - sourceCompatibility = "21" - targetCompatibility = "21" - - options.encoding = "UTF-8" -} - -kotlin { - compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) - jvmTarget.set(JvmTarget.JVM_21) - } -} diff --git a/nms/v1_21R5/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R5_PacketManager.kt b/nms/v1_21R5/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R5_PacketManager.kt deleted file mode 100644 index 561a6af4..00000000 --- a/nms/v1_21R5/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R5_PacketManager.kt +++ /dev/null @@ -1,33 +0,0 @@ -package xyz.alexcrea.cuanvil.dependency.packet.versions - -import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket -import net.minecraft.world.entity.player.Abilities -import org.bukkit.craftbukkit.entity.CraftPlayer -import org.bukkit.entity.Player -import xyz.alexcrea.cuanvil.dependency.packet.PacketManager -import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase - -class V1_21R5_PacketManager : PacketManagerBase(), PacketManager { - override val canSetInstantBuild: Boolean - get() = true - - override fun setInstantBuild(player: Player, instantBuild: Boolean) { - val nmsPlayer = (player as CraftPlayer).handle - val playerAbilities = nmsPlayer.abilities - val sendedAbilities: Abilities - if (playerAbilities.instabuild == instantBuild) { - sendedAbilities = playerAbilities - } else { - sendedAbilities = Abilities() - sendedAbilities.invulnerable = playerAbilities.invulnerable - sendedAbilities.flying = playerAbilities.flying - sendedAbilities.mayfly = playerAbilities.mayfly - sendedAbilities.instabuild = instantBuild - sendedAbilities.mayBuild = playerAbilities.mayBuild - sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed - sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed - } - val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities) - nmsPlayer.connection.send(packet) - } -} diff --git a/nms/v1_21R6/.gitignore b/nms/v1_21R6/.gitignore deleted file mode 100644 index 47374f17..00000000 --- a/nms/v1_21R6/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_21R6/build.gradle.kts b/nms/v1_21R6/build.gradle.kts deleted file mode 100644 index 3189b5cb..00000000 --- a/nms/v1_21R6/build.gradle.kts +++ /dev/null @@ -1,34 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -group = rootProject.group -version = rootProject.version - -plugins { - id("io.papermc.paperweight.userdev") -} - -dependencies { - implementation(project(":nms:nms-common")) - - // Used for nms - paperweight.paperDevBundle("1.21.10-R0.1-SNAPSHOT") -} - -repositories { - maven("https://repo.papermc.io/repository/maven-public/") -} - -// Set target version -tasks.withType().configureEach { - sourceCompatibility = "21" - targetCompatibility = "21" - - options.encoding = "UTF-8" -} - -kotlin { - compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) - jvmTarget.set(JvmTarget.JVM_21) - } -} diff --git a/nms/v1_21R6/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/PaperPacketManager.kt b/nms/v1_21R6/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/PaperPacketManager.kt deleted file mode 100644 index ee006666..00000000 --- a/nms/v1_21R6/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/PaperPacketManager.kt +++ /dev/null @@ -1,33 +0,0 @@ -package xyz.alexcrea.cuanvil.dependency.packet.versions - -import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket -import net.minecraft.world.entity.player.Abilities -import org.bukkit.craftbukkit.entity.CraftPlayer -import org.bukkit.entity.Player -import xyz.alexcrea.cuanvil.dependency.packet.PacketManager -import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase - -class V1_21R6_PacketManager : PacketManagerBase(), PacketManager { - override val canSetInstantBuild: Boolean - get() = true - - override fun setInstantBuild(player: Player, instantBuild: Boolean) { - val nmsPlayer = (player as CraftPlayer).handle - val playerAbilities = nmsPlayer.abilities - val sendedAbilities: Abilities - if (playerAbilities.instabuild == instantBuild) { - sendedAbilities = playerAbilities - } else { - sendedAbilities = Abilities() - sendedAbilities.invulnerable = playerAbilities.invulnerable - sendedAbilities.flying = playerAbilities.flying - sendedAbilities.mayfly = playerAbilities.mayfly - sendedAbilities.instabuild = instantBuild - sendedAbilities.mayBuild = playerAbilities.mayBuild - sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed - sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed - } - val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities) - nmsPlayer.connection.send(packet) - } -} \ No newline at end of file diff --git a/nms/v1_21R7/.gitignore b/nms/v1_21R7/.gitignore deleted file mode 100644 index 47374f17..00000000 --- a/nms/v1_21R7/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_21R7/build.gradle.kts b/nms/v1_21R7/build.gradle.kts deleted file mode 100644 index 91c3111a..00000000 --- a/nms/v1_21R7/build.gradle.kts +++ /dev/null @@ -1,34 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -group = rootProject.group -version = rootProject.version - -plugins { - id("io.papermc.paperweight.userdev") -} - -dependencies { - implementation(project(":nms:nms-common")) - - // Used for nms - paperweight.paperDevBundle("1.21.11-R0.1-SNAPSHOT") -} - -repositories { - maven("https://repo.papermc.io/repository/maven-public/") -} - -// Set target version -tasks.withType().configureEach { - sourceCompatibility = "21" - targetCompatibility = "21" - - options.encoding = "UTF-8" -} - -kotlin { - compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2) - jvmTarget.set(JvmTarget.JVM_21) - } -} diff --git a/nms/v1_21R7/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R7_PacketManager.kt b/nms/v1_21R7/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R7_PacketManager.kt deleted file mode 100644 index 59ae9ceb..00000000 --- a/nms/v1_21R7/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R7_PacketManager.kt +++ /dev/null @@ -1,33 +0,0 @@ -package xyz.alexcrea.cuanvil.dependency.packet.versions - -import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket -import net.minecraft.world.entity.player.Abilities -import org.bukkit.craftbukkit.entity.CraftPlayer -import org.bukkit.entity.Player -import xyz.alexcrea.cuanvil.dependency.packet.PacketManager -import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase - -class V1_21R7_PacketManager : PacketManagerBase(), PacketManager { - override val canSetInstantBuild: Boolean - get() = true - - override fun setInstantBuild(player: Player, instantBuild: Boolean) { - val nmsPlayer = (player as CraftPlayer).handle - val playerAbilities = nmsPlayer.abilities - val sendedAbilities: Abilities - if (playerAbilities.instabuild == instantBuild) { - sendedAbilities = playerAbilities - } else { - sendedAbilities = Abilities() - sendedAbilities.invulnerable = playerAbilities.invulnerable - sendedAbilities.flying = playerAbilities.flying - sendedAbilities.mayfly = playerAbilities.mayfly - sendedAbilities.instabuild = instantBuild - sendedAbilities.mayBuild = playerAbilities.mayBuild - sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed - sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed - } - val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities) - nmsPlayer.connection.send(packet) - } -} \ No newline at end of file diff --git a/src/main/java/xyz/alexcrea/cuanvil/enchant/CAEnchantmentRegistry.java b/src/main/java/xyz/alexcrea/cuanvil/enchant/CAEnchantmentRegistry.java index 0b2b34dd..b1f9a7b8 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/enchant/CAEnchantmentRegistry.java +++ b/src/main/java/xyz/alexcrea/cuanvil/enchant/CAEnchantmentRegistry.java @@ -99,8 +99,7 @@ public class CAEnchantmentRegistry { if ((!hasWarnedRegistering) && byNameMap.containsKey(enchantment.getName())) { hasWarnedRegistering = true; - CustomAnvil.instance.getLogger().log(Level.WARNING, - "Duplicate registered enchantment name. Please check that configuration is using namespace."); + CustomAnvil.Companion.log("Duplicate registered enchantment name. Please check that configuration is using namespace."); } byKeyMap.put(enchantment.getKey(), enchantment); diff --git a/src/main/kotlin/io/delilaheve/CustomAnvil.kt b/src/main/kotlin/io/delilaheve/CustomAnvil.kt index 906e023f..762c8b63 100644 --- a/src/main/kotlin/io/delilaheve/CustomAnvil.kt +++ b/src/main/kotlin/io/delilaheve/CustomAnvil.kt @@ -11,7 +11,6 @@ import xyz.alexcrea.cuanvil.command.EditConfigExecutor import xyz.alexcrea.cuanvil.command.ReloadExecutor import xyz.alexcrea.cuanvil.config.ConfigHolder import xyz.alexcrea.cuanvil.dependency.DependencyManager -import xyz.alexcrea.cuanvil.dependency.MinecraftVersionUtil import xyz.alexcrea.cuanvil.dependency.economy.EconomyManager import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry @@ -25,6 +24,7 @@ import xyz.alexcrea.cuanvil.update.ModrinthUpdateChecker import xyz.alexcrea.cuanvil.update.PluginSetDefault import xyz.alexcrea.cuanvil.update.UpdateHandler import xyz.alexcrea.cuanvil.update.UpdateUtils +import xyz.alexcrea.cuanvil.update.Version import xyz.alexcrea.cuanvil.util.MetricsUtil import java.io.File import java.io.FileReader @@ -136,7 +136,7 @@ open class CustomAnvil : JavaPlugin() { override fun onEnable() { instance = this try { - legacyCheck() + if(legacyCheck()) return } catch (e: Exception) { logger.log(Level.SEVERE, "error trying to check for legacy system", e) MetricsUtil.trackError(e) @@ -202,7 +202,16 @@ open class CustomAnvil : JavaPlugin() { } } - private fun legacyCheck() { + private fun legacyCheck(): Boolean { + val currentVersion = UpdateUtils.currentMinecraftVersion() + if (currentVersion.greaterEqual(Version(1, 21, 0)) + && !DependencyManager.inTesting + && !"true".equals(System.getenv("CUSTOM_ANVIL_BYPASS_LEGACY_CHECK"), true)) { + logger.warning("You are running a Minecraft version above or equal to 1.21.0") + logger.warning("Please use CustomAnvil v2 instead if you wish to use the plugin with this version.") + Bukkit.getPluginManager().disablePlugin(this) + return true + } // Disable old plugin name if exist val potentialPlugin = Bukkit.getPluginManager().getPlugin("UnsafeEnchantsPlus") if (potentialPlugin != null) { @@ -215,10 +224,6 @@ open class CustomAnvil : JavaPlugin() { if(!isPaper) { logger.warning("It seems you are using spigot") logger.warning("Please take notice that spigot is less supported than paper and derivatives") - if(MinecraftVersionUtil.isTooNewForSpigot) { - logger.warning("If replace too expensive is not working this is likely because of spigot") - logger.warning("As native nms is not supported for spigot starting 26.1") - } } val loader = if(isPaper) "paper" else "spigot" @@ -238,6 +243,7 @@ open class CustomAnvil : JavaPlugin() { logger.warning("An update may be available: $latestVer") } + return false } private fun registerListeners() { diff --git a/src/main/kotlin/io/delilaheve/util/ItemUtil.kt b/src/main/kotlin/io/delilaheve/util/ItemUtil.kt index 02c8475e..dba79b28 100644 --- a/src/main/kotlin/io/delilaheve/util/ItemUtil.kt +++ b/src/main/kotlin/io/delilaheve/util/ItemUtil.kt @@ -6,7 +6,6 @@ import org.bukkit.inventory.ItemStack import org.bukkit.inventory.meta.Damageable import xyz.alexcrea.cuanvil.update.UpdateUtils import xyz.alexcrea.cuanvil.util.MaterialUtil.customType -import xyz.alexcrea.cuanvil.util.MaxDamageCheckerUtil import kotlin.math.ceil import kotlin.math.max import kotlin.math.min @@ -21,13 +20,6 @@ object ItemUtil { */ fun ItemStack.isEnchantedBook() = type == ENCHANTED_BOOK - private fun maxDamage(type: Material, damageable: Damageable): Int { - val ver = UpdateUtils.currentMinecraftVersion() - if(ver.major <= 1 && ver.minor <= 20 && ver.patch < 5) return type.maxDurability.toInt() - - return MaxDamageCheckerUtil.getMaxDamage(type, damageable) - } - /** * Set this [ItemStack]s durability from a combination of the * [first] and [second] item's durability values @@ -40,7 +32,7 @@ object ItemUtil { val meta = itemMeta if(meta !is Damageable) return false - val maxDamage = maxDamage(type, meta) + val maxDamage = type.maxDurability.toInt() val damage = (first.itemMeta as? Damageable)?.damage ?: 0 if (damage == 0) return false @@ -83,6 +75,6 @@ object ItemUtil { * The two items should either be the same type, or, the [other] is a book */ fun ItemStack.canMergeWith( - other: ItemStack? - ) = (other != null) && (customType == other.customType || (other.isEnchantedBook())) + other: ItemStack + ) = customType == other.customType || (other.isEnchantedBook()) } diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/anvil/AnvilMergeLogic.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/anvil/AnvilMergeLogic.kt index fd7055ed..f398fd97 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/anvil/AnvilMergeLogic.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/anvil/AnvilMergeLogic.kt @@ -6,6 +6,7 @@ import io.delilaheve.util.EnchantmentUtil.combineWith import io.delilaheve.util.ItemUtil.isEnchantedBook import io.delilaheve.util.ItemUtil.repairFrom import io.delilaheve.util.ItemUtil.unitRepair +import net.kyori.adventure.text.Component import org.bukkit.ChatColor import org.bukkit.Material import org.bukkit.entity.HumanEntity @@ -17,6 +18,7 @@ import org.bukkit.inventory.meta.ItemMeta import org.bukkit.persistence.PersistentDataType import xyz.alexcrea.cuanvil.api.EnchantmentApi import xyz.alexcrea.cuanvil.dependency.DependencyManager +import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil.setComponentDisplayName import xyz.alexcrea.cuanvil.dialog.AnvilRenameDialog import xyz.alexcrea.cuanvil.enchant.CAEnchantment import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe @@ -139,11 +141,12 @@ object AnvilMergeLogic { private fun handleRename(resultItem: ItemStack, inventory: AnvilInventory, player: HumanEntity): Int { // Can be null var renameText = ChatColor.stripColor(inventory.renameText) + var component: Component? = null var sumCost = 0 var useColor = false if (ConfigOptions.renameColorPossible && renameText != null) { - val component = AnvilColorUtil.handleColor( + component = AnvilColorUtil.handleColor( renameText, AnvilColorUtil.renamePermission(player) ) @@ -170,7 +173,11 @@ object AnvilMergeLogic { renameText == CasedStringUtil.snakeToUpperSpacedCase(resultItem.type.name.lowercase()) ) ) { - it.setDisplayName(renameText) + if (component == null) + component = if (renameText == null || renameText.isEmpty()) null + else Component.text(renameText) + it.setComponentDisplayName(component, renameText) + processDialogPCD(it, player) resultItem.itemMeta = it diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/config/AnvilFinishOptions.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/config/AnvilFinishOptions.kt new file mode 100644 index 00000000..4cda8d83 --- /dev/null +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/config/AnvilFinishOptions.kt @@ -0,0 +1,146 @@ +package xyz.alexcrea.cuanvil.config + +import io.delilaheve.CustomAnvil +import org.bukkit.NamespacedKey +import org.bukkit.Registry +import org.bukkit.Sound +import org.bukkit.SoundCategory +import org.bukkit.configuration.ConfigurationSection +import java.util.Random +import java.util.logging.Level + +object AnvilFinishOptions { + + data class ConfiguredSound( + val sound: Sound, + val category: SoundCategory, + val volume: Float, + val pitch: Float, + val weight: Double, + ) + + // Paths + private const val SOUND_ENABLED = "anvil_sound.enabled" + + private const val USE_SOUNDS_ROOT = "anvil_sound.use" + private const val DESTROY_SOUNDS_ROOT = "anvil_sound.destroy" + + private const val ANVIL_DEGRADATION_PATH = "anvil_degradation" + + // Defaults + private const val DEFAULT_SOUND_ENABLED = true + private val DEFAULT_USE_SOUND = ConfiguredSound( + Sound.BLOCK_ANVIL_USE, + SoundCategory.BLOCKS, + 1.0f, + 1.0f, + 1.0, + ) + + private val DEFAULT_DESTROY_SOUND = ConfiguredSound( + Sound.BLOCK_ANVIL_DESTROY, + SoundCategory.BLOCKS, + 1.0f, + 1.0f, + 1.0, + ) + private const val DEFAULT_ANVIL_DEGRADATION_PATH = 0.12 + + // Others + private val RANDOM = Random() + + // Fetch + val sound_enabled: Boolean + get() { + return ConfigHolder.DEFAULT_CONFIG + .config + .getBoolean(SOUND_ENABLED, DEFAULT_SOUND_ENABLED) + } + + fun getAnvilSound(wasDestroyed: Boolean): ConfiguredSound { + return if(wasDestroyed) + getRandomDestroySound() + else getRandomUseSound() + } + + val degradation_chance: Double + get() { + return ConfigHolder.DEFAULT_CONFIG + .config + .getDouble(ANVIL_DEGRADATION_PATH, DEFAULT_ANVIL_DEGRADATION_PATH) + } + + // Utils + private fun getRandomUseSound(): ConfiguredSound { + return fromListing(USE_SOUNDS_ROOT, DEFAULT_USE_SOUND) + } + + private fun getRandomDestroySound(): ConfiguredSound { + return fromListing(DESTROY_SOUNDS_ROOT, DEFAULT_DESTROY_SOUND) + } + + private fun fromListing(path: String, default: ConfiguredSound): ConfiguredSound { + val section = ConfigHolder.DEFAULT_CONFIG + .config.getConfigurationSection(path) ?: return default + + val list = readSounds(section) + return weightedRandom(list, default) + } + + private fun readSounds(section: ConfigurationSection): List { + val sounds = ArrayList() + + for (key in section.getKeys(false)) { + if(!section.isConfigurationSection(key)) continue + + val result = readSound(section.getConfigurationSection(key)!!) + if(result == null) { + CustomAnvil.instance.logger.warning("Couldn't read sounds for key $key") + continue + } + + sounds.add(result) + } + return sounds + } + + private fun readSound(section: ConfigurationSection): ConfiguredSound? { + val name = section.getString("sound", null)?: return null + val key = NamespacedKey.fromString(name)?: return null + val sound = Registry.SOUNDS.get(key)?: return null + + val categoryName = section.getString("category", null)?: return null + val category = try { + SoundCategory.valueOf(categoryName.uppercase()) + } catch (_: IllegalArgumentException) { + return null + } + + val volume = section.getDouble("volume", 1.0).toFloat() + val pitch = section.getDouble("pitch", 1.0).toFloat() + val weight = section.getDouble("weight", 1.0) + if(weight <= 0) return null + + return ConfiguredSound(sound, category, volume, pitch, weight) + } + + private fun weightedRandom(sounds: List, default: ConfiguredSound): ConfiguredSound { + if(sounds.isEmpty()) return default + + val weightSum = sounds.sumOf { it.weight } + if(weightSum == .0) return sounds.first() + + val selectedWeight = RANDOM.nextDouble(weightSum) + + var currentSum = .0 + sounds.forEach { + currentSum += it.weight + if(currentSum > selectedWeight) return it + } + + // What ? how + CustomAnvil.instance.logger.log(Level.SEVERE, "Something very... very wrong happen on sound handling. please report this to the developer") + return default + } + +} \ No newline at end of file diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/DependencyManager.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/DependencyManager.kt index 3d5b8e86..e736a8fa 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/DependencyManager.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/DependencyManager.kt @@ -33,7 +33,7 @@ import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil.componentLore import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_OUTPUT_SLOT import xyz.alexcrea.cuanvil.util.MetricsUtil.trackError -import java.lang.reflect.Constructor +import java.lang.IllegalStateException import java.util.logging.Level object DependencyManager { @@ -42,8 +42,11 @@ object DependencyManager { lateinit var packetManager: PacketManager var externGuiTester: GenericExternGuiTester = GenericExternGuiTester() + val inTesting = externGuiTester.isInTest() + var enchantmentSquaredCompatibility: EnchantmentSquaredDependency? = null var ecoEnchantCompatibility: EcoEnchantDependency? = null + var hasEcoItem: Boolean = false var excellentEnchantsCompatibility: ExcellentEnchantsDependency? = null var disenchantmentCompatibility: DisenchantmentDependency? = null @@ -80,6 +83,10 @@ object DependencyManager { ecoEnchantCompatibility = EcoEnchantDependency(pluginManager.getPlugin("EcoEnchants")!!) ecoEnchantCompatibility!!.disableAnvilListener() } + // EcoItem check + if (pluginManager.isPluginEnabled("EcoItems")) { + hasEcoItem = true + } // Excellent Enchants dependency if (pluginManager.isPluginEnabled("ExcellentEnchants")) { @@ -335,10 +342,14 @@ object DependencyManager { private val prepareAnvilConstructor = - PrepareAnvilEvent::class.java.constructors.first() as Constructor + PrepareAnvilEvent::class.java.constructors.first() fun createFakeEvent(view: InventoryView, result: ItemStack?): PrepareAnvilEvent { - return prepareAnvilConstructor.newInstance(view, result) + val result = prepareAnvilConstructor.newInstance(view, result) + if(result !is PrepareAnvilEvent) + throw IllegalStateException("Could not create a PrepareAnvilEvent ?") + + return result } } diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/MinecraftVersionUtil.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/MinecraftVersionUtil.kt index cbd22095..5d333e29 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/MinecraftVersionUtil.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/MinecraftVersionUtil.kt @@ -51,8 +51,4 @@ object MinecraftVersionUtil { } } - val isTooNewForSpigot: Boolean get() { - return UpdateUtils.currentMinecraftVersion().major != 1 - } - } \ No newline at end of file diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/datapack/DataPackDependency.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/datapack/DataPackDependency.kt index 6d544565..af3ce203 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/datapack/DataPackDependency.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/datapack/DataPackDependency.kt @@ -223,7 +223,11 @@ object DataPackDependency { private fun setEnchantAsAll(ench: String) { // We assume current is not null and of type CABukkitEnchantment - val current = EnchantmentApi.getByKey(NamespacedKey.fromString(ench)!!) as CABukkitEnchantment + val current = EnchantmentApi.getByKey(NamespacedKey.fromString(ench)!!) as? CABukkitEnchantment + if(current == null) { + CustomAnvil.instance.logger.warning("Could not find enchant $ench") + return + } // We need to replace current wrapped enchantment with the all conflict wrapper EnchantmentApi.unregisterEnchantment(current) diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/economy/VaultEconomyManager.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/economy/VaultEconomyManager.kt index 058485e2..23d22b52 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/economy/VaultEconomyManager.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/economy/VaultEconomyManager.kt @@ -1,3 +1,5 @@ +@file:Suppress("DEPRECATION") + package xyz.alexcrea.cuanvil.dependency.economy import net.milkbowl.vault.economy.Economy diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/PacketManagerSelector.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/PacketManagerSelector.kt index d74ef089..69ca28cc 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/PacketManagerSelector.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/PacketManagerSelector.kt @@ -12,7 +12,7 @@ object PacketManagerSelector { fun selectPacketManager(forceProtocolib: Boolean): PacketManager { // Try to find version - if(DependencyManager.externGuiTester.isInTest()) + if(DependencyManager.inTesting) return NoPacketManager() return if (forceProtocolib) diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/EcoEnchantDependency.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/EcoEnchantDependency.kt index 079d5707..78bc9d13 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/EcoEnchantDependency.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/EcoEnchantDependency.kt @@ -3,7 +3,7 @@ package xyz.alexcrea.cuanvil.dependency.plugins import com.willfp.eco.core.EcoPlugin import com.willfp.ecoenchants.enchant.EcoEnchant import com.willfp.ecoenchants.enchant.EcoEnchants -import com.willfp.ecoenchants.mechanics.infiniteIfNegative +import com.willfp.ecoenchants.enchant.UtilKt import io.delilaheve.CustomAnvil import org.bukkit.event.inventory.PrepareAnvilEvent import org.bukkit.plugin.Plugin @@ -35,7 +35,7 @@ class EcoEnchantDependency(private val ecoEnchantPlugin: Plugin) { } public fun getEcoLevelLimit(): Int { - return (ecoEnchantPlugin as EcoPlugin).configYml.getInt("anvil.enchant-limit").infiniteIfNegative() + return UtilKt.infiniteIfNegative((ecoEnchantPlugin as EcoPlugin).configYml.getInt("anvil.enchant-limit")) } fun disableAnvilListener() { @@ -51,7 +51,7 @@ class EcoEnchantDependency(private val ecoEnchantPlugin: Plugin) { return } - val enchantments = EcoEnchants.values() + val enchantments = EcoEnchants.INSTANCE.values() for (ecoEnchant in enchantments) { EnchantmentApi.unregisterEnchantment(ecoEnchant.enchantment) // As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant. EnchantmentApi.registerEnchantment(CAEcoEnchant(ecoEnchant)) @@ -71,7 +71,7 @@ class EcoEnchantDependency(private val ecoEnchantPlugin: Plugin) { // Should not happen in known case. if (this.ecoEnchantOldEnchantments == null) return - val newEnchantments = EcoEnchants.values() + val newEnchantments = EcoEnchants.INSTANCE.values() // Add new enchantments for (ecoEnchant in newEnchantments) diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/ItemsAdderDependency.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/ItemsAdderDependency.kt index 7f977e18..548080fb 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/ItemsAdderDependency.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/ItemsAdderDependency.kt @@ -6,6 +6,7 @@ import org.bukkit.NamespacedKey import org.bukkit.inventory.ItemStack import org.bukkit.plugin.Plugin +@Suppress("DEPRECATION") class ItemsAdderDependency(plugin: Plugin) : GenericPluginDependency(plugin) { var isLoaded: Boolean = false get() { diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/LegacyEcoEnchantDependency.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/LegacyEcoEnchantDependency.kt index 60f00b85..7f4196cf 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/LegacyEcoEnchantDependency.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/LegacyEcoEnchantDependency.kt @@ -10,13 +10,20 @@ class LegacyEcoEnchantDependency { private var ecoEnchantOldEnchantments: MutableSet? = null + private fun unregisterEnchantment(enchant: Any) { + EnchantmentApi.unregisterEnchantment((enchant as Enchantment).key) + } + + private fun registerEnchantment(ecoEnchant: EcoEnchant, enchant: Any) { + EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, enchant as Enchantment)) + } + fun registerEnchantments() { val enchantments = EcoEnchants.values() for (ecoEnchant in enchantments) { - ecoEnchant as Enchantment - - EnchantmentApi.unregisterEnchantment(ecoEnchant) // As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant. - EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, ecoEnchant)) + // As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant. + unregisterEnchantment(ecoEnchant) + registerEnchantment(ecoEnchant, ecoEnchant) } ecoEnchantOldEnchantments = HashSet(enchantments) @@ -31,13 +38,13 @@ class LegacyEcoEnchantDependency { // Add new enchantments for (ecoEnchant in newEnchantments) if (!this.ecoEnchantOldEnchantments!!.contains(ecoEnchant)) - EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, ecoEnchant as Enchantment)) + registerEnchantment(ecoEnchant, ecoEnchant) // Remove old enchantments that not now currently used this.ecoEnchantOldEnchantments!!.removeAll(newEnchantments) for (oldEnchantment in this.ecoEnchantOldEnchantments!!) { - EnchantmentApi.unregisterEnchantment(oldEnchantment as Enchantment) + unregisterEnchantment(oldEnchantment) } this.ecoEnchantOldEnchantments = HashSet(newEnchantments) diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/ToolStatsDependency.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/ToolStatsDependency.kt index 255f7373..8456ec87 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/ToolStatsDependency.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/ToolStatsDependency.kt @@ -5,7 +5,6 @@ import lol.hyper.toolstats.tools.ItemChecker import org.bukkit.event.inventory.InventoryClickEvent import org.bukkit.inventory.ItemStack import org.bukkit.plugin.Plugin -import org.bukkit.plugin.RegisteredListener import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener import java.lang.reflect.Method @@ -19,9 +18,13 @@ class ToolStatsDependency(plugin: Plugin) : GenericPluginDependency(plugin) { getTokenMethod.trySetAccessible() } - private fun ItemChecker.getTokenSafe(item: ItemStack?): Array { - if (item == null) return arrayOf() - return getTokenMethod.invoke(this, item) as Array + private fun ItemChecker.getTokenSafe(item: ItemStack?): Array<*> { + if (item == null) return arrayOf() + val result = getTokenMethod.invoke(this, item) + if(result !is Array<*>) + throw IllegalStateException("Could not get token from ToolStats") + + return result } override fun testAnvilResult(event: InventoryClickEvent): Boolean { diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/listener/AnvilResultListener.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/listener/AnvilResultListener.kt index e9290ac9..11dc1936 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/listener/AnvilResultListener.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/listener/AnvilResultListener.kt @@ -4,7 +4,9 @@ import io.delilaheve.CustomAnvil import io.delilaheve.util.ConfigOptions import io.delilaheve.util.ItemUtil.canMergeWith import org.bukkit.GameMode +import org.bukkit.Location import org.bukkit.Material +import org.bukkit.entity.HumanEntity import org.bukkit.entity.Player import org.bukkit.event.Event import org.bukkit.event.EventHandler @@ -21,6 +23,7 @@ import xyz.alexcrea.cuanvil.anvil.AnvilMergeLogic.AnvilResult import xyz.alexcrea.cuanvil.anvil.AnvilMergeLogic.CustomCraftResult import xyz.alexcrea.cuanvil.anvil.AnvilMergeLogic.LoreEditResult import xyz.alexcrea.cuanvil.anvil.AnvilMergeLogic.UnitRepairResult +import xyz.alexcrea.cuanvil.config.AnvilFinishOptions import xyz.alexcrea.cuanvil.dependency.DependencyManager import xyz.alexcrea.cuanvil.dependency.economy.EconomyManager import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil.setComponentDisplayName @@ -28,6 +31,7 @@ import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_INPUT_ import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_INPUT_RIGHT import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_OUTPUT_SLOT import xyz.alexcrea.cuanvil.util.CustomRecipeUtil +import xyz.alexcrea.cuanvil.util.MaterialUtil.isAir import xyz.alexcrea.cuanvil.util.MiniMessageUtil import xyz.alexcrea.cuanvil.util.anvil.AnvilLoreEditUtil import xyz.alexcrea.cuanvil.util.anvil.AnvilXpUtil @@ -89,7 +93,7 @@ class AnvilResultListener : Listener { } // Rename - if (rightItem == null) { + if (rightItem.isAir) { val result = AnvilMergeLogic.doRenaming(view, inventory, player, leftItem) if (result.isEmpty()) return @@ -103,7 +107,7 @@ class AnvilResultListener : Listener { } // Merge - val canMerge = leftItem.canMergeWith(rightItem) + val canMerge = leftItem.canMergeWith(rightItem!!) if (canMerge) { val result = AnvilMergeLogic.doMerge(view, inventory, player, leftItem, rightItem) @@ -193,6 +197,9 @@ class AnvilResultListener : Listener { result ) ) return + else if(player.gameMode != GameMode.CREATIVE) { + return + } // Finally, we add the item to the player if (slotDestination.type == SlotType.CURSOR) { @@ -212,10 +219,10 @@ class AnvilResultListener : Listener { val recipe = result.recipe!! // We remove what should be removed - if (rightItem != null) { - if (recipe.rightItem == null) return false// in case it changed + if (!rightItem.isAir) { + if (recipe.rightItem.isAir) return false// in case it changed - rightItem.amount -= amount * recipe.rightItem!!.amount + rightItem!!.amount -= amount * recipe.rightItem!!.amount inventory.setItem(ANVIL_INPUT_RIGHT, rightItem) } @@ -243,6 +250,8 @@ class AnvilResultListener : Listener { player.updateInventory() } + + handleAnvilMechanic(player, inventory) return true } @@ -345,6 +354,8 @@ class AnvilResultListener : Listener { inventory.setItem(ANVIL_OUTPUT_SLOT, null) + } else if(player.gameMode != GameMode.CREATIVE) { + return false } // Finally, we add the item to the player @@ -354,7 +365,9 @@ class AnvilResultListener : Listener { player.inventory.setItem(slotDestination.slot, result.item) } - // TODO probably anvil damage & sound here ?? + if (event.click != ClickType.MIDDLE) + handleAnvilMechanic(player, inventory) + return true } @@ -382,6 +395,61 @@ class AnvilResultListener : Listener { } } + // Process both sound & degradation + private fun handleAnvilMechanic(player: HumanEntity, inventory: AnvilInventory) { + return handleAnvilMechanic(player, inventory, player.gameMode != GameMode.CREATIVE) + } + + // Process both sound & degradation + private fun handleAnvilMechanic(player: HumanEntity, inventory: AnvilInventory, canDegrade: Boolean) { + // ok so we do not provide a getLocation on view ? + val location = inventory.location + + val wasDestroyed = canDegrade && tryDegradeAnvil(player, location) + tryPlaySound(location, wasDestroyed) + } + + private fun tryDegradeAnvil(player: HumanEntity, location: Location?): Boolean { + val world = location?.world ?: return false + if (Math.random() > AnvilFinishOptions.degradation_chance) return false + + val block = world.getBlockAt(location) + + val next = when (block.type) { + Material.ANVIL -> Material.CHIPPED_ANVIL + Material.CHIPPED_ANVIL -> Material.DAMAGED_ANVIL + Material.DAMAGED_ANVIL -> Material.AIR + else -> return false + } + + block.type = next + + if (next == Material.AIR) { + player.closeInventory() + return true + } + + return false + } + + private fun tryPlaySound( + location: Location?, + wasDestroyed: Boolean, + ) { + val world = location?.world + + if (!AnvilFinishOptions.sound_enabled) return + + val sound = AnvilFinishOptions.getAnvilSound(wasDestroyed) + world?.playSound( + location, + sound.sound, + sound.category, + sound.volume, + sound.pitch, + ) + } + private fun onUnitRepairExtract( rightItem: ItemStack, event: InventoryClickEvent, diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/recipe/AnvilCustomRecipe.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/recipe/AnvilCustomRecipe.kt index fd079c3a..1cd2b616 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/recipe/AnvilCustomRecipe.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/recipe/AnvilCustomRecipe.kt @@ -176,8 +176,8 @@ class AnvilCustomRecipe( CustomAnvil.verboseLog("Left item passed !") // we don't know if right item can be - if (rightItem == null) { // null test - if (item2 != null) return false + if (rightItem.isAir) { // null test + if (!item2.isAir) return false } else { val rightSimilar = rightItem!!.isSimilar(item2) CustomAnvil.verboseLog("Right similar: $rightSimilar") diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/util/CustomRecipeUtil.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/util/CustomRecipeUtil.kt index 058b25ad..b8a1907a 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/util/CustomRecipeUtil.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/util/CustomRecipeUtil.kt @@ -4,6 +4,7 @@ import io.delilaheve.CustomAnvil import org.bukkit.inventory.ItemStack import xyz.alexcrea.cuanvil.config.ConfigHolder import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe +import xyz.alexcrea.cuanvil.util.MaterialUtil.isAir import kotlin.math.min object CustomRecipeUtil { @@ -32,7 +33,7 @@ object CustomRecipeUtil { return if(recipe.exactCount) { if(leftItem.amount != recipe.leftItem!!.amount){ 0 - }else if(rightItem != null && rightItem.amount != recipe.rightItem!!.amount){ + }else if(!rightItem.isAir && rightItem!!.amount != recipe.rightItem!!.amount){ 0 }else{ 1 @@ -43,7 +44,7 @@ object CustomRecipeUtil { val resultItem = recipe.resultItem!! // we know exist as the recipe was returned to us val maxResultAmount = resultItem.maxStackSize/resultItem.amount val maxLeftAmount = leftItem.amount/recipe.leftItem!!.amount - val maxRightAmount = if(rightItem == null){ maxLeftAmount } else{ rightItem.amount/recipe.rightItem!!.amount } + val maxRightAmount = if(rightItem.isAir){ maxLeftAmount } else{ rightItem!!.amount/recipe.rightItem!!.amount } CustomAnvil.verboseLog("resultItem: $resultItem, maxResultAmount: $maxResultAmount, maxLeftAmount: $maxLeftAmount, maxRightAmount: $maxRightAmount") diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/util/MaterialUtil.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/util/MaterialUtil.kt index dc1e25a9..f9a6acc3 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/util/MaterialUtil.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/util/MaterialUtil.kt @@ -1,6 +1,5 @@ package xyz.alexcrea.cuanvil.util -import org.bukkit.Bukkit import org.bukkit.Material import org.bukkit.NamespacedKey import org.bukkit.inventory.ItemStack @@ -22,7 +21,7 @@ object MaterialUtil { val ItemStack.customType: NamespacedKey get() { - if(DependencyManager.ecoEnchantCompatibility != null) { + if(DependencyManager.hasEcoItem) { val result = EcoItemDependencyUtil.ecoItemNamespace(this) if(result != null) return result } @@ -44,7 +43,7 @@ object MaterialUtil { @Nullable fun getMatFromKey(key: NamespacedKey): Material? { - if(DependencyManager.ecoEnchantCompatibility != null) { + if(DependencyManager.hasEcoItem) { val result = EcoItemDependencyUtil.ecoItemMaterialFromKey(key) if(result != null) return result } @@ -59,7 +58,7 @@ object MaterialUtil { } fun itemFromKey(key: NamespacedKey): ItemStack { - if(DependencyManager.ecoEnchantCompatibility != null) { + if(DependencyManager.hasEcoItem) { val result = EcoItemDependencyUtil.newEcoItemstack(key) if(result != null) return result } @@ -79,7 +78,7 @@ object MaterialUtil { fun getMaterialCount(): Int { var count = Material.entries.size - if(DependencyManager.ecoEnchantCompatibility != null) { + if(DependencyManager.hasEcoItem) { count += EcoItemDependencyUtil.getItems().size } @@ -93,7 +92,7 @@ object MaterialUtil { fun getMaterials(): MutableList { val all = ArrayList(Material.entries.map { it.key }) - if(DependencyManager.ecoEnchantCompatibility != null) { + if(DependencyManager.hasEcoItem) { all.addAll(EcoItemDependencyUtil.getItems()) } diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/util/MetricsUtil.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/util/MetricsUtil.kt index 1763db56..9459ad9e 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/util/MetricsUtil.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/util/MetricsUtil.kt @@ -18,7 +18,7 @@ object MetricsUtil { private var FAST_STATS_METRICS: BukkitContext? = null fun loadMetrics(plugin: CustomAnvil) { - if(DependencyManager.externGuiTester.isInTest()) return + if(DependencyManager.inTesting) return val config = ConfigHolder.DEFAULT_CONFIG.config val metricString = config.getString(ConfigOptions.METRIC_TYPE, MetricType.AUTO.value)!! diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/util/anvil/AnvilXpUtil.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/util/anvil/AnvilXpUtil.kt index 78ea8830..379694f2 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/util/anvil/AnvilXpUtil.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/util/anvil/AnvilXpUtil.kt @@ -277,7 +277,7 @@ object AnvilXpUtil { // We know "enchantment.key in resultEnchs" true val resultLevel = resultEnchs[enchantment.key]!! - val enchantmentMultiplier = ConfigOptions.enchantmentValue(enchantment.key, isFromBook, isToBook) + val enchantmentMultiplier = ConfigOptions.enchantmentValue(enchantment.key, isToBook, isFromBook) val value = resultLevel * enchantmentMultiplier CustomAnvil.log("Value for sacrifice item ${enchantment.key.enchantmentName} level ${enchantment.value} is $value ($resultLevel * $enchantmentMultiplier)") rightValue += value @@ -291,7 +291,7 @@ object AnvilXpUtil { val resultLevel = resultEnchs.getOrDefault(enchantment.key, 0) - val enchantmentMultiplier = ConfigOptions.enchantmentValue(enchantment.key, isFromBook, isToBook) + val enchantmentMultiplier = ConfigOptions.enchantmentValue(enchantment.key, isToBook, isFromBook) val value = resultLevel * enchantmentMultiplier CustomAnvil.log("Value for left item ${enchantment.key.enchantmentName} level ${enchantment.value} is $value ($resultLevel * $enchantmentMultiplier)") leftValue += value diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6d946d4d..218c3a1f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -463,6 +463,32 @@ monetary_cost: work_penalty: 1.0 # for work penalty (aka use penalty) recipe: 1.0 # for custom anvil recipe cost +# Chance that an anvil get degraded +# set it to zero if you wish to disable it +anvil_degradation: 0.12 + +# see https://www.digminecraft.com/lists/sound_list_pc.php +# for a list of most of the sounds +anvil_sound: + enabled: true + # The sound are weighted so if there is multiples of them one is selected randomly + # so if you want to add a "rare sound" as an easter egg you can ! + # If invalid, it will be removed from the list. and if empty it will use the default + use: + default: + sound: block.anvil.use + category: blocks + volume: 1.0 + pitch: 1.0 + weight: 1.0 + destroy: + default: + sound: block.anvil.destroy + category: blocks + volume: 1.0 + pitch: 1.0 + weight: 1.0 + # Whether to show debug logging debug_log: false diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 97188e14..a8d98c8c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -80,6 +80,7 @@ softdepend: - Disenchantment - EnchantsSquared - EcoEnchants + - EcoItems - eco - ExcellentEnchants - HavenBags