mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +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
|
|
@ -8,7 +8,7 @@ plugins {
|
|||
kotlin("jvm") version "2.1.0"
|
||||
java
|
||||
id("org.jetbrains.dokka").version("1.9.20")
|
||||
id("com.gradleup.shadow").version("9.0.0-beta16")
|
||||
id("com.gradleup.shadow").version("9.3.0")
|
||||
// Maven publish
|
||||
`maven-publish`
|
||||
signing
|
||||
|
|
@ -18,7 +18,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "xyz.alexcrea"
|
||||
version = "1.15.7"
|
||||
version = "1.15.8"
|
||||
|
||||
val effectiveVersion = "$version" +
|
||||
(if (System.getenv("SMALL_COMMIT_HASH") != null) "-dev-${System.getenv("SMALL_COMMIT_HASH")!!}" else "")
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.gui
|
||||
|
||||
import org.bukkit.inventory.InventoryView
|
||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
||||
|
||||
interface ExternGuiTester {
|
||||
|
||||
fun getContainerClass(view: InventoryView): Class<Any>?
|
||||
|
||||
fun testIfGui(inventory: InventoryView): Boolean {
|
||||
// container class only allow default bukkit craft view class
|
||||
// container class only allow default bukkit craft view or test class
|
||||
|
||||
val clazz = getContainerClass(inventory)
|
||||
return clazz != null
|
||||
return clazz == null
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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