fix incompability with xenondev anvil UI

This commit is contained in:
alexcrea 2025-04-29 14:11:37 +02:00
parent 053ab2b943
commit bf7a158c95
No known key found for this signature in database
GPG key ID: 027DD67D2D3280C5

View file

@ -9,15 +9,29 @@ interface ExternGuiTester {
fun getContainerClass(inventory: InventoryView): Class<Any>? fun getContainerClass(inventory: InventoryView): Class<Any>?
fun testIfGui(inventory: InventoryView): Boolean { fun testIfGui(inventory: InventoryView): Boolean {
val clazz = getContainerClass(inventory) val clazz = getContainerClass(inventory) ?: return false
if(clazz == null) return false
val expectedWesjdGuiPath = "anvilgui.version.$wesjdAnvilGuiName"
val clazzName = clazz.name val clazzName = clazz.name
val isWejdsGui = clazzName.contains(expectedWesjdGuiPath) if (expectWesjd(clazzName)) return true
if (expectXenondevUI(clazzName)) return true
return isWejdsGui return false
}
fun expectWesjd(name: String): Boolean {
val expectedWesjdGuiPath = "anvilgui.version.$wesjdAnvilGuiName"
return name.contains(expectedWesjdGuiPath)
}
private val XenondevUIPrefix: String
get() = "xyz.xenondevs.inventoryaccess."
private val XenondevUISufix: String
get() = ".AnvilInventoryImpl"
fun expectXenondevUI(name: String): Boolean {
return name.startsWith(XenondevUIPrefix)
&& name.endsWith(XenondevUISufix)
} }