mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
progress on 1.21 transition
This commit is contained in:
parent
922a7a0ed1
commit
ef5585fd42
23 changed files with 62 additions and 1239 deletions
|
|
@ -21,8 +21,8 @@ repositories {
|
|||
|
||||
// Set target version
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
sourceCompatibility = "16"
|
||||
targetCompatibility = "16"
|
||||
sourceCompatibility = "21"
|
||||
targetCompatibility = "21"
|
||||
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
|
@ -30,6 +30,6 @@ tasks.withType<JavaCompile>().configureEach {
|
|||
kotlin {
|
||||
compilerOptions {
|
||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
||||
jvmTarget.set(JvmTarget.JVM_16)
|
||||
jvmTarget.set(JvmTarget.JVM_21)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ repositories {
|
|||
|
||||
// Set target version
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
sourceCompatibility = "18"
|
||||
targetCompatibility = "18"
|
||||
sourceCompatibility = "21"
|
||||
targetCompatibility = "21"
|
||||
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
|
@ -30,6 +30,6 @@ tasks.withType<JavaCompile>().configureEach {
|
|||
kotlin {
|
||||
compilerOptions {
|
||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
||||
jvmTarget.set(JvmTarget.JVM_18)
|
||||
jvmTarget.set(JvmTarget.JVM_21)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,37 +2,19 @@ package xyz.alexcrea.cuanvil.dependency.datapack
|
|||
|
||||
import io.papermc.paper.datapack.Datapack
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.packs.DataPack
|
||||
import java.util.*
|
||||
|
||||
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>
|
||||
get() {
|
||||
try {
|
||||
// will throw error if do not exist
|
||||
Bukkit::class.java.getDeclaredMethod("getDatapackManager")
|
||||
|
||||
return Bukkit.getDatapackManager().enabledPacks
|
||||
return try {
|
||||
Bukkit.getDatapackManager().enabledPacks
|
||||
.stream().map { obj: Datapack -> obj.name }
|
||||
.toList()
|
||||
} catch (e: NoSuchMethodException) {
|
||||
try {
|
||||
DataPack::class.java.getDeclaredMethod("getKey")
|
||||
} catch (e: NoSuchMethodException) {
|
||||
System.err.println("Could not find compatible datapack manager")
|
||||
System.err.println("If you are using a datapack that should be compatible with CustomAnvil. It will not get detected...")
|
||||
return emptyList()
|
||||
}
|
||||
return legacyNames
|
||||
} catch (e: Exception){
|
||||
} catch (_: Exception){
|
||||
// Assume cause UnimplementedOperationException on mock server
|
||||
return Collections.emptyList()
|
||||
Collections.emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue