mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-24 00:26:16 +02:00
Do not continue anvil process if Disenchantment done something.
This commit is contained in:
parent
3c8810ed72
commit
804c11a7f4
5 changed files with 231 additions and 59 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package xyz.alexcrea.cuanvil.dependency
|
||||
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.event.inventory.InventoryClickEvent
|
||||
import org.bukkit.event.inventory.PrepareAnvilEvent
|
||||
import org.bukkit.inventory.AnvilInventory
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
|
||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerSelector
|
||||
|
|
@ -10,6 +13,7 @@ object DependencyManager {
|
|||
lateinit var packetManager: PacketManager
|
||||
var enchantmentSquaredCompatibility: EnchantmentSquaredDependency? = null
|
||||
var ecoEnchantCompatibility: EcoEnchantDependency? = null
|
||||
var disenchantmentCompatibility: DisenchantmentDependency? = null
|
||||
|
||||
fun loadDependency(){
|
||||
val pluginManager = Bukkit.getPluginManager()
|
||||
|
|
@ -30,6 +34,12 @@ object DependencyManager {
|
|||
ecoEnchantCompatibility!!.disableAnvilListener()
|
||||
}
|
||||
|
||||
// Disenchantment dependency
|
||||
if(pluginManager.isPluginEnabled("Disenchantment")){
|
||||
disenchantmentCompatibility = DisenchantmentDependency()
|
||||
disenchantmentCompatibility!!.redirectListeners()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun handleCompatibilityConfig() {
|
||||
|
|
@ -52,4 +62,20 @@ object DependencyManager {
|
|||
|
||||
}
|
||||
|
||||
fun tryEventPreAnvilBypass(event: PrepareAnvilEvent): Boolean {
|
||||
var bypass = false
|
||||
|
||||
if(disenchantmentCompatibility?.testPrepareAnvil(event) == true) bypass = true
|
||||
|
||||
return bypass
|
||||
}
|
||||
|
||||
fun tryClickAnvilResultBypass(event: InventoryClickEvent, inventory: AnvilInventory): Boolean {
|
||||
var bypass = false
|
||||
|
||||
if(disenchantmentCompatibility?.testAnvilResult(event, inventory) == true) bypass = true
|
||||
|
||||
return bypass
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue