Fix/neondevui (#59)

Fix incompatibility with plugin using neondevUI anvil gui
This commit is contained in:
alexcrea 2025-04-29 14:14:21 +02:00 committed by GitHub
commit d8fbb034e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,15 +9,32 @@ 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) // this mean we are on test
if(clazz == null) return false if(inventory.javaClass.name.endsWith("AnvilViewMock")) return false
val expectedWesjdGuiPath = "anvilgui.version.$wesjdAnvilGuiName" val clazz = getContainerClass(inventory) ?: return false
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)
} }