mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
Generic gui tester and generic paper nms
This commit is contained in:
parent
f5a89fea7c
commit
fc94dbe169
12 changed files with 144 additions and 78 deletions
|
|
@ -1,38 +0,0 @@
|
|||
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
|
||||
.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){
|
||||
// Assume cause UnimplementedOperationException on mock server
|
||||
return Collections.emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue