mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
try fixing the issue
This commit is contained in:
parent
d4bc6716d3
commit
55e3034161
3 changed files with 39 additions and 3 deletions
BIN
libs/toolstats-1.9.6-stripped.jar
Normal file
BIN
libs/toolstats-1.9.6-stripped.jar
Normal file
Binary file not shown.
|
|
@ -84,11 +84,12 @@ object DependencyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Generic" dependencies
|
// "Generic" dependencies
|
||||||
|
if (pluginManager.isPluginEnabled("ToolStats"))
|
||||||
|
genericDependencies.add(ToolStatsDependency(pluginManager.getPlugin("ToolStats")!!))
|
||||||
|
|
||||||
|
for (dependency in genericDependencies)
|
||||||
for (dependency in genericDependencies) {
|
|
||||||
dependency.redirectListeners()
|
dependency.redirectListeners()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleCompatibilityConfig() {
|
fun handleCompatibilityConfig() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package xyz.alexcrea.cuanvil.dependency.plugins
|
||||||
|
|
||||||
|
import lol.hyper.toolstats.tools.ItemChecker
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.plugin.Plugin
|
||||||
|
import org.bukkit.plugin.RegisteredListener
|
||||||
|
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener
|
||||||
|
import java.lang.reflect.Method
|
||||||
|
|
||||||
|
class ToolStatsDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
||||||
|
|
||||||
|
// Sadly, getTokens function is private, so I need to do that
|
||||||
|
private val getTokenMethod: Method =
|
||||||
|
ItemChecker::class.java.getDeclaredMethod("getTokens", ItemStack::class.java);
|
||||||
|
|
||||||
|
init {
|
||||||
|
getTokenMethod.trySetAccessible()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun postAnvilEvents(): Collection<RegisteredListener> {
|
||||||
|
return listOf()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun testAnvilResult(event: InventoryClickEvent): Boolean {
|
||||||
|
// Check if token changes from left with result
|
||||||
|
val left = event.inventory.getItem(PrepareAnvilListener.ANVIL_INPUT_LEFT)
|
||||||
|
val result = event.inventory.getItem(PrepareAnvilListener.ANVIL_OUTPUT_SLOT)
|
||||||
|
|
||||||
|
val leftTokens = getTokenMethod.invoke(left) as Array<String>
|
||||||
|
val resultToken = getTokenMethod.invoke(result) as Array<String>
|
||||||
|
|
||||||
|
return !leftTokens.contentDeepEquals(resultToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue