mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
fix big issue extern gui wrongly tested
This commit is contained in:
parent
89eec84a66
commit
be7f4d0bcb
3 changed files with 11 additions and 9 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.gui
|
||||
|
||||
import org.bukkit.inventory.InventoryView
|
||||
import xyz.alexcrea.cuanvil.dependency.MinecraftVersionUtil
|
||||
import java.lang.reflect.Method
|
||||
|
||||
class GenericExternGuiTester: ExternGuiTester {
|
||||
|
|
@ -12,14 +11,16 @@ class GenericExternGuiTester: ExternGuiTester {
|
|||
private const val HANDLE_METHOD_NAME = "getHandle"
|
||||
}
|
||||
|
||||
var tested = false
|
||||
var testExist = false
|
||||
var inTesting = false
|
||||
|
||||
var testedClass: String? = null
|
||||
lateinit var getHandleMethod: Method
|
||||
|
||||
override fun getContainerClass(view: InventoryView): Class<Any>? {
|
||||
// In case we are in a test environment
|
||||
if(!tested) testClassExist()
|
||||
if(!testExist) testClassExist()
|
||||
if(inTesting) return view.javaClass //TEMPORARY
|
||||
|
||||
if(!testedClass.contentEquals(view.javaClass.name))
|
||||
return null
|
||||
|
|
@ -36,7 +37,7 @@ class GenericExternGuiTester: ExternGuiTester {
|
|||
}
|
||||
|
||||
fun testClassExist() {
|
||||
tested = true
|
||||
testExist = true
|
||||
|
||||
// We first try to get craft anvil interface,
|
||||
// but is absent on old version so we try craft inventory view before
|
||||
|
|
@ -53,6 +54,8 @@ class GenericExternGuiTester: ExternGuiTester {
|
|||
}
|
||||
catch (_: ClassNotFoundException) {}
|
||||
catch (_: NoSuchMethodException) {}
|
||||
|
||||
inTesting = true
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue