mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
fix support for enchantedbook
Some checks are pending
Java CI with Gradle / build (push) Waiting to run
Some checks are pending
Java CI with Gradle / build (push) Waiting to run
This commit is contained in:
parent
b9ff4bdc40
commit
d469171e4d
3 changed files with 15 additions and 11 deletions
|
|
@ -130,9 +130,9 @@ class DiagnosticExecutor: CASubCommand() {
|
||||||
message.clickEvent = ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, stb.toString())
|
message.clickEvent = ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, stb.toString())
|
||||||
message.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text("§7Click to copy"))
|
message.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text("§7Click to copy"))
|
||||||
|
|
||||||
sender.spigot().sendMessage(message);
|
sender.spigot().sendMessage(message)
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(stb.toString());
|
sender.sendMessage(stb.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
@ -268,7 +268,7 @@ class DiagnosticExecutor: CASubCommand() {
|
||||||
val fakeInv = Bukkit.createInventory(player, InventoryType.ANVIL)
|
val fakeInv = Bukkit.createInventory(player, InventoryType.ANVIL)
|
||||||
invView = player.openInventory(fakeInv)!!
|
invView = player.openInventory(fakeInv)!!
|
||||||
event = DependencyManager.createFakeEvent(invView, result)
|
event = DependencyManager.createFakeEvent(invView, result)
|
||||||
} catch (e: Throwable) {
|
} catch (_: Throwable) {
|
||||||
// Help
|
// Help
|
||||||
val menuTypeClazz = Class.forName("org.bukkit.inventory.MenuType")
|
val menuTypeClazz = Class.forName("org.bukkit.inventory.MenuType")
|
||||||
val anvilTypeField = menuTypeClazz.getField("ANVIL")
|
val anvilTypeField = menuTypeClazz.getField("ANVIL")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package xyz.alexcrea.cuanvil.dependency.plugins
|
package xyz.alexcrea.cuanvil.dependency.plugins
|
||||||
|
|
||||||
|
import org.bukkit.event.Event
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent
|
import org.bukkit.event.inventory.InventoryClickEvent
|
||||||
import org.bukkit.plugin.Plugin
|
import org.bukkit.plugin.Plugin
|
||||||
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
||||||
|
|
@ -10,17 +11,21 @@ class EnchantedBookDependency(plugin: Plugin) : GenericPluginDependency(plugin)
|
||||||
|
|
||||||
override fun testAnvilResult(event: InventoryClickEvent): Boolean {
|
override fun testAnvilResult(event: InventoryClickEvent): Boolean {
|
||||||
val view = event.view
|
val view = event.view
|
||||||
|
val inv = event.inventory
|
||||||
|
|
||||||
val current = view.getItem(ANVIL_OUTPUT_SLOT)
|
//TODO use view here (v2)
|
||||||
view.setItem(ANVIL_OUTPUT_SLOT, null)
|
val current = inv.getItem(ANVIL_OUTPUT_SLOT)
|
||||||
val fakeEvent = DependencyManager.createFakeEvent(event.view, null)
|
inv.setItem(ANVIL_OUTPUT_SLOT, null)
|
||||||
|
val fakeEvent = DependencyManager.createFakeEvent(view, null)
|
||||||
|
|
||||||
if (testPrepareAnvil(fakeEvent)) {
|
if (testPrepareAnvil(fakeEvent)) {
|
||||||
event.isCancelled = false
|
event.result = Event.Result.DEFAULT
|
||||||
|
|
||||||
|
inv.setItem(ANVIL_INPUT_LEFT, fakeEvent.result)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
view.setItem(ANVIL_INPUT_LEFT, current)
|
inv.setItem(ANVIL_INPUT_LEFT, current)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEPreV5Enchantment
|
||||||
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEV5Enchantment
|
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEV5Enchantment
|
||||||
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEV5_4Enchantment
|
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEV5_4Enchantment
|
||||||
import xyz.alexcrea.cuanvil.enchant.wrapped.CALegacyEEEnchantment
|
import xyz.alexcrea.cuanvil.enchant.wrapped.CALegacyEEEnchantment
|
||||||
import java.lang.reflect.Constructor
|
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
import su.nightexpress.excellentenchants.api.EnchantRegistry as V5EnchantRegistry
|
import su.nightexpress.excellentenchants.api.EnchantRegistry as V5EnchantRegistry
|
||||||
import su.nightexpress.excellentenchants.enchantment.impl.universal.CurseOfFragilityEnchant as LegacyCurseOfFragilityEnchant
|
import su.nightexpress.excellentenchants.enchantment.impl.universal.CurseOfFragilityEnchant as LegacyCurseOfFragilityEnchant
|
||||||
|
|
@ -48,7 +47,7 @@ class ExcellentEnchantsDependency {
|
||||||
|
|
||||||
listenerVersion = value
|
listenerVersion = value
|
||||||
break
|
break
|
||||||
} catch (ignored: ClassNotFoundException) {
|
} catch (_: ClassNotFoundException) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +60,7 @@ class ExcellentEnchantsDependency {
|
||||||
var isModernCurseOfFragility = true
|
var isModernCurseOfFragility = true
|
||||||
try {
|
try {
|
||||||
Class.forName("su.nightexpress.excellentenchants.enchantment.universal.CurseOfFragilityEnchant")
|
Class.forName("su.nightexpress.excellentenchants.enchantment.universal.CurseOfFragilityEnchant")
|
||||||
} catch (ignored: ClassNotFoundException) {
|
} catch (_: ClassNotFoundException) {
|
||||||
isModernCurseOfFragility = false
|
isModernCurseOfFragility = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue