Excellent enchants compatibility (#34)

Add compatibility with
[ExcellentEnchants](https://www.spigotmc.org/resources/excellentenchants-%E2%AD%90-75-vanilla-like-enchantments.61693/)
This commit is contained in:
alexcrea 2024-10-15 08:27:26 +02:00 committed by GitHub
parent 7c283dc7f8
commit 13b7e73d8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 177 additions and 4 deletions

View file

@ -23,6 +23,8 @@ object DependencyManager {
var enchantmentSquaredCompatibility: EnchantmentSquaredDependency? = null
var ecoEnchantCompatibility: EcoEnchantDependency? = null
var excellentEnchantsCompatibility: ExcellentEnchantsDependency? = null
var disenchantmentCompatibility: DisenchantmentDependency? = null
fun loadDependency(){
@ -53,6 +55,12 @@ object DependencyManager {
ecoEnchantCompatibility!!.disableAnvilListener()
}
// Excellent Enchants dependency
if(pluginManager.isPluginEnabled("ExcellentEnchants")){
excellentEnchantsCompatibility = ExcellentEnchantsDependency()
excellentEnchantsCompatibility!!.redirectListeners()
}
// Disenchantment dependency
if(pluginManager.isPluginEnabled("Disenchantment")){
disenchantmentCompatibility = DisenchantmentDependency()
@ -69,6 +77,7 @@ object DependencyManager {
fun registerEnchantments() {
enchantmentSquaredCompatibility?.registerEnchantments()
ecoEnchantCompatibility?.registerEnchantments()
excellentEnchantsCompatibility?.registerEnchantments()
}
@ -84,8 +93,11 @@ object DependencyManager {
fun tryEventPreAnvilBypass(event: PrepareAnvilEvent): Boolean {
var bypass = false
// Test if disenchantment used special prepare anvil
if(disenchantmentCompatibility?.testPrepareAnvil(event) == true) bypass = true
// Test excellent enchantments used special prepare anvil
if(!bypass && (excellentEnchantsCompatibility?.testPrepareAnvil(event) == true)) bypass = true
// Test if the inventory is a gui(version specific)
if(!bypass && (externGuiTester?.testIfGui(event.view) == true)) bypass = true
@ -96,8 +108,12 @@ object DependencyManager {
fun tryClickAnvilResultBypass(event: InventoryClickEvent, inventory: AnvilInventory): Boolean {
var bypass = false
// Test if disenchantment used special event click
if(disenchantmentCompatibility?.testAnvilResult(event, inventory) == true) bypass = true
// Test if disenchantment used special event click
if(!bypass && (excellentEnchantsCompatibility?.testAnvilResult(event) == true)) bypass = true
// Test if the inventory is a gui(version specific)
if(!bypass && (externGuiTester?.testIfGui(event.view) == true)) bypass = true