From a8d6aaad3091379dc8cc24a14700a4b433724fe2 Mon Sep 17 00:00:00 2001 From: Will FP Date: Sat, 4 May 2024 16:22:25 +0100 Subject: [PATCH] Fixed several things, updated version --- build.gradle.kts | 81 +++++++++---------- .../java/com/willfp/eco/core/EcoPlugin.java | 5 +- .../proxy/v1_20_6/CommonsInitializer.kt | 4 +- .../com/willfp/eco/internal/spigot/EcoImpl.kt | 5 ++ gradle.properties | 2 +- 5 files changed, 51 insertions(+), 46 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4e93b471..2430f465 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -142,55 +142,17 @@ allprojects { setExtendsFrom(listOf(configurations.compileOnly.get(), configurations.implementation.get())) } - java { - toolchain.languageVersion = JavaLanguageVersion.of(17) - } - - kotlin { - jvmToolchain(17) - } - tasks { + withType { + duplicatesStrategy = DuplicatesStrategy.WARN + } + compileKotlin { kotlinOptions { jvmTarget = "17" } } - shadowJar { - relocate("org.bstats", "com.willfp.eco.libs.bstats") - relocate("redempt.crunch", "com.willfp.eco.libs.crunch") - relocate("org.apache.commons.lang3", "com.willfp.eco.libs.lang3") - relocate("org.apache.maven", "com.willfp.eco.libs.maven") - relocate("org.checkerframework", "com.willfp.eco.libs.checkerframework") - relocate("org.intellij", "com.willfp.eco.libs.intellij") - relocate("org.jetbrains.annotations", "com.willfp.eco.libs.jetbrains.annotations") - //relocate("org.jetbrains.exposed", "com.willfp.eco.libs.exposed") - relocate("org.objenesis", "com.willfp.eco.libs.objenesis") - relocate("org.reflections", "com.willfp.eco.libs.reflections") - relocate("javassist", "com.willfp.eco.libs.javassist") - relocate("javax.annotation", "com.willfp.eco.libs.annotation") - relocate("com.google.errorprone", "com.willfp.eco.libs.errorprone") - relocate("com.google.j2objc", "com.willfp.eco.libs.j2objc") - relocate("com.google.thirdparty", "com.willfp.eco.libs.google.thirdparty") - relocate("com.google.protobuf", "com.willfp.eco.libs.google.protobuf") // No I don't know either - relocate("google.protobuf", "com.willfp.eco.libs.protobuf") // Still don't know - relocate("com.zaxxer.hikari", "com.willfp.eco.libs.hikari") - //relocate("com.mysql", "com.willfp.eco.libs.mysql") - relocate("com.mongodb", "com.willfp.eco.libs.mongodb") - relocate("org.bson", "com.willfp.eco.libs.bson") - relocate("org.litote", "com.willfp.eco.libs.litote") - relocate("org.reactivestreams", "com.willfp.eco.libs.reactivestreams") - relocate("reactor.", "com.willfp.eco.libs.reactor.") // Dot in name to be safe - relocate("com.moandjiezana.toml", "com.willfp.eco.libs.toml") - relocate("com.willfp.modelenginebridge", "com.willfp.eco.libs.modelenginebridge") - - /* - Kotlin and caffeine are not shaded so that they can be accessed directly by eco plugins. - Also, not relocating adventure, because it's a pain in the ass, and it doesn't *seem* to be causing loader constraint violations. - */ - } - compileJava { dependsOn(clean) options.encoding = "UTF-8" @@ -217,6 +179,41 @@ allprojects { } } +tasks { + shadowJar { + relocate("org.bstats", "com.willfp.eco.libs.bstats") + relocate("redempt.crunch", "com.willfp.eco.libs.crunch") + relocate("org.apache.commons.lang3", "com.willfp.eco.libs.lang3") + relocate("org.apache.maven", "com.willfp.eco.libs.maven") + relocate("org.checkerframework", "com.willfp.eco.libs.checkerframework") + relocate("org.intellij", "com.willfp.eco.libs.intellij") + relocate("org.jetbrains.annotations", "com.willfp.eco.libs.jetbrains.annotations") + //relocate("org.jetbrains.exposed", "com.willfp.eco.libs.exposed") + relocate("org.objenesis", "com.willfp.eco.libs.objenesis") + relocate("org.reflections", "com.willfp.eco.libs.reflections") + relocate("javassist", "com.willfp.eco.libs.javassist") + relocate("javax.annotation", "com.willfp.eco.libs.annotation") + relocate("com.google.errorprone", "com.willfp.eco.libs.errorprone") + relocate("com.google.j2objc", "com.willfp.eco.libs.j2objc") + relocate("com.google.thirdparty", "com.willfp.eco.libs.google.thirdparty") + relocate("com.google.protobuf", "com.willfp.eco.libs.google.protobuf") // No I don't know either + relocate("google.protobuf", "com.willfp.eco.libs.protobuf") // Still don't know + relocate("com.zaxxer.hikari", "com.willfp.eco.libs.hikari") + //relocate("com.mysql", "com.willfp.eco.libs.mysql") + relocate("com.mongodb", "com.willfp.eco.libs.mongodb") + relocate("org.bson", "com.willfp.eco.libs.bson") + relocate("org.litote", "com.willfp.eco.libs.litote") + relocate("org.reactivestreams", "com.willfp.eco.libs.reactivestreams") + relocate("reactor.", "com.willfp.eco.libs.reactor.") // Dot in name to be safe + relocate("com.moandjiezana.toml", "com.willfp.eco.libs.toml") + relocate("com.willfp.modelenginebridge", "com.willfp.eco.libs.modelenginebridge") + + /* + Kotlin and caffeine are not shaded so that they can be accessed directly by eco plugins. + Also, not relocating adventure, because it's a pain in the ass, and it doesn't *seem* to be causing loader constraint violations. + */ + } +} // Root is Java 21 to support 1.20.6+, rest use Java 17 java { diff --git a/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java b/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java index faa85cbf..e80a4780 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java +++ b/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java @@ -575,8 +575,9 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike, Regist this.getLogger().severe(""); this.getLogger().severe("You don't seem to be running paper!"); this.getLogger().severe("Paper is strongly recommended for all servers,"); - this.getLogger().severe("and some things may not function properly without it"); - this.getLogger().severe("Download Paper from &fhttps://papermc.io"); + this.getLogger().severe("and many features may not function properly without it"); + this.getLogger().severe("Download Paper from https://papermc.io"); + this.getLogger().severe("It's a drop-in replacement for Spigot, so it's easy to switch."); this.getLogger().severe(""); this.getLogger().severe("----------------------------"); this.getLogger().severe(""); diff --git a/eco-core/core-nms/v1_20_6/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_20_6/CommonsInitializer.kt b/eco-core/core-nms/v1_20_6/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_20_6/CommonsInitializer.kt index 825e5c14..7fce90ee 100644 --- a/eco-core/core-nms/v1_20_6/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_20_6/CommonsInitializer.kt +++ b/eco-core/core-nms/v1_20_6/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_20_6/CommonsInitializer.kt @@ -23,6 +23,7 @@ import org.bukkit.craftbukkit.entity.CraftEntity import org.bukkit.craftbukkit.entity.CraftMob import org.bukkit.craftbukkit.entity.CraftPlayer import org.bukkit.craftbukkit.inventory.CraftItemStack +import org.bukkit.craftbukkit.inventory.CraftMetaArmor import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry import org.bukkit.craftbukkit.util.CraftMagicNumbers @@ -47,7 +48,8 @@ class CommonsInitializer : CommonsInitializerProxy { isAccessible = true } - private val pdcRegsitry = Class.forName("org.bukkit.craftbukkit.v1_20_R3.inventory.CraftMetaItem") + private val pdcRegsitry = CraftMetaArmor::class.java + .superclass // Access CraftMetaItem .getDeclaredField("DATA_TYPE_REGISTRY") .apply { isAccessible = true } .get(null) as CraftPersistentDataTypeRegistry diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoImpl.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoImpl.kt index da412af9..4190db5f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoImpl.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoImpl.kt @@ -239,6 +239,11 @@ class EcoImpl : EcoSpigotPlugin(), Eco { MergedStateMenu(base, additional) override fun clean(plugin: EcoPlugin) { + // Prevent self-cleaning + if (plugin == this) { + return + } + if (plugin.proxyPackage.isNotEmpty()) { val factory = plugin.proxyFactory as EcoProxyFactory factory.clean() diff --git a/gradle.properties b/gradle.properties index 1d0b5bc7..d5997460 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 6.69.2 +version = 6.70.0 kotlin.incremental.useClasspathSnapshot=false \ No newline at end of file