fix support for enchantedbook
Some checks are pending
Java CI with Gradle / build (push) Waiting to run

This commit is contained in:
alexcrea 2026-07-08 14:44:20 +02:00
parent b9ff4bdc40
commit d469171e4d
Signed by: alexcrea
GPG key ID: E59DF23EE2A2266C
3 changed files with 15 additions and 11 deletions

View file

@ -130,9 +130,9 @@ class DiagnosticExecutor: CASubCommand() {
message.clickEvent = ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, stb.toString())
message.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text("§7Click to copy"))
sender.spigot().sendMessage(message);
sender.spigot().sendMessage(message)
} else {
sender.sendMessage(stb.toString());
sender.sendMessage(stb.toString())
}
return true
@ -268,7 +268,7 @@ class DiagnosticExecutor: CASubCommand() {
val fakeInv = Bukkit.createInventory(player, InventoryType.ANVIL)
invView = player.openInventory(fakeInv)!!
event = DependencyManager.createFakeEvent(invView, result)
} catch (e: Throwable) {
} catch (_: Throwable) {
// Help
val menuTypeClazz = Class.forName("org.bukkit.inventory.MenuType")
val anvilTypeField = menuTypeClazz.getField("ANVIL")

View file

@ -1,5 +1,6 @@
package xyz.alexcrea.cuanvil.dependency.plugins
import org.bukkit.event.Event
import org.bukkit.event.inventory.InventoryClickEvent
import org.bukkit.plugin.Plugin
import xyz.alexcrea.cuanvil.dependency.DependencyManager
@ -10,17 +11,21 @@ class EnchantedBookDependency(plugin: Plugin) : GenericPluginDependency(plugin)
override fun testAnvilResult(event: InventoryClickEvent): Boolean {
val view = event.view
val inv = event.inventory
val current = view.getItem(ANVIL_OUTPUT_SLOT)
view.setItem(ANVIL_OUTPUT_SLOT, null)
val fakeEvent = DependencyManager.createFakeEvent(event.view, null)
//TODO use view here (v2)
val current = inv.getItem(ANVIL_OUTPUT_SLOT)
inv.setItem(ANVIL_OUTPUT_SLOT, null)
val fakeEvent = DependencyManager.createFakeEvent(view, null)
if (testPrepareAnvil(fakeEvent)) {
event.isCancelled = false
event.result = Event.Result.DEFAULT
inv.setItem(ANVIL_INPUT_LEFT, fakeEvent.result)
return true
}
view.setItem(ANVIL_INPUT_LEFT, current)
inv.setItem(ANVIL_INPUT_LEFT, current)
return false
}

View file

@ -14,7 +14,6 @@ import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEPreV5Enchantment
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEV5Enchantment
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEV5_4Enchantment
import xyz.alexcrea.cuanvil.enchant.wrapped.CALegacyEEEnchantment
import java.lang.reflect.Constructor
import java.lang.reflect.Method
import su.nightexpress.excellentenchants.api.EnchantRegistry as V5EnchantRegistry
import su.nightexpress.excellentenchants.enchantment.impl.universal.CurseOfFragilityEnchant as LegacyCurseOfFragilityEnchant
@ -48,7 +47,7 @@ class ExcellentEnchantsDependency {
listenerVersion = value
break
} catch (ignored: ClassNotFoundException) {
} catch (_: ClassNotFoundException) {
}
}
@ -61,7 +60,7 @@ class ExcellentEnchantsDependency {
var isModernCurseOfFragility = true
try {
Class.forName("su.nightexpress.excellentenchants.enchantment.universal.CurseOfFragilityEnchant")
} catch (ignored: ClassNotFoundException) {
} catch (_: ClassNotFoundException) {
isModernCurseOfFragility = false
}