Compare commits

..

No commits in common. "v1.x.x" and "v1.18.0" have entirely different histories.

72 changed files with 698 additions and 522 deletions

View file

@ -8,9 +8,12 @@
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 }}
@ -23,37 +26,46 @@ jobs:
contents: write
env:
MODRINTH_VERSIONS: '["1.18.x", "1.19.x", "1.20.x"]'
MODRINTH_VERSIONS: '["1.18.x", "1.19.x", "1.20.x", "1.21.x", "26.1.x", "26.2.x"]'
MODRINTH_PLATFORMS: '["spigot", "paper", "purpur", "folia"]'
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
- name: Set up JDKs
uses: actions/setup-java@v5
uses: actions/setup-java@v4
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@v6
uses: gradle/actions/setup-gradle@v5
- 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
@ -63,7 +75,7 @@ jobs:
# only submit dependency on push
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v6
uses: gradle/actions/dependency-submission@v4
if: ${{ github.event_name == 'push' && success() }}
continue-on-error: true
@ -79,16 +91,16 @@ jobs:
# upload the named jars as artifact
- name: Upload online JAR artifact
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
with:
name: CustomAnvil.jar
path: build/libs/${{ env.ONLINE_JAR_NAME }}
archive: false
- name: Upload offline JAR file
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
with:
name: CustomAnvil-offline.jar
path: build/libs/${{ env.OFFLINE_JAR_NAME }}
archive: false
- name: Summarize tests results
uses: jeantessier/test-summary-action@v1
@ -97,12 +109,33 @@ jobs:
# upload the jar to release
- name: Upload jar to release
if: ${{ github.event_name == 'release' && success() }}
uses: softprops/action-gh-release@v3
uses: softprops/action-gh-release@v2
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
@ -123,7 +156,8 @@ jobs:
with:
webhook-url: ${{ secrets.RELEASE_WEBHOOK_URL }}
content: |
<@&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.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.
${{ github.event.release.body }}

View file

@ -5,23 +5,24 @@ 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.4.0"
kotlin("jvm") version "2.3.0"
java
id("org.jetbrains.dokka").version("2.2.0")
id("com.gradleup.shadow").version("9.6.1")
id("org.jetbrains.dokka").version("1.9.20")
id("com.gradleup.shadow").version("9.3.0")
// Maven publish
`maven-publish`
signing
id("cn.lalaki.central").version("2.0.8")
id("cn.lalaki.central").version("1.2.8")
// Paper
id("io.papermc.paperweight.userdev") version "2.0.0-beta.21" apply false
id("io.papermc.hangar-publish-plugin") version "0.1.4"
id("io.papermc.paperweight.userdev") version "2.0.0-beta.17" apply false
id("io.papermc.hangar-publish-plugin") version "0.1.2"
}
group = "xyz.alexcrea"
version = "1.20.1"
version = "1.18.0"
val isDevBuild = System.getenv("SMALL_COMMIT_HASH") != null
val isPreRelease = System.getenv("IS_GITHUB_PRERELEASE") == "true"
@ -33,6 +34,9 @@ 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/")
@ -54,7 +58,7 @@ dependencies {
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
// fast stats
implementation("dev.faststats.metrics:bukkit:0.29.0")
implementation("dev.faststats.metrics:bukkit:0.27.2")
// minimessage
implementation("net.kyori:adventure-text-minimessage:4.25.0")
@ -68,22 +72,21 @@ dependencies {
compileOnly(files("libs/EnchantsSquared.jar"))
// EcoEnchants & item
compileOnly("com.willfp:libreforge:2026.32:all")
compileOnly("com.willfp:eco:2026.32")
compileOnly("com.willfp:libreforge:4.79.0:all")
compileOnly("com.willfp:eco:6.74.5")
compileOnly("com.willfp:EcoEnchants:2026.32:all")
compileOnly("com.willfp:EcoEnchants:12.11.1")
compileOnly(project(":impl:LegacyEcoEnchant"))
compileOnly("com.willfp:EcoItems:5.66.0")
// ExcellentEnchants
implementation(project(":impl:ExcellentEnchant5_4"))
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"))
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
// Disenchantment
compileOnly(files("libs/Disenchantment-6.1.5.jar"))
@ -165,7 +168,7 @@ allprojects {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_16)
}
}
@ -177,10 +180,7 @@ tasks {
fun ShadowJar.configureBaseShadow(suffix: String, libraries: Array<String>) {
val processedSuffix = if(suffix.isEmpty()) "" else "-$suffix"
val version = effectiveVersion
val name = "${rootProject.name}-${version}${processedSuffix}.jar"
val librariesExpendTo = libraries.joinToString(transform = { "\"$it\"" })
val name = "${rootProject.name}-${effectiveVersion}${processedSuffix}.jar"
archiveFileName.set(name)
// Shadow necessary dependency
@ -189,8 +189,8 @@ tasks {
filesMatching("plugin.yml") {
expand(
"version" to version + processedSuffix,
"libraries" to librariesExpendTo,
"version" to effectiveVersion + processedSuffix,
"libraries" to libraries.joinToString(transform = { "\"$it\"" }),
)
}
@ -202,7 +202,7 @@ tasks {
shadowJar {
configureBaseShadow("",
arrayOf(
"org.jetbrains.kotlin:kotlin-stdlib:2.4.0",
"org.jetbrains.kotlin:kotlin-stdlib:2.3.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 = register<ShadowJar>("offlineJar") {
val offlineJar by registering(ShadowJar::class) {
configureBaseShadow("offline", emptyArray())
from(sourceSets.main.get().output)
@ -228,12 +228,12 @@ tasks {
}
val sourcesJar = tasks.register<Jar>("sourcesJar") {
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(kotlin.sourceSets.main.get().kotlin)
}
val javadocJar = tasks.register<Jar>("javadocJar", fun Jar.() {
val javadocJar by tasks.registering(Jar::class, fun Jar.() {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Javadoc JAR"
archiveClassifier.set("javadoc")
@ -357,25 +357,36 @@ publishing {
}
// hangar publish
fun latestCommitMessage(): Provider<String> {
return providers.exec {
commandLine("git", "log", "-1", "--pretty=%B")
}.standardOutput.asText.map(String::trim)
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 changelog(isOnline: Boolean): Provider<String> {
val changelog = if(isDevBuild) latestCommitMessage()
else providers.environmentVariable("RELEASE_CHANGELOG")
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"
}
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 {
@ -389,7 +400,6 @@ hangarPublish {
channel.set(if (isDevBuild || isPreRelease) devChannel else releaseChannel)
changelog.set(changelog(isOnline))
id.set("CustomAnvil")
apiKey.set(System.getenv("HANGAR_API_TOKEN"))

View file

@ -476,32 +476,6 @@ 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

View file

@ -468,33 +468,6 @@ 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

View file

@ -456,33 +456,6 @@ 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

View file

@ -1,5 +1,4 @@
kotlin.code.style=official
org.gradle.configuration-cache=true
# Signing
signing.secretKeyRingFile=~/.gnupg/secring.gpg
@ -7,8 +6,8 @@ signing.secretKeyRingFile=~/.gnupg/secring.gpg
kotlin.daemon.jvmargs=-Xmx8G
# list of nms
subprojects.reobfnms=v1_17R1,v1_18R1,v1_18R2
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
# list of version for hangar release
paperVersion=1.18-1.20.5
paperVersion=1.18-26.2

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -2,7 +2,7 @@ group = rootProject.group
version = rootProject.version
plugins {
kotlin("jvm") version "2.4.0"
kotlin("jvm") version "2.3.0"
}
repositories {

View file

@ -2,7 +2,7 @@ group = rootProject.group
version = rootProject.version
plugins {
kotlin("jvm") version "2.4.0"
kotlin("jvm") version "2.3.0"
}
// Imitate needed class and method to support legacy version of EcoEnchant

Binary file not shown.

View file

@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_16)
}
}

View file

@ -37,7 +37,7 @@ object PlatformUtil {
// Lore
fun ItemMeta.componentLore(): MutableList<Component> {
val lore: List<Component>?
if (isPaper) {
if(isPaper){
lore = this.lore()
} else {
val legacyLores = this.lore ?: return ArrayList()
@ -52,41 +52,49 @@ object PlatformUtil {
}
fun ItemMeta.setComponentLore(lore: List<Component?>) {
if (isPaper) {
if(isPaper){
this.lore(lore)
} else {
val legacyLore = ArrayList<String?>(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 (!this.hasDisplayName()) return null
return if (isPaper) {
this.displayName()
if(useCustomName){
if(!this.hasCustomName()) return null
return this.customName()
}else if(isPaper){
if(!this.hasDisplayName()) return null
return this.displayName()
} else {
legacy_mm.deserialize(this.displayName)
if(!this.hasDisplayName()) return null
val legacy = this.displayName
return legacy_mm.deserialize(legacy)
}
}
fun ItemMeta.setComponentDisplayName(component: Component?, fallback: String? = null) {
if (isPaper) {
fun ItemMeta.setComponentDisplayName(component: Component?) {
if(useCustomName){
this.customName(component)
}else if(isPaper){
this.displayName(component)
} else {
if (component == null) {
if(component == null){
this.setDisplayName(null)
return
}
val legacy = fallback ?: legacy_mm.serialize(component)
val legacy = legacy_mm.serialize(component)
this.setDisplayName(legacy)
}
}

View file

@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_18)
}
}

View file

@ -1,4 +1,3 @@
@file:Suppress("DEPRECATION", "removal")
package xyz.alexcrea.cuanvil.dependency.datapack
import io.papermc.paper.datapack.Datapack
@ -22,21 +21,18 @@ object DataPackTester {
return Bukkit.getDatapackManager().enabledPacks
.stream().map { obj: Datapack -> obj.name }
.toList()
} catch (_: NoSuchMethodException) {
} catch (e: NoSuchMethodException) {
try {
DataPack::class.java.getDeclaredMethod("getKey")
} catch (_: NoSuchMethodException) {
} catch (e: 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 (_: Exception){
} catch (e: Exception){
// Assume cause UnimplementedOperationException on mock server
return Collections.emptyList()
} catch(_: NoSuchMethodError) {
// Idk newer spigot may not have that ?
return Collections.emptyList()
}
}
}

View file

@ -12,7 +12,6 @@ object AnvilTitleUtil {
private val runTaskMap = HashMap<UUID, ScheduledTask>()
@Suppress("DEPRECATION")
private fun actualRename(view: InventoryView, name: String, player: HumanEntity, anvilDialog: AnvilRenameDialog) {
runTaskMap.remove(player.uniqueId)
if (view.title == name) return

View file

@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_16)
}
}

View file

@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_18)
}
}

View file

@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_18)
}
}

View file

@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_18)
}
}

View file

@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_18)
}
}

1
nms/v1_21R1/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.lastDeploymentsId

View file

@ -0,0 +1,35 @@
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<JavaCompile>().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)
}
}

View file

@ -0,0 +1,33 @@
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)
}
}

1
nms/v1_21R2/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.lastDeploymentsId

View file

@ -0,0 +1,35 @@
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<JavaCompile>().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)
}
}

View file

@ -0,0 +1,33 @@
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)
}
}

1
nms/v1_21R3/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.lastDeploymentsId

View file

@ -0,0 +1,35 @@
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<JavaCompile>().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)
}
}

View file

@ -0,0 +1,33 @@
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)
}
}

1
nms/v1_21R4/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.lastDeploymentsId

View file

@ -0,0 +1,34 @@
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<JavaCompile>().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)
}
}

View file

@ -0,0 +1,33 @@
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)
}
}

1
nms/v1_21R5/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.lastDeploymentsId

View file

@ -0,0 +1,34 @@
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<JavaCompile>().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)
}
}

View file

@ -0,0 +1,33 @@
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)
}
}

1
nms/v1_21R6/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.lastDeploymentsId

View file

@ -0,0 +1,34 @@
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<JavaCompile>().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)
}
}

View file

@ -0,0 +1,33 @@
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)
}
}

1
nms/v1_21R7/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.lastDeploymentsId

View file

@ -0,0 +1,34 @@
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<JavaCompile>().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)
}
}

View file

@ -0,0 +1,33 @@
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)
}
}

View file

@ -99,7 +99,8 @@ public class CAEnchantmentRegistry {
if ((!hasWarnedRegistering) && byNameMap.containsKey(enchantment.getName())) {
hasWarnedRegistering = true;
CustomAnvil.Companion.log("Duplicate registered enchantment name. Please check that configuration is using namespace.");
CustomAnvil.instance.getLogger().log(Level.WARNING,
"Duplicate registered enchantment name. Please check that configuration is using namespace.");
}
byKeyMap.put(enchantment.getKey(), enchantment);

View file

@ -11,6 +11,7 @@ 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
@ -24,7 +25,6 @@ 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 {
if(legacyCheck()) return
legacyCheck()
} catch (e: Exception) {
logger.log(Level.SEVERE, "error trying to check for legacy system", e)
MetricsUtil.trackError(e)
@ -202,16 +202,7 @@ open class CustomAnvil : JavaPlugin() {
}
}
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
}
private fun legacyCheck() {
// Disable old plugin name if exist
val potentialPlugin = Bukkit.getPluginManager().getPlugin("UnsafeEnchantsPlus")
if (potentialPlugin != null) {
@ -224,6 +215,10 @@ 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"
@ -243,7 +238,6 @@ open class CustomAnvil : JavaPlugin() {
logger.warning("An update may be available: $latestVer")
}
return false
}
private fun registerListeners() {

View file

@ -6,6 +6,7 @@ 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
@ -20,6 +21,13 @@ 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
@ -32,7 +40,7 @@ object ItemUtil {
val meta = itemMeta
if(meta !is Damageable) return false
val maxDamage = type.maxDurability.toInt()
val maxDamage = maxDamage(type, meta)
val damage = (first.itemMeta as? Damageable)?.damage ?: 0
if (damage == 0) return false
@ -75,6 +83,6 @@ object ItemUtil {
* The two items should either be the same type, or, the [other] is a book
*/
fun ItemStack.canMergeWith(
other: ItemStack
) = customType == other.customType || (other.isEnchantedBook())
other: ItemStack?
) = (other != null) && (customType == other.customType || (other.isEnchantedBook()))
}

View file

@ -6,7 +6,6 @@ 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
@ -18,7 +17,6 @@ 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
@ -141,12 +139,11 @@ 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) {
component = AnvilColorUtil.handleColor(
val component = AnvilColorUtil.handleColor(
renameText,
AnvilColorUtil.renamePermission(player)
)
@ -173,11 +170,7 @@ object AnvilMergeLogic {
renameText == CasedStringUtil.snakeToUpperSpacedCase(resultItem.type.name.lowercase())
)
) {
if (component == null)
component = if (renameText == null || renameText.isEmpty()) null
else Component.text(renameText)
it.setComponentDisplayName(component, renameText)
it.setDisplayName(renameText)
processDialogPCD(it, player)
resultItem.itemMeta = it

View file

@ -1,146 +0,0 @@
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<ConfiguredSound> {
val sounds = ArrayList<ConfiguredSound>()
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<ConfiguredSound>, 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
}
}

View file

@ -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.IllegalStateException
import java.lang.reflect.Constructor
import java.util.logging.Level
object DependencyManager {
@ -42,11 +42,8 @@ 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
@ -83,10 +80,6 @@ object DependencyManager {
ecoEnchantCompatibility = EcoEnchantDependency(pluginManager.getPlugin("EcoEnchants")!!)
ecoEnchantCompatibility!!.disableAnvilListener()
}
// EcoItem check
if (pluginManager.isPluginEnabled("EcoItems")) {
hasEcoItem = true
}
// Excellent Enchants dependency
if (pluginManager.isPluginEnabled("ExcellentEnchants")) {
@ -342,14 +335,10 @@ object DependencyManager {
private val prepareAnvilConstructor =
PrepareAnvilEvent::class.java.constructors.first()
PrepareAnvilEvent::class.java.constructors.first() as Constructor<PrepareAnvilEvent>
fun createFakeEvent(view: InventoryView, result: ItemStack?): PrepareAnvilEvent {
val result = prepareAnvilConstructor.newInstance(view, result)
if(result !is PrepareAnvilEvent)
throw IllegalStateException("Could not create a PrepareAnvilEvent ?")
return result
return prepareAnvilConstructor.newInstance(view, result)
}
}

View file

@ -51,4 +51,8 @@ object MinecraftVersionUtil {
}
}
val isTooNewForSpigot: Boolean get() {
return UpdateUtils.currentMinecraftVersion().major != 1
}
}

View file

@ -223,11 +223,7 @@ 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
if(current == null) {
CustomAnvil.instance.logger.warning("Could not find enchant $ench")
return
}
val current = EnchantmentApi.getByKey(NamespacedKey.fromString(ench)!!) as CABukkitEnchantment
// We need to replace current wrapped enchantment with the all conflict wrapper
EnchantmentApi.unregisterEnchantment(current)

View file

@ -1,5 +1,3 @@
@file:Suppress("DEPRECATION")
package xyz.alexcrea.cuanvil.dependency.economy
import net.milkbowl.vault.economy.Economy

View file

@ -12,7 +12,7 @@ object PacketManagerSelector {
fun selectPacketManager(forceProtocolib: Boolean): PacketManager {
// Try to find version
if(DependencyManager.inTesting)
if(DependencyManager.externGuiTester.isInTest())
return NoPacketManager()
return if (forceProtocolib)

View file

@ -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.enchant.UtilKt
import com.willfp.ecoenchants.mechanics.infiniteIfNegative
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 UtilKt.infiniteIfNegative((ecoEnchantPlugin as EcoPlugin).configYml.getInt("anvil.enchant-limit"))
return (ecoEnchantPlugin as EcoPlugin).configYml.getInt("anvil.enchant-limit").infiniteIfNegative()
}
fun disableAnvilListener() {
@ -51,7 +51,7 @@ class EcoEnchantDependency(private val ecoEnchantPlugin: Plugin) {
return
}
val enchantments = EcoEnchants.INSTANCE.values()
val enchantments = EcoEnchants.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.INSTANCE.values()
val newEnchantments = EcoEnchants.values()
// Add new enchantments
for (ecoEnchant in newEnchantments)

View file

@ -6,7 +6,6 @@ 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() {

View file

@ -10,20 +10,13 @@ class LegacyEcoEnchantDependency {
private var ecoEnchantOldEnchantments: MutableSet<EcoEnchant>? = 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) {
// 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)
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))
}
ecoEnchantOldEnchantments = HashSet(enchantments)
@ -38,13 +31,13 @@ class LegacyEcoEnchantDependency {
// Add new enchantments
for (ecoEnchant in newEnchantments)
if (!this.ecoEnchantOldEnchantments!!.contains(ecoEnchant))
registerEnchantment(ecoEnchant, ecoEnchant)
EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, ecoEnchant as Enchantment))
// Remove old enchantments that not now currently used
this.ecoEnchantOldEnchantments!!.removeAll(newEnchantments)
for (oldEnchantment in this.ecoEnchantOldEnchantments!!) {
unregisterEnchantment(oldEnchantment)
EnchantmentApi.unregisterEnchantment(oldEnchantment as Enchantment)
}
this.ecoEnchantOldEnchantments = HashSet(newEnchantments)

View file

@ -5,6 +5,7 @@ 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
@ -18,13 +19,9 @@ class ToolStatsDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
getTokenMethod.trySetAccessible()
}
private fun ItemChecker.getTokenSafe(item: ItemStack?): Array<*> {
if (item == null) return arrayOf<Any>()
val result = getTokenMethod.invoke(this, item)
if(result !is Array<*>)
throw IllegalStateException("Could not get token from ToolStats")
return result
private fun ItemChecker.getTokenSafe(item: ItemStack?): Array<String> {
if (item == null) return arrayOf()
return getTokenMethod.invoke(this, item) as Array<String>
}
override fun testAnvilResult(event: InventoryClickEvent): Boolean {

View file

@ -4,9 +4,7 @@ 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
@ -23,7 +21,6 @@ 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
@ -31,7 +28,6 @@ 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
@ -93,7 +89,7 @@ class AnvilResultListener : Listener {
}
// Rename
if (rightItem.isAir) {
if (rightItem == null) {
val result = AnvilMergeLogic.doRenaming(view, inventory, player, leftItem)
if (result.isEmpty()) return
@ -107,7 +103,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)
@ -197,9 +193,6 @@ 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) {
@ -219,10 +212,10 @@ class AnvilResultListener : Listener {
val recipe = result.recipe!!
// We remove what should be removed
if (!rightItem.isAir) {
if (recipe.rightItem.isAir) return false// in case it changed
if (rightItem != null) {
if (recipe.rightItem == null) return false// in case it changed
rightItem!!.amount -= amount * recipe.rightItem!!.amount
rightItem.amount -= amount * recipe.rightItem!!.amount
inventory.setItem(ANVIL_INPUT_RIGHT, rightItem)
}
@ -250,8 +243,6 @@ class AnvilResultListener : Listener {
player.updateInventory()
}
handleAnvilMechanic(player, inventory)
return true
}
@ -354,8 +345,6 @@ 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
@ -365,9 +354,7 @@ class AnvilResultListener : Listener {
player.inventory.setItem(slotDestination.slot, result.item)
}
if (event.click != ClickType.MIDDLE)
handleAnvilMechanic(player, inventory)
// TODO probably anvil damage & sound here ??
return true
}
@ -395,61 +382,6 @@ 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,

View file

@ -176,8 +176,8 @@ class AnvilCustomRecipe(
CustomAnvil.verboseLog("Left item passed !")
// we don't know if right item can be
if (rightItem.isAir) { // null test
if (!item2.isAir) return false
if (rightItem == null) { // null test
if (item2 != null) return false
} else {
val rightSimilar = rightItem!!.isSimilar(item2)
CustomAnvil.verboseLog("Right similar: $rightSimilar")

View file

@ -4,7 +4,6 @@ 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 {
@ -33,7 +32,7 @@ object CustomRecipeUtil {
return if(recipe.exactCount) {
if(leftItem.amount != recipe.leftItem!!.amount){
0
}else if(!rightItem.isAir && rightItem!!.amount != recipe.rightItem!!.amount){
}else if(rightItem != null && rightItem.amount != recipe.rightItem!!.amount){
0
}else{
1
@ -44,7 +43,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.isAir){ maxLeftAmount } else{ rightItem!!.amount/recipe.rightItem!!.amount }
val maxRightAmount = if(rightItem == null){ maxLeftAmount } else{ rightItem.amount/recipe.rightItem!!.amount }
CustomAnvil.verboseLog("resultItem: $resultItem, maxResultAmount: $maxResultAmount, maxLeftAmount: $maxLeftAmount, maxRightAmount: $maxRightAmount")

View file

@ -1,5 +1,6 @@
package xyz.alexcrea.cuanvil.util
import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.NamespacedKey
import org.bukkit.inventory.ItemStack
@ -21,7 +22,7 @@ object MaterialUtil {
val ItemStack.customType: NamespacedKey
get() {
if(DependencyManager.hasEcoItem) {
if(DependencyManager.ecoEnchantCompatibility != null) {
val result = EcoItemDependencyUtil.ecoItemNamespace(this)
if(result != null) return result
}
@ -43,7 +44,7 @@ object MaterialUtil {
@Nullable
fun getMatFromKey(key: NamespacedKey): Material? {
if(DependencyManager.hasEcoItem) {
if(DependencyManager.ecoEnchantCompatibility != null) {
val result = EcoItemDependencyUtil.ecoItemMaterialFromKey(key)
if(result != null) return result
}
@ -58,7 +59,7 @@ object MaterialUtil {
}
fun itemFromKey(key: NamespacedKey): ItemStack {
if(DependencyManager.hasEcoItem) {
if(DependencyManager.ecoEnchantCompatibility != null) {
val result = EcoItemDependencyUtil.newEcoItemstack(key)
if(result != null) return result
}
@ -78,7 +79,7 @@ object MaterialUtil {
fun getMaterialCount(): Int {
var count = Material.entries.size
if(DependencyManager.hasEcoItem) {
if(DependencyManager.ecoEnchantCompatibility != null) {
count += EcoItemDependencyUtil.getItems().size
}
@ -92,7 +93,7 @@ object MaterialUtil {
fun getMaterials(): MutableList<NamespacedKey> {
val all = ArrayList(Material.entries.map { it.key })
if(DependencyManager.hasEcoItem) {
if(DependencyManager.ecoEnchantCompatibility != null) {
all.addAll(EcoItemDependencyUtil.getItems())
}

View file

@ -18,7 +18,7 @@ object MetricsUtil {
private var FAST_STATS_METRICS: BukkitContext? = null
fun loadMetrics(plugin: CustomAnvil) {
if(DependencyManager.inTesting) return
if(DependencyManager.externGuiTester.isInTest()) return
val config = ConfigHolder.DEFAULT_CONFIG.config
val metricString = config.getString(ConfigOptions.METRIC_TYPE, MetricType.AUTO.value)!!

View file

@ -277,7 +277,7 @@ object AnvilXpUtil {
// We know "enchantment.key in resultEnchs" true
val resultLevel = resultEnchs[enchantment.key]!!
val enchantmentMultiplier = ConfigOptions.enchantmentValue(enchantment.key, isToBook, isFromBook)
val enchantmentMultiplier = ConfigOptions.enchantmentValue(enchantment.key, isFromBook, isToBook)
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, isToBook, isFromBook)
val enchantmentMultiplier = ConfigOptions.enchantmentValue(enchantment.key, isFromBook, isToBook)
val value = resultLevel * enchantmentMultiplier
CustomAnvil.log("Value for left item ${enchantment.key.enchantmentName} level ${enchantment.value} is $value ($resultLevel * $enchantmentMultiplier)")
leftValue += value

View file

@ -463,32 +463,6 @@ 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

View file

@ -80,7 +80,6 @@ softdepend:
- Disenchantment
- EnchantsSquared
- EcoEnchants
- EcoItems
- eco
- ExcellentEnchants
- HavenBags