mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
fix null error on toolstat detected (#68)
This commit is contained in:
commit
ff27180e82
1 changed files with 7 additions and 2 deletions
|
|
@ -23,6 +23,11 @@ class ToolStatsDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
|||
return listOf()
|
||||
}
|
||||
|
||||
private fun ItemChecker.getTokenSafe(item: ItemStack?): Array<String> {
|
||||
if (item == null) return arrayOf()
|
||||
return getTokenMethod.invoke(this, item) as Array<String>
|
||||
}
|
||||
|
||||
override fun testAnvilResult(event: InventoryClickEvent): Boolean {
|
||||
// Check if token changes from left with result
|
||||
val left = event.inventory.getItem(PrepareAnvilListener.ANVIL_INPUT_LEFT)
|
||||
|
|
@ -30,8 +35,8 @@ class ToolStatsDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
|||
|
||||
val itemChecker = (plugin as ToolStats).itemChecker
|
||||
|
||||
val leftTokens = getTokenMethod.invoke(itemChecker, left) as Array<String>
|
||||
val resultToken = getTokenMethod.invoke(itemChecker, result) as Array<String>
|
||||
val leftTokens = itemChecker.getTokenSafe(left)
|
||||
val resultToken = itemChecker.getTokenSafe(result)
|
||||
|
||||
return !leftTokens.contentDeepEquals(resultToken);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue