mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
Compare commits
4 commits
6c4991f852
...
4b3fd76dd0
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b3fd76dd0 | |||
| fc4df29033 | |||
| 6ea8430247 | |||
| ca89b0d095 |
19 changed files with 78 additions and 38 deletions
|
|
@ -8,17 +8,17 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.3.0"
|
kotlin("jvm") version "2.4.0"
|
||||||
java
|
java
|
||||||
id("org.jetbrains.dokka").version("1.9.20")
|
id("org.jetbrains.dokka").version("2.2.0")
|
||||||
id("com.gradleup.shadow").version("9.3.0")
|
id("com.gradleup.shadow").version("9.6.1")
|
||||||
// Maven publish
|
// Maven publish
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
signing
|
signing
|
||||||
id("cn.lalaki.central").version("1.2.8")
|
id("cn.lalaki.central").version("2.0.8")
|
||||||
// Paper
|
// Paper
|
||||||
id("io.papermc.paperweight.userdev") version "2.0.0-beta.17" apply false
|
id("io.papermc.paperweight.userdev") version "2.0.0-beta.21" apply false
|
||||||
id("io.papermc.hangar-publish-plugin") version "0.1.2"
|
id("io.papermc.hangar-publish-plugin") version "0.1.4"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "xyz.alexcrea"
|
group = "xyz.alexcrea"
|
||||||
|
|
@ -166,7 +166,7 @@ allprojects {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -178,7 +178,10 @@ tasks {
|
||||||
|
|
||||||
fun ShadowJar.configureBaseShadow(suffix: String, libraries: Array<String>) {
|
fun ShadowJar.configureBaseShadow(suffix: String, libraries: Array<String>) {
|
||||||
val processedSuffix = if(suffix.isEmpty()) "" else "-$suffix"
|
val processedSuffix = if(suffix.isEmpty()) "" else "-$suffix"
|
||||||
val name = "${rootProject.name}-${effectiveVersion}${processedSuffix}.jar"
|
val version = effectiveVersion
|
||||||
|
val name = "${rootProject.name}-${version}${processedSuffix}.jar"
|
||||||
|
val librariesExpendTo = libraries.joinToString(transform = { "\"$it\"" })
|
||||||
|
|
||||||
archiveFileName.set(name)
|
archiveFileName.set(name)
|
||||||
|
|
||||||
// Shadow necessary dependency
|
// Shadow necessary dependency
|
||||||
|
|
@ -187,8 +190,8 @@ tasks {
|
||||||
|
|
||||||
filesMatching("plugin.yml") {
|
filesMatching("plugin.yml") {
|
||||||
expand(
|
expand(
|
||||||
"version" to effectiveVersion + processedSuffix,
|
"version" to version + processedSuffix,
|
||||||
"libraries" to libraries.joinToString(transform = { "\"$it\"" }),
|
"libraries" to librariesExpendTo,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -200,7 +203,7 @@ tasks {
|
||||||
shadowJar {
|
shadowJar {
|
||||||
configureBaseShadow("",
|
configureBaseShadow("",
|
||||||
arrayOf(
|
arrayOf(
|
||||||
"org.jetbrains.kotlin:kotlin-stdlib:2.3.0",
|
"org.jetbrains.kotlin:kotlin-stdlib:2.4.0",
|
||||||
"net.kyori:adventure-text-minimessage:4.25.0",
|
"net.kyori:adventure-text-minimessage:4.25.0",
|
||||||
"net.kyori:adventure-text-serializer-plain:4.25.0",
|
"net.kyori:adventure-text-serializer-plain:4.25.0",
|
||||||
"net.kyori:adventure-text-serializer-legacy:4.25.0",
|
"net.kyori:adventure-text-serializer-legacy:4.25.0",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
org.gradle.configuration-cache=true
|
||||||
|
|
||||||
# Signing
|
# Signing
|
||||||
signing.secretKeyRingFile=~/.gnupg/secring.gpg
|
signing.secretKeyRingFile=~/.gnupg/secring.gpg
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ group = rootProject.group
|
||||||
version = rootProject.version
|
version = rootProject.version
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.3.0"
|
kotlin("jvm") version "2.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ group = rootProject.group
|
||||||
version = rootProject.version
|
version = rootProject.version
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.3.0"
|
kotlin("jvm") version "2.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Imitate needed class and method to support legacy version of EcoEnchant
|
// Imitate needed class and method to support legacy version of EcoEnchant
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,39 @@
|
||||||
|
@file:Suppress("DEPRECATION", "removal")
|
||||||
package xyz.alexcrea.cuanvil.dependency.datapack
|
package xyz.alexcrea.cuanvil.dependency.datapack
|
||||||
|
|
||||||
import io.papermc.paper.datapack.Datapack
|
import io.papermc.paper.datapack.Datapack
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.packs.DataPack
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object DataPackTester {
|
object DataPackTester {
|
||||||
|
val legacyNames: List<String>
|
||||||
|
get() = Bukkit.getDataPackManager().dataPacks
|
||||||
|
.stream().filter { obj -> obj.isEnabled }
|
||||||
|
.map { pack -> pack.key.key }
|
||||||
|
.toList()
|
||||||
|
|
||||||
val enabledPacks: List<String>
|
val enabledPacks: List<String>
|
||||||
get() {
|
get() {
|
||||||
return try {
|
try {
|
||||||
Bukkit.getDatapackManager().enabledPacks
|
// will throw error if do not exist
|
||||||
|
Bukkit::class.java.getDeclaredMethod("getDatapackManager")
|
||||||
|
|
||||||
|
return Bukkit.getDatapackManager().enabledPacks
|
||||||
.stream().map { obj: Datapack -> obj.name }
|
.stream().map { obj: Datapack -> obj.name }
|
||||||
.toList()
|
.toList()
|
||||||
|
} catch(_: NoSuchMethodException) {
|
||||||
|
try {
|
||||||
|
DataPack::class.java.getDeclaredMethod("getKey")
|
||||||
|
} catch(_: NoSuchMethodException) {
|
||||||
|
System.err.println("Could not find compatible datapack manager")
|
||||||
|
System.err.println("If you are using a datapack that should be compatible with CustomAnvil. It will not get detected...")
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
return legacyNames
|
||||||
} catch(_: Exception) {
|
} catch(_: Exception) {
|
||||||
// Assume cause UnimplementedOperationException on mock server
|
// Assume cause UnimplementedOperationException on mock server
|
||||||
Collections.emptyList()
|
return Collections.emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ object AnvilTitleUtil {
|
||||||
|
|
||||||
private val runTaskMap = HashMap<UUID, ScheduledTask>()
|
private val runTaskMap = HashMap<UUID, ScheduledTask>()
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
private fun actualRename(view: AnvilView, name: String, player: HumanEntity, anvilDialog: AnvilRenameDialog) {
|
private fun actualRename(view: AnvilView, name: String, player: HumanEntity, anvilDialog: AnvilRenameDialog) {
|
||||||
runTaskMap.remove(player.uniqueId)
|
runTaskMap.remove(player.uniqueId)
|
||||||
if (view.title == name) return
|
if (view.title == name) return
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
||||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil.componentLore
|
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil.componentLore
|
||||||
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_OUTPUT_SLOT
|
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_OUTPUT_SLOT
|
||||||
import xyz.alexcrea.cuanvil.util.MetricsUtil.trackError
|
import xyz.alexcrea.cuanvil.util.MetricsUtil.trackError
|
||||||
import java.lang.reflect.Constructor
|
import java.lang.IllegalStateException
|
||||||
import java.util.logging.Level
|
import java.util.logging.Level
|
||||||
|
|
||||||
@Suppress("UnstableApiUsage")
|
@Suppress("UnstableApiUsage")
|
||||||
|
|
@ -337,10 +337,14 @@ object DependencyManager {
|
||||||
|
|
||||||
|
|
||||||
private val prepareAnvilConstructor =
|
private val prepareAnvilConstructor =
|
||||||
PrepareAnvilEvent::class.java.constructors.first() as Constructor<PrepareAnvilEvent>
|
PrepareAnvilEvent::class.java.constructors.first()
|
||||||
|
|
||||||
fun createFakeEvent(view: AnvilView, result: ItemStack?): PrepareAnvilEvent {
|
fun createFakeEvent(view: AnvilView, result: ItemStack?): PrepareAnvilEvent {
|
||||||
return prepareAnvilConstructor.newInstance(view, result)
|
val result = prepareAnvilConstructor.newInstance(view, result)
|
||||||
|
if(result !is PrepareAnvilEvent)
|
||||||
|
throw IllegalStateException("Could not create a PrepareAnvilEvent ?")
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import org.bukkit.NamespacedKey
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.plugin.Plugin
|
import org.bukkit.plugin.Plugin
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
class ItemsAdderDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
class ItemsAdderDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
||||||
var isLoaded: Boolean = false
|
var isLoaded: Boolean = false
|
||||||
get() {
|
get() {
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,20 @@ class LegacyEcoEnchantDependency {
|
||||||
|
|
||||||
|
|
||||||
private var ecoEnchantOldEnchantments: MutableSet<EcoEnchant>? = null
|
private var ecoEnchantOldEnchantments: MutableSet<EcoEnchant>? = null
|
||||||
|
private fun unregisterEnchantment(enchant: Any) {
|
||||||
|
EnchantmentApi.unregisterEnchantment((enchant as Enchantment).key)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun registerEnchantment(ecoEnchant: EcoEnchant, enchant: Any) {
|
||||||
|
EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, enchant as Enchantment))
|
||||||
|
}
|
||||||
|
|
||||||
fun registerEnchantments() {
|
fun registerEnchantments() {
|
||||||
val enchantments = EcoEnchants.values()
|
val enchantments = EcoEnchants.values()
|
||||||
for (ecoEnchant in enchantments) {
|
for (ecoEnchant in enchantments) {
|
||||||
ecoEnchant as Enchantment
|
// As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant.
|
||||||
|
unregisterEnchantment(ecoEnchant)
|
||||||
EnchantmentApi.unregisterEnchantment(ecoEnchant) // As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant.
|
registerEnchantment(ecoEnchant, ecoEnchant)
|
||||||
EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, ecoEnchant))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ecoEnchantOldEnchantments = HashSet(enchantments)
|
ecoEnchantOldEnchantments = HashSet(enchantments)
|
||||||
|
|
@ -31,13 +38,13 @@ class LegacyEcoEnchantDependency {
|
||||||
// Add new enchantments
|
// Add new enchantments
|
||||||
for (ecoEnchant in newEnchantments)
|
for (ecoEnchant in newEnchantments)
|
||||||
if (!this.ecoEnchantOldEnchantments!!.contains(ecoEnchant))
|
if (!this.ecoEnchantOldEnchantments!!.contains(ecoEnchant))
|
||||||
EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, ecoEnchant as Enchantment))
|
registerEnchantment(ecoEnchant, ecoEnchant)
|
||||||
|
|
||||||
|
|
||||||
// Remove old enchantments that not now currently used
|
// Remove old enchantments that not now currently used
|
||||||
this.ecoEnchantOldEnchantments!!.removeAll(newEnchantments)
|
this.ecoEnchantOldEnchantments!!.removeAll(newEnchantments)
|
||||||
for (oldEnchantment in this.ecoEnchantOldEnchantments!!) {
|
for (oldEnchantment in this.ecoEnchantOldEnchantments!!) {
|
||||||
EnchantmentApi.unregisterEnchantment(oldEnchantment as Enchantment)
|
unregisterEnchantment(oldEnchantment)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ecoEnchantOldEnchantments = HashSet(newEnchantments)
|
this.ecoEnchantOldEnchantments = HashSet(newEnchantments)
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,13 @@ class ToolStatsDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
||||||
getTokenMethod.trySetAccessible()
|
getTokenMethod.trySetAccessible()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ItemChecker.getTokenSafe(item: ItemStack?): Array<String> {
|
private fun ItemChecker.getTokenSafe(item: ItemStack?): Array<*> {
|
||||||
if (item == null) return arrayOf()
|
if (item == null) return arrayOf<Any>()
|
||||||
return getTokenMethod.invoke(this, item) as Array<String>
|
val result = getTokenMethod.invoke(this, item)
|
||||||
|
if(result !is Array<*>)
|
||||||
|
throw IllegalStateException("Could not get token from ToolStats")
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun testAnvilResult(event: InventoryClickEvent): Boolean {
|
override fun testAnvilResult(event: InventoryClickEvent): Boolean {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue