From 870f56debf247ef3bb193ca40dd3af05526ec44d Mon Sep 17 00:00:00 2001 From: alexcrea Date: Thu, 25 Sep 2025 19:07:00 +0200 Subject: [PATCH 01/10] add nms for mc 1.21.9 --- build.gradle.kts | 1 + nms/v1_21R6/.gitignore | 1 + nms/v1_21R6/build.gradle.kts | 34 +++++++++++++++++++ .../gui/version/v1_21R6_ExternGuiTester.kt | 34 +++++++++++++++++++ .../packet/versions/V1_21R6_PacketManager.kt | 33 ++++++++++++++++++ settings.gradle.kts | 2 ++ .../dependency/gui/GuiTesterSelector.kt | 1 + .../packet/PacketManagerSelector.kt | 1 + 8 files changed, 107 insertions(+) create mode 100644 nms/v1_21R6/.gitignore create mode 100644 nms/v1_21R6/build.gradle.kts create mode 100644 nms/v1_21R6/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_21R6_ExternGuiTester.kt create mode 100644 nms/v1_21R6/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R6_PacketManager.kt diff --git a/build.gradle.kts b/build.gradle.kts index 51b3651..a6a0722 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -84,6 +84,7 @@ dependencies { implementation(project(":nms:v1_21R3", configuration = "reobf")) implementation(project(":nms:v1_21R4", configuration = "reobf")) implementation(project(":nms:v1_21R5", configuration = "reobf")) + implementation(project(":nms:v1_21R6"))//, configuration = "reobf")) //TODO add back when 1.21.9 release // include kotlin for the offline jar implementation(kotlin("stdlib")) diff --git a/nms/v1_21R6/.gitignore b/nms/v1_21R6/.gitignore new file mode 100644 index 0000000..47374f1 --- /dev/null +++ b/nms/v1_21R6/.gitignore @@ -0,0 +1 @@ +.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_21R6/build.gradle.kts b/nms/v1_21R6/build.gradle.kts new file mode 100644 index 0000000..1ec1258 --- /dev/null +++ b/nms/v1_21R6/build.gradle.kts @@ -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.9-pre4-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_0) + jvmTarget.set(JvmTarget.JVM_21) + } +} diff --git a/nms/v1_21R6/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_21R6_ExternGuiTester.kt b/nms/v1_21R6/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_21R6_ExternGuiTester.kt new file mode 100644 index 0000000..4e4c32b --- /dev/null +++ b/nms/v1_21R6/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_21R6_ExternGuiTester.kt @@ -0,0 +1,34 @@ +package xyz.alexcrea.cuanvil.dependency.gui.version + +import org.bukkit.craftbukkit.inventory.CraftInventoryView +import org.bukkit.inventory.InventoryView +import xyz.alexcrea.cuanvil.dependency.gui.ExternGuiTester + +class v1_21R6_ExternGuiTester: ExternGuiTester { + override val wesjdAnvilGuiName = "Wrapper1_21_R6" + + var tested = false; + var possible = false; + + override fun getContainerClass(view: InventoryView): Class? { + // In case we are in a test environment + if(!tested) testClassExist() + if(!possible) return null + + if(view !is CraftInventoryView<*, *>) return null + val container = view.handle + + return container.javaClass + } + + fun testClassExist(){ + tested = true; + try { + Class.forName("org.bukkit.craftbukkit.inventory.CraftInventoryView") + possible = true + } catch (e: ClassNotFoundException){ + possible = false + } + } + +} \ No newline at end of file diff --git a/nms/v1_21R6/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R6_PacketManager.kt b/nms/v1_21R6/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R6_PacketManager.kt new file mode 100644 index 0000000..ee00666 --- /dev/null +++ b/nms/v1_21R6/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_21R6_PacketManager.kt @@ -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) + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 2861550..867d1bc 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -33,6 +33,8 @@ include("nms:v1_21R4") findProject(":nms:v1_21R4")?.name = "v1_21R4" include("nms:v1_21R5") findProject(":nms:v1_21R5")?.name = "v1_21R5" +include("nms:v1_21R6") +findProject(":nms:v1_21R6")?.name = "v1_21R6" include(":impl:LegacyEcoEnchant") findProject(":impl:LegacyEcoEnchant")?.name = "LegacyEcoEnchant" \ No newline at end of file diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt index b8ce177..8e4623c 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt @@ -45,6 +45,7 @@ object GuiTesterSelector { 4 -> v1_21R3_ExternGuiTester() 5 -> v1_21R4_ExternGuiTester() 6, 7, 8 -> v1_21R5_ExternGuiTester() + 9 -> v1_21R6_ExternGuiTester() else -> null } 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 450fbce..9ec231b 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/PacketManagerSelector.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/PacketManagerSelector.kt @@ -59,6 +59,7 @@ object PacketManagerSelector { 4 -> V1_21R3_PacketManager() 5 -> V1_21R4_PacketManager() 6, 7, 8 -> V1_21R5_PacketManager() + 9 -> V1_21R6_PacketManager() else -> null } From 3ab6dbc155aa3db8634e48c7c5ab036de0a26882 Mon Sep 17 00:00:00 2001 From: alexcrea Date: Thu, 25 Sep 2025 19:39:10 +0200 Subject: [PATCH 02/10] drop 1.17.x to 1.18.x nms paper bundle are broken --- README.md | 3 +- build.gradle.kts | 3 -- nms/v1_17R1/.gitignore | 1 - nms/v1_17R1/build.gradle.kts | 35 ------------------- .../gui/version/v1_17R1_ExternGuiTester.kt | 16 --------- .../packet/versions/V1_17R1_PacketManager.kt | 33 ----------------- nms/v1_18R1/.gitignore | 1 - nms/v1_18R1/build.gradle.kts | 35 ------------------- .../gui/version/v1_18R1_ExternGuiTester.kt | 16 --------- .../packet/versions/V1_18R1_PacketManager.kt | 33 ----------------- nms/v1_18R2/.gitignore | 1 - nms/v1_18R2/build.gradle.kts | 35 ------------------- .../gui/version/v1_18R2_ExternGuiTester.kt | 16 --------- .../packet/versions/V1_18R2_PacketManager.kt | 33 ----------------- settings.gradle.kts | 6 ---- .../dependency/gui/GuiTesterSelector.kt | 13 +------ .../packet/PacketManagerSelector.kt | 14 ++------ 17 files changed, 4 insertions(+), 290 deletions(-) delete mode 100644 nms/v1_17R1/.gitignore delete mode 100644 nms/v1_17R1/build.gradle.kts delete mode 100644 nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_17R1_ExternGuiTester.kt delete mode 100644 nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_17R1_PacketManager.kt delete mode 100644 nms/v1_18R1/.gitignore delete mode 100644 nms/v1_18R1/build.gradle.kts delete mode 100644 nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R1_ExternGuiTester.kt delete mode 100644 nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R1_PacketManager.kt delete mode 100644 nms/v1_18R2/.gitignore delete mode 100644 nms/v1_18R2/build.gradle.kts delete mode 100644 nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R2_ExternGuiTester.kt delete mode 100644 nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R2_PacketManager.kt diff --git a/README.md b/README.md index 978ea34..897d613 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ **Custom Anvil** is a plugin that allows server administrators to customize every aspect of the anvil's mechanics. It is expected to work on 1.18 to 1.21.7 minecraft servers running spigot or paper. -(the plugin support of 1.16.5 to 1.17.1 is experimental and may encounter issues) **Custom Anvil** was previously named **Unsafe Enchants+**. It was renamed because it now affects every anvil aspect and not only unsafe enchants\ @@ -87,7 +86,7 @@ as low priority as I work for the plugin on my free time for free. One of the configurations allow displaying price about 40 and removing Too Expensive. \ By how the minecraft client work: price above 40 can only be displayed green, even if the player does not own enough experience level. -Minecraft version 1.17 to 1.21.7 do not need any dependency. Other version need ProtocoLib enabled on your server for this feature. \ +Minecraft version 1.19 to 1.21.7 do not need any dependency. Other version need ProtocoLib enabled on your server for this feature. \ You can also wait for an update of the plugin to support a newer version. Please note that 1.16.5 to 1.17.1 are not officially supported. Run at your own risk. diff --git a/build.gradle.kts b/build.gradle.kts index a6a0722..23cb67e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -69,9 +69,6 @@ dependencies { // Include nms implementation(project(":nms:nms-common")) - implementation(project(":nms:v1_17R1", configuration = "reobf")) - implementation(project(":nms:v1_18R1", configuration = "reobf")) - implementation(project(":nms:v1_18R2", configuration = "reobf")) implementation(project(":nms:v1_19R1", configuration = "reobf")) implementation(project(":nms:v1_19R2", configuration = "reobf")) implementation(project(":nms:v1_19R3", configuration = "reobf")) diff --git a/nms/v1_17R1/.gitignore b/nms/v1_17R1/.gitignore deleted file mode 100644 index 47374f1..0000000 --- a/nms/v1_17R1/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_17R1/build.gradle.kts b/nms/v1_17R1/build.gradle.kts deleted file mode 100644 index 9a79bca..0000000 --- a/nms/v1_17R1/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.17.1-R0.1-SNAPSHOT") -} - -repositories { - maven("https://repo.papermc.io/repository/maven-public/") - -} - -// Set target version -tasks.withType().configureEach { - sourceCompatibility = "16" - targetCompatibility = "16" - - options.encoding = "UTF-8" -} - -kotlin { - compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0) - jvmTarget.set(JvmTarget.JVM_16) - } -} diff --git a/nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_17R1_ExternGuiTester.kt b/nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_17R1_ExternGuiTester.kt deleted file mode 100644 index 8e352e0..0000000 --- a/nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_17R1_ExternGuiTester.kt +++ /dev/null @@ -1,16 +0,0 @@ -package xyz.alexcrea.cuanvil.dependency.gui.version - -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryView -import org.bukkit.inventory.InventoryView -import xyz.alexcrea.cuanvil.dependency.gui.ExternGuiTester - -class v1_17R1_ExternGuiTester: ExternGuiTester { - override val wesjdAnvilGuiName = "Wrapper1_17_R1" - - override fun getContainerClass(view: InventoryView): Class? { - if (view !is CraftInventoryView) return null - val container = view.handle - - return container.javaClass - } -} \ No newline at end of file diff --git a/nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_17R1_PacketManager.kt b/nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_17R1_PacketManager.kt deleted file mode 100644 index c820eab..0000000 --- a/nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_17R1_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.v1_17_R1.entity.CraftPlayer -import org.bukkit.entity.Player -import xyz.alexcrea.cuanvil.dependency.packet.PacketManager -import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase - -class V1_17R1_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_18R1/.gitignore b/nms/v1_18R1/.gitignore deleted file mode 100644 index 47374f1..0000000 --- a/nms/v1_18R1/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_18R1/build.gradle.kts b/nms/v1_18R1/build.gradle.kts deleted file mode 100644 index 0ed9674..0000000 --- a/nms/v1_18R1/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.18.1-R0.1-SNAPSHOT") -} - -repositories { - maven("https://repo.papermc.io/repository/maven-public/") - -} - -// Set target version -tasks.withType().configureEach { - sourceCompatibility = "17" - targetCompatibility = "17" - - options.encoding = "UTF-8" -} - -kotlin { - compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0) - jvmTarget.set(JvmTarget.JVM_17) - } -} diff --git a/nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R1_ExternGuiTester.kt b/nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R1_ExternGuiTester.kt deleted file mode 100644 index 659a0f6..0000000 --- a/nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R1_ExternGuiTester.kt +++ /dev/null @@ -1,16 +0,0 @@ -package xyz.alexcrea.cuanvil.dependency.gui.version - -import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryView -import org.bukkit.inventory.InventoryView -import xyz.alexcrea.cuanvil.dependency.gui.ExternGuiTester - -class v1_18R1_ExternGuiTester: ExternGuiTester { - override val wesjdAnvilGuiName = "Wrapper1_18_R1" - - override fun getContainerClass(view: InventoryView): Class? { - if (view !is CraftInventoryView) return null - val container = view.handle - - return container.javaClass - } -} \ No newline at end of file diff --git a/nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R1_PacketManager.kt b/nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R1_PacketManager.kt deleted file mode 100644 index 71df5c7..0000000 --- a/nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R1_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.v1_18_R1.entity.CraftPlayer -import org.bukkit.entity.Player -import xyz.alexcrea.cuanvil.dependency.packet.PacketManager -import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase - -class V1_18R1_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_18R2/.gitignore b/nms/v1_18R2/.gitignore deleted file mode 100644 index 47374f1..0000000 --- a/nms/v1_18R2/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_18R2/build.gradle.kts b/nms/v1_18R2/build.gradle.kts deleted file mode 100644 index 2cc9659..0000000 --- a/nms/v1_18R2/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.18.2-R0.1-SNAPSHOT") -} - -repositories { - maven("https://repo.papermc.io/repository/maven-public/") - -} - -// Set target version -tasks.withType().configureEach { - sourceCompatibility = "17" - targetCompatibility = "17" - - options.encoding = "UTF-8" -} - -kotlin { - compilerOptions { - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0) - jvmTarget.set(JvmTarget.JVM_17) - } -} diff --git a/nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R2_ExternGuiTester.kt b/nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R2_ExternGuiTester.kt deleted file mode 100644 index 1447716..0000000 --- a/nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R2_ExternGuiTester.kt +++ /dev/null @@ -1,16 +0,0 @@ -package xyz.alexcrea.cuanvil.dependency.gui.version - -import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView -import org.bukkit.inventory.InventoryView -import xyz.alexcrea.cuanvil.dependency.gui.ExternGuiTester - -class v1_18R2_ExternGuiTester: ExternGuiTester { - override val wesjdAnvilGuiName = "Wrapper1_18_R2" - - override fun getContainerClass(view: InventoryView): Class? { - if (view !is CraftInventoryView) return null - val container = view.handle - - return container.javaClass - } -} \ No newline at end of file diff --git a/nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R2_PacketManager.kt b/nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R2_PacketManager.kt deleted file mode 100644 index ee442f5..0000000 --- a/nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R2_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.v1_18_R2.entity.CraftPlayer -import org.bukkit.entity.Player -import xyz.alexcrea.cuanvil.dependency.packet.PacketManager -import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase - -class V1_18R2_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/settings.gradle.kts b/settings.gradle.kts index 867d1bc..a63389b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,12 +3,6 @@ rootProject.name = "CustomAnvil" // NMS subproject include("nms:nms-common") findProject(":nms:nms-common")?.name = "nms-common" -include("nms:v1_17R1") -findProject(":nms:v1_17R1")?.name = "v1_17R1" -include("nms:v1_18R1") -findProject(":nms:v1_18R1")?.name = "v1_18R1" -include("nms:v1_18R2") -findProject(":nms:v1_18R2")?.name = "v1_18R2" include("nms:v1_19R1") findProject(":nms:v1_19R1")?.name = "v1_19R1" include("nms:v1_19R2") diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt index 8e4623c..d819430 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt @@ -11,18 +11,7 @@ object GuiTesterSelector { if (versionParts[0] != 1) return null return when (versionParts[1]) { - // Can't support 1.16.5 bc 1.16.5 paper userdev do not exist - - 17 -> when (versionParts[2]) { - 0, 1 -> v1_17R1_ExternGuiTester() - else -> null - } - - 18 -> when (versionParts[2]) { - 0, 1 -> v1_18R1_ExternGuiTester() - 2 -> v1_18R2_ExternGuiTester() - else -> null - } + // Can't support 1.16.5-1.18.x paper userdev do not exist or broken 19 -> when (versionParts[2]) { 0, 1, 2 -> v1_19R1_ExternGuiTester() 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 9ec231b..7ba3586 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/PacketManagerSelector.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/PacketManagerSelector.kt @@ -19,24 +19,14 @@ object PacketManagerSelector { ProtocoLibWrapper() else NoPacketManager() + private val versionSpecificManager: PacketManagerBase? get() { val versionParts = UpdateUtils.currentMinecraftVersionArray() if (versionParts[0] != 1) return null return when (versionParts[1]) { - // Can't support 1.16.5 bc 1.16.5 paper userdev do not exist - - 17 -> when (versionParts[2]) { - 0, 1 -> V1_17R1_PacketManager() - else -> null - } - - 18 -> when (versionParts[2]) { - 0, 1 -> V1_18R1_PacketManager() - 2 -> V1_18R2_PacketManager() - else -> null - } + // Can't support 1.16.5 to 1.18.x bc paper userdev do not exist or broken 19 -> when (versionParts[2]) { 0, 1, 2 -> V1_19R1_PacketManager() From 5bdd2f9b4c4873e174991df5eab56c4246debc0e Mon Sep 17 00:00:00 2001 From: alexcrea Date: Thu, 25 Sep 2025 20:11:02 +0200 Subject: [PATCH 03/10] add copper items --- .../alexcrea/cuanvil/update/Update_1_21.java | 31 ++++------ .../cuanvil/update/Update_1_21_9.java | 61 +++++++++++++++++++ .../xyz/alexcrea/cuanvil/update/Version.java | 3 + .../cuanvil/update/plugin/PluginUpdates.java | 34 +++++++++-- src/main/kotlin/io/delilaheve/CustomAnvil.kt | 7 +-- .../cuanvil/command/ReloadExecutor.kt | 6 +- 6 files changed, 110 insertions(+), 32 deletions(-) create mode 100644 src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21.java b/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21.java index 332b5fe..bd5ccf9 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21.java @@ -1,7 +1,6 @@ package xyz.alexcrea.cuanvil.update; import io.delilaheve.CustomAnvil; -import org.bukkit.configuration.file.FileConfiguration; import xyz.alexcrea.cuanvil.config.ConfigHolder; import static xyz.alexcrea.cuanvil.update.UpdateUtils.addAbsentToList; @@ -12,31 +11,28 @@ public class Update_1_21 { private static final Version V1_21 = new Version(1, 21); - public static void handleUpdate(){ - // Assume if version path is not null then it's 1.21 + public static void handleUpdate(Version current){ + // Test if we are running in 1.21.1 + if(V1_21.greaterEqual(current)) + return; + + // if version path is not null then check if its it's before 1.21 String oldVersion = ConfigHolder.DEFAULT_CONFIG.getConfig().getString(UpdateUtils.MINECRAFT_VERSION_PATH); if(oldVersion != null){ - Version version = Version.fromString(oldVersion); - - // Test 1.21 + var version = Version.fromString(oldVersion); if(V1_21.greaterEqual(version)) return; } - Version current = UpdateUtils.currentMinecraftVersion(); - - // Test 1.21 - if(current.greaterEqual(V1_21)){ - doUpdate(); - } + doUpdate(); } private static void doUpdate() { CustomAnvil.instance.getLogger().info("Updating config to support 1.21 ..."); - FileConfiguration baseConfig = ConfigHolder.DEFAULT_CONFIG.getConfig(); - FileConfiguration groupConfig = ConfigHolder.ITEM_GROUP_HOLDER.getConfig(); - FileConfiguration conflictConfig = ConfigHolder.CONFLICT_HOLDER.getConfig(); - FileConfiguration unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig(); + var baseConfig = ConfigHolder.DEFAULT_CONFIG.getConfig(); + var groupConfig = ConfigHolder.ITEM_GROUP_HOLDER.getConfig(); + var conflictConfig = ConfigHolder.CONFLICT_HOLDER.getConfig(); + var unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig(); // Add mace to groups groupConfig.set("mace.type", "include"); @@ -81,7 +77,7 @@ public class Update_1_21 { unitConfig.set("breeze_rod.mace", 0.25); // Set version string as 1.21 - baseConfig.set(UpdateUtils.MINECRAFT_VERSION_PATH, "1.21"); + baseConfig.set(UpdateUtils.MINECRAFT_VERSION_PATH, V1_21.toString()); // Save ConfigHolder.DEFAULT_CONFIG.saveToDisk(true); @@ -94,7 +90,6 @@ public class Update_1_21 { ConfigHolder.ITEM_GROUP_HOLDER.reload(); CustomAnvil.instance.getLogger().info("Updating Done !"); - } } diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java b/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java new file mode 100644 index 0000000..0f169bc --- /dev/null +++ b/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java @@ -0,0 +1,61 @@ +package xyz.alexcrea.cuanvil.update; + +import io.delilaheve.CustomAnvil; +import xyz.alexcrea.cuanvil.config.ConfigHolder; + +import static xyz.alexcrea.cuanvil.update.UpdateUtils.addAbsentToList; + +// This is a temporary class that aim to handle 1.21 update. +// It will be replaced by a better system later. +public class Update_1_21_9 { + + private static final Version V1_21_9 = new Version(1, 21, 9); + + public static void handleUpdate(Version current){ + // Test if we are running in 1.21.1.9 + if(V1_21_9.greaterEqual(current)) + return; + + // if version path is not null then check if its it's before 1.21.9 + String oldVersion = ConfigHolder.DEFAULT_CONFIG.getConfig().getString(UpdateUtils.MINECRAFT_VERSION_PATH); + if(oldVersion != null){ + var version = Version.fromString(oldVersion); + if(V1_21_9.greaterEqual(version)) return; + } + + doUpdate(); + } + + private static void doUpdate() { + CustomAnvil.instance.getLogger().info("Updating config to support 1.21.9 ..."); + + var baseConfig = ConfigHolder.DEFAULT_CONFIG.getConfig(); + var groupConfig = ConfigHolder.ITEM_GROUP_HOLDER.getConfig(); + + // Add mace to groups + addAbsentToList(groupConfig, "helmets.items", "copper_helmet"); + addAbsentToList(groupConfig, "chestplate.items", "copper_chestplate"); + addAbsentToList(groupConfig, "leggings.items", "copper_leggings"); + addAbsentToList(groupConfig, "boots.items", "copper_boots"); + + addAbsentToList(groupConfig, "pickaxes.items", "copper_pickaxe"); + addAbsentToList(groupConfig, "shovels.items", "copper_shovel"); + addAbsentToList(groupConfig, "hoes.items", "copper_hoe"); + addAbsentToList(groupConfig, "axes.items", "copper_axe"); + addAbsentToList(groupConfig, "swords.items", "copper_sword"); + + // Set version string as 1.21 + baseConfig.set(UpdateUtils.MINECRAFT_VERSION_PATH, V1_21_9.toString()); + + // Save + ConfigHolder.DEFAULT_CONFIG.saveToDisk(true); + ConfigHolder.ITEM_GROUP_HOLDER.saveToDisk(true); + + // imply reload of CONFLICT_HOLDER + // We also do not need to reload base config as there is no object related to it. + ConfigHolder.ITEM_GROUP_HOLDER.reload(); + + CustomAnvil.instance.getLogger().info("Updating Done !"); + } + +} diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/Version.java b/src/main/java/xyz/alexcrea/cuanvil/update/Version.java index e6f63cf..15476f5 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/Version.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/Version.java @@ -1,5 +1,7 @@ package xyz.alexcrea.cuanvil.update; +import org.jetbrains.annotations.NotNull; + import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -48,6 +50,7 @@ public record Version(int major, int minor, int patch) { this.patch <= other.patch))); } + @NotNull @Override public String toString() { return major + "." + minor + "." + patch; diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PluginUpdates.java b/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PluginUpdates.java index 03c858e..0beaf63 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PluginUpdates.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PluginUpdates.java @@ -2,6 +2,9 @@ package xyz.alexcrea.cuanvil.update.plugin; import io.delilaheve.CustomAnvil; import xyz.alexcrea.cuanvil.config.ConfigHolder; +import xyz.alexcrea.cuanvil.update.UpdateUtils; +import xyz.alexcrea.cuanvil.update.Update_1_21; +import xyz.alexcrea.cuanvil.update.Update_1_21_9; import xyz.alexcrea.cuanvil.update.Version; import javax.annotation.Nonnull; @@ -12,26 +15,37 @@ public class PluginUpdates { private static final String CONFIG_VERSION_PATH = "configVersion"; - public static void handlePluginUpdate() { + // Handle mc version update then plugin version update + public static void handleUpdates() { + handleMCVersionUpdate(); + handlePluginUpdate(); + } + + private static final Version V1_6_2 = new Version(1, 6, 2); + private static final Version V1_6_7 = new Version(1, 6, 7); + private static final Version V1_8_0 = new Version(1, 8, 0); + private static final Version V1_11_0 = new Version(1, 11, 0); + + // Handle only plugin update + private static void handlePluginUpdate() { String versionString = ConfigHolder.DEFAULT_CONFIG.getConfig().getString(CONFIG_VERSION_PATH); Version current = versionString == null ? new Version(0) : Version.fromString(versionString); Set toSave = new HashSet<>(); - if (new Version(1, 6, 2).greaterThan(current)) { + if (V1_6_2.greaterThan(current)) { PUpdate_1_6_2.handleUpdate(toSave); // We assume 1.6.7 will run. TODO a better system instead of that I guess } - if (new Version(1, 6, 7).greaterThan(current)) { + if (V1_6_7.greaterThan(current)) { PUpdate_1_6_7.handleUpdate(toSave); // We assume 1.8.0 will run. } - if (new Version(1, 8, 0).greaterThan(current)) { + if (V1_8_0.greaterThan(current)) { PUpdate_1_8_0.handleUpdate(toSave); // We assume 1.11.0 will run. } - - if (new Version(1, 11, 0).greaterThan(current)) { + if (V1_11_0.greaterThan(current)) { PUpdate_1_11_0.handleUpdate(toSave); finishConfiguration("1.11.0", toSave); @@ -39,6 +53,14 @@ public class PluginUpdates { } + // Handle minecraft version update (not plugin version update) + public static void handleMCVersionUpdate(){ + Version current = UpdateUtils.currentMinecraftVersion(); + + Update_1_21.handleUpdate(current); + Update_1_21_9.handleUpdate(current); + } + private static void finishConfiguration(@Nonnull String newVersion, @Nonnull Set toSave) { CustomAnvil.instance.getLogger().info("Configuration file updated to " + newVersion); ConfigHolder.DEFAULT_CONFIG.getConfig().set(CONFIG_VERSION_PATH, newVersion); diff --git a/src/main/kotlin/io/delilaheve/CustomAnvil.kt b/src/main/kotlin/io/delilaheve/CustomAnvil.kt index f629c2f..386969a 100644 --- a/src/main/kotlin/io/delilaheve/CustomAnvil.kt +++ b/src/main/kotlin/io/delilaheve/CustomAnvil.kt @@ -139,11 +139,8 @@ open class CustomAnvil : JavaPlugin() { return } - // temporary: handle 1.21 update - Update_1_21.handleUpdate() - - // plugin configuration updates - PluginUpdates.handlePluginUpdate() + // Handle minecraft and plugin updates + PluginUpdates.handleUpdates() // Register enchantment of compatible plugin and load configuration change. DependencyManager.handleCompatibilityConfig() diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/command/ReloadExecutor.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/command/ReloadExecutor.kt index 38a98c0..8093e09 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/command/ReloadExecutor.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/command/ReloadExecutor.kt @@ -9,7 +9,7 @@ import xyz.alexcrea.cuanvil.api.event.CAConfigReadyEvent import xyz.alexcrea.cuanvil.config.ConfigHolder import xyz.alexcrea.cuanvil.dependency.DependencyManager import xyz.alexcrea.cuanvil.gui.config.global.* -import xyz.alexcrea.cuanvil.update.Update_1_21 +import xyz.alexcrea.cuanvil.update.plugin.PluginUpdates class ReloadExecutor : CommandExecutor { override fun onCommand(sender: CommandSender, cmd: Command, cmdstr: String, args: Array): Boolean { @@ -48,8 +48,8 @@ class ReloadExecutor : CommandExecutor { UnitRepairConfigGui.getCurrentInstance()?.reloadValues() CustomRecipeConfigGui.getCurrentInstance()?.reloadValues() - // temporary: handle 1.21 update - Update_1_21.handleUpdate() + // handle minecraft version update + PluginUpdates.handleMCVersionUpdate() // Handle dependency reload DependencyManager.handleConfigReload() From dd2f3204c394497be848c34b6db1e544a211f78f Mon Sep 17 00:00:00 2001 From: alexcrea Date: Thu, 25 Sep 2025 20:24:22 +0200 Subject: [PATCH 04/10] logic issue fix --- .../java/xyz/alexcrea/cuanvil/update/Update_1_21.java | 8 +++----- .../java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21.java b/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21.java index bd5ccf9..1695b34 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21.java @@ -5,22 +5,20 @@ import xyz.alexcrea.cuanvil.config.ConfigHolder; import static xyz.alexcrea.cuanvil.update.UpdateUtils.addAbsentToList; -// This is a temporary class that aim to handle 1.21 update. -// It will be replaced by a better system later. public class Update_1_21 { private static final Version V1_21 = new Version(1, 21); public static void handleUpdate(Version current){ - // Test if we are running in 1.21.1 - if(V1_21.greaterEqual(current)) + // Test if we are running in 1.21 or better + if(V1_21.greaterThan(current)) return; // if version path is not null then check if its it's before 1.21 String oldVersion = ConfigHolder.DEFAULT_CONFIG.getConfig().getString(UpdateUtils.MINECRAFT_VERSION_PATH); if(oldVersion != null){ var version = Version.fromString(oldVersion); - if(V1_21.greaterEqual(version)) return; + if(V1_21.lesserEqual(version)) return; } doUpdate(); diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java b/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java index 0f169bc..0075285 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java @@ -5,22 +5,20 @@ import xyz.alexcrea.cuanvil.config.ConfigHolder; import static xyz.alexcrea.cuanvil.update.UpdateUtils.addAbsentToList; -// This is a temporary class that aim to handle 1.21 update. -// It will be replaced by a better system later. public class Update_1_21_9 { private static final Version V1_21_9 = new Version(1, 21, 9); public static void handleUpdate(Version current){ - // Test if we are running in 1.21.1.9 - if(V1_21_9.greaterEqual(current)) + // Test if we are running in 1.21.9 or better + if(V1_21_9.greaterThan(current)) return; // if version path is not null then check if its it's before 1.21.9 String oldVersion = ConfigHolder.DEFAULT_CONFIG.getConfig().getString(UpdateUtils.MINECRAFT_VERSION_PATH); if(oldVersion != null){ var version = Version.fromString(oldVersion); - if(V1_21_9.greaterEqual(version)) return; + if(V1_21_9.lesserEqual(version)) return; } doUpdate(); From 4da017c9be99ae0c0bf0bf780b7dadf83c9c7c22 Mon Sep 17 00:00:00 2001 From: alexcrea Date: Thu, 25 Sep 2025 20:30:03 +0200 Subject: [PATCH 05/10] more pretty log --- .../java/xyz/alexcrea/cuanvil/update/Update_1_21.java | 9 ++++----- .../java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java | 9 ++++----- .../alexcrea/cuanvil/update/plugin/PluginUpdates.java | 9 +++++++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21.java b/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21.java index 1695b34..56de63c 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21.java @@ -9,19 +9,20 @@ public class Update_1_21 { private static final Version V1_21 = new Version(1, 21); - public static void handleUpdate(Version current){ + public static boolean handleUpdate(Version current){ // Test if we are running in 1.21 or better if(V1_21.greaterThan(current)) - return; + return false; // if version path is not null then check if its it's before 1.21 String oldVersion = ConfigHolder.DEFAULT_CONFIG.getConfig().getString(UpdateUtils.MINECRAFT_VERSION_PATH); if(oldVersion != null){ var version = Version.fromString(oldVersion); - if(V1_21.lesserEqual(version)) return; + if(V1_21.lesserEqual(version)) return false; } doUpdate(); + return true; } private static void doUpdate() { @@ -86,8 +87,6 @@ public class Update_1_21 { // imply reload of CONFLICT_HOLDER // We also do not need to reload base config as there is no object related to it. ConfigHolder.ITEM_GROUP_HOLDER.reload(); - - CustomAnvil.instance.getLogger().info("Updating Done !"); } } diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java b/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java index 0075285..e749d74 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/Update_1_21_9.java @@ -9,19 +9,20 @@ public class Update_1_21_9 { private static final Version V1_21_9 = new Version(1, 21, 9); - public static void handleUpdate(Version current){ + public static boolean handleUpdate(Version current){ // Test if we are running in 1.21.9 or better if(V1_21_9.greaterThan(current)) - return; + return false; // if version path is not null then check if its it's before 1.21.9 String oldVersion = ConfigHolder.DEFAULT_CONFIG.getConfig().getString(UpdateUtils.MINECRAFT_VERSION_PATH); if(oldVersion != null){ var version = Version.fromString(oldVersion); - if(V1_21_9.lesserEqual(version)) return; + if(V1_21_9.lesserEqual(version)) return false; } doUpdate(); + return true; } private static void doUpdate() { @@ -52,8 +53,6 @@ public class Update_1_21_9 { // imply reload of CONFLICT_HOLDER // We also do not need to reload base config as there is no object related to it. ConfigHolder.ITEM_GROUP_HOLDER.reload(); - - CustomAnvil.instance.getLogger().info("Updating Done !"); } } diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PluginUpdates.java b/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PluginUpdates.java index 0beaf63..430825c 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PluginUpdates.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PluginUpdates.java @@ -57,8 +57,13 @@ public class PluginUpdates { public static void handleMCVersionUpdate(){ Version current = UpdateUtils.currentMinecraftVersion(); - Update_1_21.handleUpdate(current); - Update_1_21_9.handleUpdate(current); + boolean hadUpdate = false; + hadUpdate |= Update_1_21.handleUpdate(current); + hadUpdate |= Update_1_21_9.handleUpdate(current); + + if(hadUpdate){ + CustomAnvil.instance.getLogger().info("Updating Done !"); + } } private static void finishConfiguration(@Nonnull String newVersion, @Nonnull Set toSave) { From 8b7be2dd1fb3ce8f1db20e88f1ea629f722ba742 Mon Sep 17 00:00:00 2001 From: alexcrea Date: Thu, 25 Sep 2025 20:32:05 +0200 Subject: [PATCH 06/10] add default 1.21.9 configurations --- README.md | 3 +- defaultconfigs/1.21.9/README.md | 6 + defaultconfigs/1.21.9/config.yml | 393 +++++++++++++++++++++ defaultconfigs/1.21.9/custom_recipes.yml | 5 + defaultconfigs/1.21.9/enchant_conflict.yml | 382 ++++++++++++++++++++ defaultconfigs/1.21.9/item_groups.yml | 236 +++++++++++++ defaultconfigs/1.21.9/unit_repair_item.yml | 192 ++++++++++ 7 files changed, 1216 insertions(+), 1 deletion(-) create mode 100644 defaultconfigs/1.21.9/README.md create mode 100644 defaultconfigs/1.21.9/config.yml create mode 100644 defaultconfigs/1.21.9/custom_recipes.yml create mode 100644 defaultconfigs/1.21.9/enchant_conflict.yml create mode 100644 defaultconfigs/1.21.9/item_groups.yml create mode 100644 defaultconfigs/1.21.9/unit_repair_item.yml diff --git a/README.md b/README.md index 897d613..3c207da 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,8 @@ For information about the API, please refer to [the Wiki](https://github.com/ale ### Default Plugin's Configurations For 1.18 to 1.20.6 use the [1.18 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.18)\ -For 1.21 to 1.21.7 use the [1.21 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21) +For 1.21 to 1.21.8 use the [1.21 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21)\ +From 1.21.9 use the [1.21.9 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21) --- Custom anvil [use bstat](https://bstats.org/plugin/bukkit/Unsafe%20Enchants%20Plus/20923) for metric. You can [disable it](https://bstats.org/getting-started) if you like. diff --git a/defaultconfigs/1.21.9/README.md b/defaultconfigs/1.21.9/README.md new file mode 100644 index 0000000..2b3bfa8 --- /dev/null +++ b/defaultconfigs/1.21.9/README.md @@ -0,0 +1,6 @@ +### Default Plugin's Configurations For 1.21.9 +- [config.yml](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21.9/config.yml) +- [enchant_conflict.yml](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21.9/enchant_conflict.yml) +- [item_groups.yml](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21.9/item_groups.yml) +- [unit_repair_item.yml](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21.9/unit_repair_item.yml) +- [custom_recipes.yml](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21.9/custom_recipes.yml) diff --git a/defaultconfigs/1.21.9/config.yml b/defaultconfigs/1.21.9/config.yml new file mode 100644 index 0000000..f6817ba --- /dev/null +++ b/defaultconfigs/1.21.9/config.yml @@ -0,0 +1,393 @@ +# +# It is recommended that you use /configanvil to edit theses config. +# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes ! +# + +# All anvil cost will be capped to limit_repair_value if enabled. +# +# In other words: +# For any anvil cost greater than limit_repair_value, Cost will be set to limit_repair_value. +limit_repair_cost: false + +# Max cost value the Anvil can get to. +# +# Valid values include 0 to 1000. +# Cost will be displayed as "Too Expensive": +# - If Cost is above 39 +# - And replace_too_expensive is disabled (false) +limit_repair_value: 39 + +# Whether the anvil's cost limit should be removed entirely. +# +# The anvil will still visually display "Too Expensive" if "replace_too_expensive" is disabled +# However, the action will be completable if xp requirement is meet. +remove_repair_limit: false + +# Whenever anvil cost is above 39 should display the true price and not "Too Expensive". +# +# However, when bypassing "Too Expensive", anvil price will be displayed as Green. +# If the action is not completable, the cost will still be displayed as "Too expensive". +# That mean you also need to change other settings like remove_repair_limit or limit_repair_cost. +# +# Require ProtocoLib. +replace_too_expensive: false + +# XP Level amount added to the anvil when the item is repaired by another item of the same type +# +# Valid values include 0 to 1000 +item_repair_cost: 2 + +# XP Level amount added to the anvil when the item is renamed +# +# Valid values include 0 to 1000 +item_rename_cost: 1 + +# XP Level amount added to the anvil when the item is repaired by an "unit" +# For example: a Diamond on a Diamond Sword +# What's considered unit for what can be edited on the unit repair configuration. +# +# Valid values include 0 to 1000 +unit_repair_cost: 1 + +# XP Level amount added to the anvil when a sacrifice enchantment +# conflict with one of the left item enchantment +# +# Valid values include 0 to 1000 +sacrifice_illegal_enchant_cost: 1 + +# Allow using color code and hexadecimal color. +# +# Color code are prefixed by "&" and hexadecimal color by "#". +# Color code will not be applied if it colors nothing. "&&" can be used to write "&". +allow_color_code: false +allow_hexadecimal_color: false + +# Toggle if color should only be applicable if the player a certain permission. +# +# permission are "ca.color.code" for use of color code and "ca.color.hex" for use of hexadecimal color. +permission_needed_for_color: true + +# Xp cost if the player use color in the items name on rename. +# +# Valid values include 0 to 1000. +use_of_color_cost: 0 + +# Default limit to apply to any enchants missing from enchant_limits +# +# Valid values include 1 to 1000 +default_limit: 5 + +# Override limits for specific enchants +# +# Enchantments not listed here will use the value of default_limit +# +# Overrides provided default from aqua_affinity to depth_strider won't change effect with extra levels +# +# Valid range of 1 - 255 for each enchantment +enchant_limits: + minecraft:aqua_affinity: 1 + minecraft:binding_curse: 1 + minecraft:channeling: 1 + minecraft:flame: 1 + minecraft:infinity: 1 + minecraft:mending: 1 + minecraft:multishot: 1 + minecraft:silk_touch: 1 + minecraft:vanishing_curse: 1 + minecraft:depth_strider: 3 # anything more than 3 is treated as 3 by the game + minecraft:protection: 4 + minecraft:fire_protection: 4 + minecraft:blast_protection: 4 + minecraft:projectile_protection: 4 + minecraft:feather_falling: 4 + minecraft:thorns: 3 + minecraft:respiration: 3 + minecraft:sharpness: 5 + minecraft:smite: 5 + minecraft:bane_of_arthropods: 5 + minecraft:knockback: 2 + minecraft:fire_aspect: 2 + minecraft:looting: 3 + minecraft:sweeping: 3 + minecraft:sweeping_edge: 3 + minecraft:efficiency: 5 + minecraft:unbreaking: 3 + minecraft:fortune: 3 + minecraft:power: 5 + minecraft:punch: 2 + minecraft:luck_of_the_sea: 3 + minecraft:lure: 3 + minecraft:frost_walker: 2 + minecraft:impaling: 5 + minecraft:riptide: 3 + minecraft:loyalty: 3 + minecraft:piercing: 4 + minecraft:quick_charge: 3 + minecraft:soul_speed: 3 + minecraft:swift_sneak: 3 + minecraft:density: 5 + minecraft:breach: 4 + minecraft:wind_burst: 3 + +# Multipliers used to calculate the enchantment's value in repair/combining +# +# Values here are pulled from the fandom wiki: +# https://minecraft.fandom.com/wiki/Anvil_mechanics#Costs_for_combining_enchantments +# +# If an enchantment is missing values here, or is less than 0, it will default to 0 +# +# Calculated as: [Enchantment lvl] * [multiplier] +# +# With default values protection 4 would have a value of 4 when +# coming from either a book (4 * 1) or an item (4 * 1) +enchant_values: + minecraft:aqua_affinity: + item: 4 + book: 2 + minecraft:bane_of_arthropods: + item: 2 + book: 1 + minecraft:binding_curse: + item: 8 + book: 4 + minecraft:blast_protection: + item: 4 + book: 2 + minecraft:channeling: + item: 8 + book: 4 + minecraft:depth_strider: + item: 4 + book: 2 + minecraft:efficiency: + item: 1 + book: 1 + minecraft:flame: + item: 4 + book: 2 + minecraft:feather_falling: + item: 2 + book: 1 + minecraft:fire_aspect: + item: 4 + book: 2 + minecraft:fire_protection: + item: 2 + book: 1 + minecraft:fortune: + item: 4 + book: 2 + minecraft:frost_walker: + item: 4 + book: 2 + minecraft:impaling: + item: 4 + book: 2 + minecraft:infinity: + item: 8 + book: 4 + minecraft:knockback: + item: 2 + book: 1 + minecraft:looting: + item: 4 + book: 2 + minecraft:loyalty: + item: 1 + book: 1 + minecraft:luck_of_the_sea: + item: 4 + book: 2 + minecraft:lure: + item: 4 + book: 2 + minecraft:mending: + item: 4 + book: 2 + minecraft:multishot: + item: 4 + book: 2 + minecraft:piercing: + item: 1 + book: 1 + minecraft:power: + item: 1 + book: 1 + minecraft:projectile_protection: + item: 2 + book: 1 + minecraft:protection: + item: 1 + book: 1 + minecraft:punch: + item: 4 + book: 2 + minecraft:quick_charge: + item: 2 + book: 1 + minecraft:respiration: + item: 4 + book: 2 + minecraft:riptide: + item: 4 + book: 2 + minecraft:silk_touch: + item: 8 + book: 4 + minecraft:sharpness: + item: 1 + book: 1 + minecraft:smite: + item: 2 + book: 1 + minecraft:soul_speed: + item: 8 + book: 4 + minecraft:swift_sneak: + item: 8 + book: 4 + minecraft:sweeping: + item: 4 + book: 2 + minecraft:sweeping_edge: + item: 4 + book: 2 + minecraft:thorns: + item: 8 + book: 4 + minecraft:unbreaking: + item: 2 + book: 1 + minecraft:vanishing_curse: + item: 8 + book: 4 + minecraft:density: + item: 2 + book: 1 + minecraft:breach: + item: 4 + book: 2 + minecraft:wind_burst: + item: 4 + book: 2 + +# Disable enchantment merging for level above the set value +# Enchantment merging is when, for example, 2 unbreaking II book combine to give sharpness III +# But Enchantment above this value can still be applied. following the previous example, we could still apply a unbreaking III book to a sword +# Even if disable-merge-over of unbreaking is set to 2 +# -1 mean enchantment merge for this enchantment is not disabled. default to -1 if absent. +disable-merge-over: + # Sharpness is set to -1. it equivalent to it not being set to anything (and work as vanilla) + minecraft:sharpness: -1 +# If uncommented. 2 unbreaking II book would not give an unbreaking III book. but unbreaking III book can still be applied +# minecraft:unbreaking: 2 + +# The maximum number of enchantment an item can get. -1 for infinity +# Use eco enchant enchant_limit if present by default unless "default" is not equal to -1 +enchantment_count_limit: + default: -1 + # Limit for specific items. example bellow is an example with stick + # Per item enchantment limit override eco enchant enchant_limit and default limit + items: + stick: -1 + +# Settings for lore modification +lore_edit: + book_and_quil: + # Permission is ca.lore_edit.book + use_permission: true + append: + # If adding lore using book & quil is enabled + enabled: false + # Cost used every time + fixed_cost: 1 + # Cost used for every lore line added + per_line_cost: 0 + # Use left item vanilla cost penalty if any + shared_increase: false + # Increase shared left item cost penalty + shared_additive: false + # If adding the lore consume the book & quil + do_consume: false + # Allow using color code and hexadecimal color when editing lore via book & quil + # + # Color code are prefixed by "&" and hexadecimal color by "#" + # Color code will not be applied if it colors nothing. "&&" can be used to write "&" + allow_color_code: true + allow_hexadecimal_color: true + use_cost: 0 + + remove: + # If removing lore using book & quil is enabled + enabled: false + # Cost used every time + fixed_cost: 1 + # Cost used for every lore line removed + per_line_cost: 0 + # Use left item vanilla cost penalty if any + shared_increase: false + # Increase shared left item cost penalty + shared_additive: false + # If removing the lore consume the book & quil + do_consume: false + # If the color should get back to color code or hex format + remove_color_on_remove: true + # Cost of replacing colors + remove_color_cost: 0 + + paper: + # Permission is ca.lore_edit.paper + use_permission: true + # what order should the lines should get added/removed (start/end, if invalid or not present will be end) + order: end + + append_line: + # If adding lore line using paper is enabled + enabled: false + # Cost used every time + fixed_cost: 1 + # Use left item vanilla cost penalty if any + shared_increase: false + # Increase shared left item cost penalty + shared_additive: false + # If adding the lore line consume the paper + do_consume: false + # Allow using color code and hexadecimal color when editing lore via book & quil + # + # Color code are prefixed by "&" and hexadecimal color by "#" + # Color code will not be applied if it colors nothing. "&&" can be used to write "&" + allow_color_code: true + allow_hexadecimal_color: true + color_use_cost: 0 + use_cost: 0 + + remove_line: + # If removing lore line using paper is enabled + enabled: false + # Cost used every time + fixed_cost: 1 + # Use left item vanilla cost penalty if any + shared_increase: false + # Increase shared left item cost penalty + shared_additive: false + # If removing the lore line consume the paper + do_consume: false + # If the color should get back to color code or hex format + remove_color_on_remove: true + # Cost of replacing colors + remove_color_cost: 0 + +# Whether to show debug logging +debug_log: false + +# Whether to show verbose debug logging +debug_log_verbose: false + +# In case something when wrong with CustomAnvil packet manager. +# If you see "missing class exception" or similar you may test this. +# If enabled and Protocolib absent or disabled "Replace to expensive" will not work. +# ProtocoLib may also be used if the server is in an "unsupported" version even if this option is disabled. +force_protocolib: false + +configVersion: 1.11.0 +lowMinecraftVersion: 1.21.9 diff --git a/defaultconfigs/1.21.9/custom_recipes.yml b/defaultconfigs/1.21.9/custom_recipes.yml new file mode 100644 index 0000000..57c2220 --- /dev/null +++ b/defaultconfigs/1.21.9/custom_recipes.yml @@ -0,0 +1,5 @@ +# ---------------------------------------------------- +# This config file is to store custom craft +# It is recommended to use the in game config editor for this configuration. +# /customanvilconfig With ca.config.edit permission +# ---------------------------------------------------- diff --git a/defaultconfigs/1.21.9/enchant_conflict.yml b/defaultconfigs/1.21.9/enchant_conflict.yml new file mode 100644 index 0000000..04f716f --- /dev/null +++ b/defaultconfigs/1.21.9/enchant_conflict.yml @@ -0,0 +1,382 @@ +# +# It is recommended that you use /configanvil to edit theses config. +# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes ! +# + +# material conflicts +# +# If you want to edit this file: +# - A conflict will apply to every item except if in one of the notAffectedGroups group +# - the conflict will count only if the user try to combine at least as +# many conflicting enchantment as "maxEnchantmentBeforeConflict" +# +# +# ---------------------------------------------------- +# These restriction are about not allowing enchantment +# on illegal items +# ---------------------------------------------------- + +restriction_aqua_affinity: + enchantments: + - minecraft:aqua_affinity + notAffectedGroups: + - enchanted_book + - helmets + +restriction_bane_of_arthropods: + enchantments: + - minecraft:bane_of_arthropods + notAffectedGroups: + - enchanted_book + - melee_weapons + - mace + +restriction_blast_protection: + enchantments: + - minecraft:blast_protection + notAffectedGroups: + - enchanted_book + - armors + +restriction_channeling: + enchantments: + - minecraft:channeling + notAffectedGroups: + - enchanted_book + - trident + +restriction_binding_curse: + enchantments: + - minecraft:binding_curse + notAffectedGroups: + - enchanted_book + - wearable + +restriction_vanishing_curse: + enchantments: + - minecraft:vanishing_curse + notAffectedGroups: + - enchanted_book + - can_vanish + +restriction_depth_strider: + enchantments: + - minecraft:depth_strider + notAffectedGroups: + - enchanted_book + - boots + +restriction_efficiency: + enchantments: + - minecraft:efficiency + notAffectedGroups: + - enchanted_book + - tools + - shears + +restriction_feather_falling: + enchantments: + - minecraft:feather_falling + notAffectedGroups: + - enchanted_book + - boots + +restriction_fire_aspect: + enchantments: + - minecraft:fire_aspect + notAffectedGroups: + - enchanted_book + - swords + - mace + +restriction_fire_protection: + enchantments: + - minecraft:fire_protection + notAffectedGroups: + - enchanted_book + - armors + +restriction_flame: + enchantments: + - minecraft:flame + notAffectedGroups: + - enchanted_book + - bow + +restriction_fortune: + enchantments: + - minecraft:fortune + notAffectedGroups: + - enchanted_book + - tools + +restriction_frost_walker: + enchantments: + - minecraft:frost_walker + notAffectedGroups: + - enchanted_book + - boots + +restriction_impaling: + enchantments: + - minecraft:impaling + notAffectedGroups: + - enchanted_book + - trident + +restriction_infinity: + enchantments: + - minecraft:infinity + notAffectedGroups: + - enchanted_book + - bow + +restriction_knockback: + enchantments: + - minecraft:knockback + notAffectedGroups: + - enchanted_book + - swords + +restriction_looting: + enchantments: + - minecraft:looting + notAffectedGroups: + - enchanted_book + - swords + +restriction_loyalty: + enchantments: + - minecraft:loyalty + notAffectedGroups: + - enchanted_book + - trident + +restriction_lure: + enchantments: + - minecraft:lure + notAffectedGroups: + - enchanted_book + - fishing_rod + +restriction_mending: + enchantments: + - minecraft:mending + notAffectedGroups: + - enchanted_book + - can_unbreak + +restriction_minecraft_multishot: + enchantments: + - minecraft:multishot + notAffectedGroups: + - enchanted_book + - crossbow + +restriction_piercing: + enchantments: + - minecraft:piercing + notAffectedGroups: + - enchanted_book + - crossbow + +restriction_power: + enchantments: + - minecraft:power + notAffectedGroups: + - enchanted_book + - bow + +restriction_projectile_protection: + enchantments: + - minecraft:projectile_protection + notAffectedGroups: + - enchanted_book + - armors + +restriction_protection: + enchantments: + - minecraft:protection + notAffectedGroups: + - enchanted_book + - armors + +restriction_punch: + enchantments: + - minecraft:punch + notAffectedGroups: + - enchanted_book + - bow + +restriction_quick_charge: + enchantments: + - minecraft:quick_charge + notAffectedGroups: + - enchanted_book + - crossbow + +restriction_respiration: + enchantments: + - minecraft:respiration + notAffectedGroups: + - enchanted_book + - helmets + +restriction_riptide: + enchantments: + - minecraft:riptide + notAffectedGroups: + - enchanted_book + - trident + +restriction_sharpness: + enchantments: + - minecraft:sharpness + notAffectedGroups: + - enchanted_book + - melee_weapons + +restriction__silk_touch: + enchantments: + - minecraft:silk_touch + notAffectedGroups: + - enchanted_book + - tools + +restriction_smite: + enchantments: + - minecraft:smite + notAffectedGroups: + - enchanted_book + - melee_weapons + - mace + +restriction_soul_speed: + enchantments: + - minecraft:soul_speed + notAffectedGroups: + - enchanted_book + - boots + +restriction_sweeping_edge: + enchantments: + - minecraft:sweeping + - minecraft:sweeping_edge + notAffectedGroups: + - enchanted_book + - swords + +# Do not exist in 1.18, that mean useInFuture will be set to true +# useInFuture set to true also mean it will not warn if there is an issue +restriction_swift_sneak: + useInFuture: true + enchantments: + - minecraft:swift_sneak + notAffectedGroups: + - enchanted_book + - leggings + +restriction_thorns: + enchantments: + - minecraft:thorns + notAffectedGroups: + - enchanted_book + - armors + +restriction__unbreaking: + enchantments: + - minecraft:unbreaking + notAffectedGroups: + - enchanted_book + - can_unbreak + +# ---------------------------------------------------- +# Now we have conflicts about enchantment Incompatibility +# We just filtered what item enchantments can be applied +# notAffectedGroups is empty as we don't want anything to not respect theses rules +# maxEnchantmentBeforeConflict is set to 1 to only have 1 on those enchantment available +# ---------------------------------------------------- + +sword_enchant_conflict: + enchantments: + - minecraft:bane_of_arthropods + - minecraft:smite + - minecraft:sharpness + - minecraft:density + - minecraft:breach + notAffectedGroups: [] + maxEnchantmentBeforeConflict: 1 + +protection_enchant_conflict: + enchantments: + - minecraft:blast_protection + - minecraft:fire_protection + - minecraft:projectile_protection + - minecraft:protection + notAffectedGroups: [] + maxEnchantmentBeforeConflict: 1 + +trident_conflict1: + enchantments: + - minecraft:channeling + - minecraft:riptide + notAffectedGroups: [] + maxEnchantmentBeforeConflict: 1 + +trident_conflict2: + enchantments: + - minecraft:loyalty + - minecraft:riptide + notAffectedGroups: [] + maxEnchantmentBeforeConflict: 1 + +boot_conflict: + enchantments: + - minecraft:depth_strider + - minecraft:frost_walker + notAffectedGroups: [] + maxEnchantmentBeforeConflict: 1 + +tool_conflict: + enchantments: + - minecraft:fortune + - minecraft:silk_touch + notAffectedGroups: [] + maxEnchantmentBeforeConflict: 1 + +bow_conflict: + enchantments: + - minecraft:mending + - minecraft:infinity + notAffectedGroups: [] + maxEnchantmentBeforeConflict: 1 + +crossbow_conflict: + enchantments: + - minecraft:multishot + - minecraft:piercing + notAffectedGroups: [] + maxEnchantmentBeforeConflict: 1 +restriction_density: + enchantments: + - minecraft:density + notAffectedGroups: + - mace + - enchanted_book +restriction_breach: + enchantments: + - minecraft:breach + notAffectedGroups: + - mace + - enchanted_book +restriction_wind_burst: + enchantments: + - minecraft:wind_burst + notAffectedGroups: + - mace + - enchanted_book + +# ---------------------------------------------------- +# Bellow is for custom conflicts. +# This is also where conflict create from the gui will be placed. +# ---------------------------------------------------- diff --git a/defaultconfigs/1.21.9/item_groups.yml b/defaultconfigs/1.21.9/item_groups.yml new file mode 100644 index 0000000..2dbd5db --- /dev/null +++ b/defaultconfigs/1.21.9/item_groups.yml @@ -0,0 +1,236 @@ +# +# It is recommended that you use /configanvil to edit theses config. +# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes ! +# + +# Please note this config use spigot material names. +# It should match minecraft name in most case, maybe every case, but I can't be sure +# In case there an issue with material name, you can found them here: +# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html + +# An empty Exclude group exclude nothing, so it contain everything +everything: + type: exclude + +# An empty include group will include nothing +nothing: + type: include + +# This group is an example of a group including only stone and polished granite +example_include: + type: include + items: + - stone + - polished_granite + +# This group contain everything except polished granite and elements of example_include +example_exclude: + type: exclude + items: + - polished_granite + groups: + - example_include + +# Default configuration should be vanilla enchantment conflict group +# there may have error, if you find one you can fix it ! +# https://minecraft.fandom.com/wiki/Enchanting + +swords: + type: include + items: + - wooden_sword + - stone_sword + - iron_sword + - diamond_sword + - golden_sword + - netherite_sword + - copper_sword + +axes: + type: include + items: + - wooden_axe + - stone_axe + - iron_axe + - diamond_axe + - golden_axe + - netherite_axe + - copper_axe + +melee_weapons: + type: include + groups: + - swords + - axes + +helmets: + type: include + items: + - leather_helmet + - chainmail_helmet + - iron_helmet + - diamond_helmet + - golden_helmet + - netherite_helmet + - turtle_helmet + - copper_helmet + +chestplate: + type: include + items: + - leather_chestplate + - chainmail_chestplate + - iron_chestplate + - diamond_chestplate + - golden_chestplate + - netherite_chestplate + - copper_chestplate + +leggings: + type: include + items: + - leather_leggings + - chainmail_leggings + - iron_leggings + - diamond_leggings + - golden_leggings + - netherite_leggings + - copper_leggings + +boots: + type: include + items: + - leather_boots + - chainmail_boots + - iron_boots + - diamond_boots + - golden_boots + - netherite_boots + - copper_boots + +armors: + type: include + groups: + - helmets + - chestplate + - leggings + - boots + +wearable: + type: include + items: + - elytra + - carved_pumpkin + - skeleton_skull + - wither_skeleton_skull + - zombie_head + - player_head + - creeper_head + - dragon_head + - piglin_head + groups: + - armors + +pickaxes: + type: include + items: + - wooden_pickaxe + - stone_pickaxe + - iron_pickaxe + - diamond_pickaxe + - golden_pickaxe + - netherite_pickaxe + - copper_pickaxe + +shovels: + type: include + items: + - wooden_shovel + - stone_shovel + - iron_shovel + - diamond_shovel + - golden_shovel + - netherite_shovel + - copper_shovel + +hoes: + type: include + items: + - wooden_hoe + - stone_hoe + - iron_hoe + - diamond_hoe + - golden_hoe + - netherite_hoe + - copper_hoe + +tools: + type: include + groups: + - pickaxes + - shovels + - hoes + - axes + +enchanted_book: + type: include + items: + - enchanted_book + +trident: + type: include + items: + - trident + +bow: + type: include + items: + - bow + +crossbow: + type: include + items: + - crossbow + +fishing_rod: + type: include + items: + - fishing_rod + +shears: + type: include + items: + - shears + +can_unbreak: + type: include + items: + - elytra + - flint_and_steel + - shield + - carrot_on_a_stick + - warped_fungus_on_a_stick + - brush + groups: + - melee_weapons + - tools + - armors + - trident + - bow + - crossbow + - fishing_rod + - shears + - mace + +can_vanish: + type: include + items: + - compass + groups: + - wearable + - can_unbreak +mace: + type: include + items: + - mace + diff --git a/defaultconfigs/1.21.9/unit_repair_item.yml b/defaultconfigs/1.21.9/unit_repair_item.yml new file mode 100644 index 0000000..0ce2bce --- /dev/null +++ b/defaultconfigs/1.21.9/unit_repair_item.yml @@ -0,0 +1,192 @@ +# +# It is recommended that you use /configanvil to edit theses config. +# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes ! +# + +# Unit repair configuration +# +# This configuration is to make custom unit repair +# A unit repair is, for example, a diamond to repair a diamond sword +# In vanilla, a unit repair 25% of object durability +# you can make a custom value here +# +# Item name should NOT combine caps and no caps (example: Stone) + +# Default value if the config is an invalid value (value <= 0 ) +# If value > 1 it will be treated as being = 1 +default_repair_amount: 0.25 + +# You can add custom unit repair +# The example bellow make a shield repaired by 10% by sticks + +# stick: +# shield: 0.10 + + +# Vanilla unit repair group is bellow +diamond: + diamond_helmet: 0.25 + diamond_chestplate: 0.25 + diamond_leggings: 0.25 + diamond_boots: 0.25 + diamond_sword: 0.25 + diamond_pickaxe: 0.25 + diamond_axe: 0.25 + diamond_shovel: 0.25 + diamond_hoe: 0.25 + +netherite_ingot: + netherite_helmet: 0.25 + netherite_chestplate: 0.25 + netherite_leggings: 0.25 + netherite_boots: 0.25 + netherite_sword: 0.25 + netherite_pickaxe: 0.25 + netherite_axe: 0.25 + netherite_shovel: 0.25 + netherite_hoe: 0.25 + +gold_ingot: + golden_helmet: 0.25 + golden_chestplate: 0.25 + golden_leggings: 0.25 + golden_boots: 0.25 + golden_sword: 0.25 + golden_pickaxe: 0.25 + golden_axe: 0.25 + golden_shovel: 0.25 + golden_hoe: 0.25 + +iron_ingot: + iron_helmet: 0.25 + iron_chestplate: 0.25 + iron_leggings: 0.25 + iron_boots: 0.25 + iron_sword: 0.25 + iron_pickaxe: 0.25 + iron_axe: 0.25 + iron_shovel: 0.25 + iron_hoe: 0.25 + +cobblestone: + stone_sword: 0.25 + stone_pickaxe: 0.25 + stone_axe: 0.25 + stone_shovel: 0.25 + stone_hoe: 0.25 + +cobbled_deepslate: + stone_sword: 0.25 + stone_pickaxe: 0.25 + stone_axe: 0.25 + stone_shovel: 0.25 + stone_hoe: 0.25 + +blackstone: + stone_sword: 0.25 + stone_pickaxe: 0.25 + stone_axe: 0.25 + stone_shovel: 0.25 + stone_hoe: 0.25 + +leather: + leather_helmet: 0.25 + leather_chestplate: 0.25 + leather_leggings: 0.25 + leather_boots: 0.25 + +phantom_membrane: + elytra: 0.25 + +scute: + turtle_helmet: 0.25 + +oak_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +spruce_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +birch_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +jungle_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +acacia_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +dark_oak_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +mangrove_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +cherry_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +bamboo_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +crimson_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +warped_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 +breeze_rod: + mace: 0.25 From 49845f8d6b0708b5b914dfdd232791f277a533f9 Mon Sep 17 00:00:00 2001 From: alexcrea Date: Thu, 25 Sep 2025 20:34:00 +0200 Subject: [PATCH 07/10] prepare version bumb --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 23cb67e..9aeb5ab 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,7 @@ plugins { } group = "xyz.alexcrea" -version = "1.14.2" +version = "1.15.0" val effectiveVersion = "$version" + (if (System.getenv("SMALL_COMMIT_HASH") != null) "-dev-${System.getenv("SMALL_COMMIT_HASH")!!}" else "") From 07f6da525d9155670a90f61b798d824e3e790f4a Mon Sep 17 00:00:00 2001 From: alexcrea <42614139+alexcrea@users.noreply.github.com> Date: Sat, 27 Sep 2025 13:19:21 +0200 Subject: [PATCH 08/10] Revert "drop 1.17.x to 1.18.x nms" This reverts commit 3ab6dbc155aa3db8634e48c7c5ab036de0a26882. --- README.md | 3 +- build.gradle.kts | 3 ++ nms/v1_17R1/.gitignore | 1 + nms/v1_17R1/build.gradle.kts | 35 +++++++++++++++++++ .../gui/version/v1_17R1_ExternGuiTester.kt | 16 +++++++++ .../packet/versions/V1_17R1_PacketManager.kt | 33 +++++++++++++++++ nms/v1_18R1/.gitignore | 1 + nms/v1_18R1/build.gradle.kts | 35 +++++++++++++++++++ .../gui/version/v1_18R1_ExternGuiTester.kt | 16 +++++++++ .../packet/versions/V1_18R1_PacketManager.kt | 33 +++++++++++++++++ nms/v1_18R2/.gitignore | 1 + nms/v1_18R2/build.gradle.kts | 35 +++++++++++++++++++ .../gui/version/v1_18R2_ExternGuiTester.kt | 16 +++++++++ .../packet/versions/V1_18R2_PacketManager.kt | 33 +++++++++++++++++ settings.gradle.kts | 6 ++++ .../dependency/gui/GuiTesterSelector.kt | 13 ++++++- .../packet/PacketManagerSelector.kt | 14 ++++++-- 17 files changed, 290 insertions(+), 4 deletions(-) create mode 100644 nms/v1_17R1/.gitignore create mode 100644 nms/v1_17R1/build.gradle.kts create mode 100644 nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_17R1_ExternGuiTester.kt create mode 100644 nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_17R1_PacketManager.kt create mode 100644 nms/v1_18R1/.gitignore create mode 100644 nms/v1_18R1/build.gradle.kts create mode 100644 nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R1_ExternGuiTester.kt create mode 100644 nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R1_PacketManager.kt create mode 100644 nms/v1_18R2/.gitignore create mode 100644 nms/v1_18R2/build.gradle.kts create mode 100644 nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R2_ExternGuiTester.kt create mode 100644 nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R2_PacketManager.kt diff --git a/README.md b/README.md index 3c207da..829eeb0 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ **Custom Anvil** is a plugin that allows server administrators to customize every aspect of the anvil's mechanics. It is expected to work on 1.18 to 1.21.7 minecraft servers running spigot or paper. +(the plugin support of 1.16.5 to 1.17.1 is experimental and may encounter issues) **Custom Anvil** was previously named **Unsafe Enchants+**. It was renamed because it now affects every anvil aspect and not only unsafe enchants\ @@ -86,7 +87,7 @@ as low priority as I work for the plugin on my free time for free. One of the configurations allow displaying price about 40 and removing Too Expensive. \ By how the minecraft client work: price above 40 can only be displayed green, even if the player does not own enough experience level. -Minecraft version 1.19 to 1.21.7 do not need any dependency. Other version need ProtocoLib enabled on your server for this feature. \ +Minecraft version 1.17 to 1.21.7 do not need any dependency. Other version need ProtocoLib enabled on your server for this feature. \ You can also wait for an update of the plugin to support a newer version. Please note that 1.16.5 to 1.17.1 are not officially supported. Run at your own risk. diff --git a/build.gradle.kts b/build.gradle.kts index 9aeb5ab..3bee4ce 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -69,6 +69,9 @@ dependencies { // Include nms implementation(project(":nms:nms-common")) + implementation(project(":nms:v1_17R1", configuration = "reobf")) + implementation(project(":nms:v1_18R1", configuration = "reobf")) + implementation(project(":nms:v1_18R2", configuration = "reobf")) implementation(project(":nms:v1_19R1", configuration = "reobf")) implementation(project(":nms:v1_19R2", configuration = "reobf")) implementation(project(":nms:v1_19R3", configuration = "reobf")) diff --git a/nms/v1_17R1/.gitignore b/nms/v1_17R1/.gitignore new file mode 100644 index 0000000..47374f1 --- /dev/null +++ b/nms/v1_17R1/.gitignore @@ -0,0 +1 @@ +.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_17R1/build.gradle.kts b/nms/v1_17R1/build.gradle.kts new file mode 100644 index 0000000..9a79bca --- /dev/null +++ b/nms/v1_17R1/build.gradle.kts @@ -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.17.1-R0.1-SNAPSHOT") +} + +repositories { + maven("https://repo.papermc.io/repository/maven-public/") + +} + +// Set target version +tasks.withType().configureEach { + sourceCompatibility = "16" + targetCompatibility = "16" + + options.encoding = "UTF-8" +} + +kotlin { + compilerOptions { + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0) + jvmTarget.set(JvmTarget.JVM_16) + } +} diff --git a/nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_17R1_ExternGuiTester.kt b/nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_17R1_ExternGuiTester.kt new file mode 100644 index 0000000..8e352e0 --- /dev/null +++ b/nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_17R1_ExternGuiTester.kt @@ -0,0 +1,16 @@ +package xyz.alexcrea.cuanvil.dependency.gui.version + +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryView +import org.bukkit.inventory.InventoryView +import xyz.alexcrea.cuanvil.dependency.gui.ExternGuiTester + +class v1_17R1_ExternGuiTester: ExternGuiTester { + override val wesjdAnvilGuiName = "Wrapper1_17_R1" + + override fun getContainerClass(view: InventoryView): Class? { + if (view !is CraftInventoryView) return null + val container = view.handle + + return container.javaClass + } +} \ No newline at end of file diff --git a/nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_17R1_PacketManager.kt b/nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_17R1_PacketManager.kt new file mode 100644 index 0000000..c820eab --- /dev/null +++ b/nms/v1_17R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_17R1_PacketManager.kt @@ -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.v1_17_R1.entity.CraftPlayer +import org.bukkit.entity.Player +import xyz.alexcrea.cuanvil.dependency.packet.PacketManager +import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase + +class V1_17R1_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_18R1/.gitignore b/nms/v1_18R1/.gitignore new file mode 100644 index 0000000..47374f1 --- /dev/null +++ b/nms/v1_18R1/.gitignore @@ -0,0 +1 @@ +.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_18R1/build.gradle.kts b/nms/v1_18R1/build.gradle.kts new file mode 100644 index 0000000..0ed9674 --- /dev/null +++ b/nms/v1_18R1/build.gradle.kts @@ -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.18.1-R0.1-SNAPSHOT") +} + +repositories { + maven("https://repo.papermc.io/repository/maven-public/") + +} + +// Set target version +tasks.withType().configureEach { + sourceCompatibility = "17" + targetCompatibility = "17" + + options.encoding = "UTF-8" +} + +kotlin { + compilerOptions { + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0) + jvmTarget.set(JvmTarget.JVM_17) + } +} diff --git a/nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R1_ExternGuiTester.kt b/nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R1_ExternGuiTester.kt new file mode 100644 index 0000000..659a0f6 --- /dev/null +++ b/nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R1_ExternGuiTester.kt @@ -0,0 +1,16 @@ +package xyz.alexcrea.cuanvil.dependency.gui.version + +import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryView +import org.bukkit.inventory.InventoryView +import xyz.alexcrea.cuanvil.dependency.gui.ExternGuiTester + +class v1_18R1_ExternGuiTester: ExternGuiTester { + override val wesjdAnvilGuiName = "Wrapper1_18_R1" + + override fun getContainerClass(view: InventoryView): Class? { + if (view !is CraftInventoryView) return null + val container = view.handle + + return container.javaClass + } +} \ No newline at end of file diff --git a/nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R1_PacketManager.kt b/nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R1_PacketManager.kt new file mode 100644 index 0000000..71df5c7 --- /dev/null +++ b/nms/v1_18R1/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R1_PacketManager.kt @@ -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.v1_18_R1.entity.CraftPlayer +import org.bukkit.entity.Player +import xyz.alexcrea.cuanvil.dependency.packet.PacketManager +import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase + +class V1_18R1_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_18R2/.gitignore b/nms/v1_18R2/.gitignore new file mode 100644 index 0000000..47374f1 --- /dev/null +++ b/nms/v1_18R2/.gitignore @@ -0,0 +1 @@ +.lastDeploymentsId \ No newline at end of file diff --git a/nms/v1_18R2/build.gradle.kts b/nms/v1_18R2/build.gradle.kts new file mode 100644 index 0000000..2cc9659 --- /dev/null +++ b/nms/v1_18R2/build.gradle.kts @@ -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.18.2-R0.1-SNAPSHOT") +} + +repositories { + maven("https://repo.papermc.io/repository/maven-public/") + +} + +// Set target version +tasks.withType().configureEach { + sourceCompatibility = "17" + targetCompatibility = "17" + + options.encoding = "UTF-8" +} + +kotlin { + compilerOptions { + apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0) + jvmTarget.set(JvmTarget.JVM_17) + } +} diff --git a/nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R2_ExternGuiTester.kt b/nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R2_ExternGuiTester.kt new file mode 100644 index 0000000..1447716 --- /dev/null +++ b/nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/version/v1_18R2_ExternGuiTester.kt @@ -0,0 +1,16 @@ +package xyz.alexcrea.cuanvil.dependency.gui.version + +import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryView +import org.bukkit.inventory.InventoryView +import xyz.alexcrea.cuanvil.dependency.gui.ExternGuiTester + +class v1_18R2_ExternGuiTester: ExternGuiTester { + override val wesjdAnvilGuiName = "Wrapper1_18_R2" + + override fun getContainerClass(view: InventoryView): Class? { + if (view !is CraftInventoryView) return null + val container = view.handle + + return container.javaClass + } +} \ No newline at end of file diff --git a/nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R2_PacketManager.kt b/nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R2_PacketManager.kt new file mode 100644 index 0000000..ee442f5 --- /dev/null +++ b/nms/v1_18R2/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/versions/V1_18R2_PacketManager.kt @@ -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.v1_18_R2.entity.CraftPlayer +import org.bukkit.entity.Player +import xyz.alexcrea.cuanvil.dependency.packet.PacketManager +import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase + +class V1_18R2_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/settings.gradle.kts b/settings.gradle.kts index a63389b..867d1bc 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,6 +3,12 @@ rootProject.name = "CustomAnvil" // NMS subproject include("nms:nms-common") findProject(":nms:nms-common")?.name = "nms-common" +include("nms:v1_17R1") +findProject(":nms:v1_17R1")?.name = "v1_17R1" +include("nms:v1_18R1") +findProject(":nms:v1_18R1")?.name = "v1_18R1" +include("nms:v1_18R2") +findProject(":nms:v1_18R2")?.name = "v1_18R2" include("nms:v1_19R1") findProject(":nms:v1_19R1")?.name = "v1_19R1" include("nms:v1_19R2") diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt index d819430..8e4623c 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt @@ -11,7 +11,18 @@ object GuiTesterSelector { if (versionParts[0] != 1) return null return when (versionParts[1]) { - // Can't support 1.16.5-1.18.x paper userdev do not exist or broken + // Can't support 1.16.5 bc 1.16.5 paper userdev do not exist + + 17 -> when (versionParts[2]) { + 0, 1 -> v1_17R1_ExternGuiTester() + else -> null + } + + 18 -> when (versionParts[2]) { + 0, 1 -> v1_18R1_ExternGuiTester() + 2 -> v1_18R2_ExternGuiTester() + else -> null + } 19 -> when (versionParts[2]) { 0, 1, 2 -> v1_19R1_ExternGuiTester() 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 7ba3586..9ec231b 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/PacketManagerSelector.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/packet/PacketManagerSelector.kt @@ -19,14 +19,24 @@ object PacketManagerSelector { ProtocoLibWrapper() else NoPacketManager() - private val versionSpecificManager: PacketManagerBase? get() { val versionParts = UpdateUtils.currentMinecraftVersionArray() if (versionParts[0] != 1) return null return when (versionParts[1]) { - // Can't support 1.16.5 to 1.18.x bc paper userdev do not exist or broken + // Can't support 1.16.5 bc 1.16.5 paper userdev do not exist + + 17 -> when (versionParts[2]) { + 0, 1 -> V1_17R1_PacketManager() + else -> null + } + + 18 -> when (versionParts[2]) { + 0, 1 -> V1_18R1_PacketManager() + 2 -> V1_18R2_PacketManager() + else -> null + } 19 -> when (versionParts[2]) { 0, 1, 2 -> V1_19R1_PacketManager() From f907a4b6c4b2f0648e7a8f1234487f97afe2f348 Mon Sep 17 00:00:00 2001 From: alexcrea <42614139+alexcrea@users.noreply.github.com> Date: Sat, 27 Sep 2025 19:01:36 +0200 Subject: [PATCH 09/10] prepare release --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3bee4ce..3dfc3c8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -84,7 +84,7 @@ dependencies { implementation(project(":nms:v1_21R3", configuration = "reobf")) implementation(project(":nms:v1_21R4", configuration = "reobf")) implementation(project(":nms:v1_21R5", configuration = "reobf")) - implementation(project(":nms:v1_21R6"))//, configuration = "reobf")) //TODO add back when 1.21.9 release + implementation(project(":nms:v1_21R6", configuration = "reobf")) // include kotlin for the offline jar implementation(kotlin("stdlib")) From 8615ec82e274788e6c9da42470d7205aa8424746 Mon Sep 17 00:00:00 2001 From: alexcrea <42614139+alexcrea@users.noreply.github.com> Date: Sat, 27 Sep 2025 19:03:04 +0200 Subject: [PATCH 10/10] Prepare for release --- nms/v1_21R6/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nms/v1_21R6/build.gradle.kts b/nms/v1_21R6/build.gradle.kts index 1ec1258..f124fdd 100644 --- a/nms/v1_21R6/build.gradle.kts +++ b/nms/v1_21R6/build.gradle.kts @@ -11,7 +11,7 @@ dependencies { implementation(project(":nms:nms-common")) // Used for nms - paperweight.paperDevBundle("1.21.9-pre4-R0.1-SNAPSHOT") + paperweight.paperDevBundle("1.21.9-R0.1-SNAPSHOT") } repositories {