mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Add compatibility with ExcellentEnchants
This commit is contained in:
parent
7c283dc7f8
commit
ffb9b4d756
7 changed files with 88 additions and 3 deletions
|
|
@ -36,6 +36,10 @@ dependencies {
|
|||
compileOnly("com.willfp:EcoEnchants:12.5.1")
|
||||
compileOnly("com.willfp:eco:6.70.1")
|
||||
|
||||
// ExcellentEnchants
|
||||
compileOnly(files("libs/nightcore-2.6.4.jar"))
|
||||
compileOnly(files("libs/ExcellentEnchants-4.2.2.jar"))
|
||||
|
||||
// Disenchantment
|
||||
compileOnly("cz.kominekjan:Disenchantment:v5.4.0")
|
||||
|
||||
|
|
|
|||
BIN
libs/ExcellentEnchants-4.2.2.jar
Normal file
BIN
libs/ExcellentEnchants-4.2.2.jar
Normal file
Binary file not shown.
BIN
libs/nightcore-2.6.4.jar
Normal file
BIN
libs/nightcore-2.6.4.jar
Normal file
Binary file not shown.
|
|
@ -0,0 +1,46 @@
|
|||
package xyz.alexcrea.cuanvil.enchant.wrapped;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.CustomEnchantment;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.Definition;
|
||||
import xyz.alexcrea.cuanvil.enchant.AdditionalTestEnchantment;
|
||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
||||
import xyz.alexcrea.cuanvil.enchant.EnchantmentRarity;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class CAEEEnchantment extends CABukkitEnchantment implements AdditionalTestEnchantment {
|
||||
|
||||
@NotNull CustomEnchantment eeenchantment;
|
||||
@NotNull Definition definition;
|
||||
|
||||
public CAEEEnchantment(@NotNull CustomEnchantment enchantment) {
|
||||
super(enchantment.getBukkitEnchantment(), EnchantmentRarity.getRarity(enchantment.getDefinition().getAnvilCost()));
|
||||
this.eeenchantment = enchantment;
|
||||
this.definition = enchantment.getDefinition();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnchantConflict(@NotNull Map<CAEnchantment, Integer> enchantments, @NotNull Material itemMat) {
|
||||
if(!definition.hasConflicts()) return false;
|
||||
|
||||
Set<String> conflicts = definition.getConflicts();
|
||||
|
||||
for (CAEnchantment caEnchantment : enchantments.keySet()) {
|
||||
if(conflicts.contains(caEnchantment.getName())) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemConflict(@NotNull Map<CAEnchantment, Integer> enchantments, @NotNull Material itemMat, @NotNull ItemStack item) {
|
||||
if(Material.ENCHANTED_BOOK.equals(itemMat)) return false;
|
||||
|
||||
return !definition.getSupportedItems().is(item);
|
||||
}
|
||||
}
|
||||
|
|
@ -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,11 @@ object DependencyManager {
|
|||
ecoEnchantCompatibility!!.disableAnvilListener()
|
||||
}
|
||||
|
||||
// Excellent Enchants dependency
|
||||
if(pluginManager.isPluginEnabled("ExcellentEnchants")){
|
||||
excellentEnchantsCompatibility = ExcellentEnchantsDependency(pluginManager.getPlugin("ExcellentEnchants")!!)
|
||||
}
|
||||
|
||||
// Disenchantment dependency
|
||||
if(pluginManager.isPluginEnabled("Disenchantment")){
|
||||
disenchantmentCompatibility = DisenchantmentDependency()
|
||||
|
|
@ -69,6 +76,7 @@ object DependencyManager {
|
|||
fun registerEnchantments() {
|
||||
enchantmentSquaredCompatibility?.registerEnchantments()
|
||||
ecoEnchantCompatibility?.registerEnchantments()
|
||||
excellentEnchantsCompatibility?.registerEnchantments()
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package xyz.alexcrea.cuanvil.dependency
|
||||
|
||||
import io.delilaheve.CustomAnvil
|
||||
import org.bukkit.plugin.Plugin
|
||||
import su.nightexpress.excellentenchants.registry.EnchantRegistry
|
||||
import xyz.alexcrea.cuanvil.api.EnchantmentApi
|
||||
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEEnchantment
|
||||
|
||||
class ExcellentEnchantsDependency(private val excellentEnchantsPlugin: Plugin){
|
||||
|
||||
init {
|
||||
CustomAnvil.instance.logger.info("Excellent Enchants Detected !")
|
||||
}
|
||||
|
||||
fun registerEnchantments() {
|
||||
CustomAnvil.instance.logger.info("Preparing Excellent Enchants compatibility...")
|
||||
|
||||
for (enchantment in EnchantRegistry.getRegistered()) {
|
||||
EnchantmentApi.unregisterEnchantment(enchantment.bukkitEnchantment.key) // As excellent enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant.
|
||||
EnchantmentApi.registerEnchantment(CAEEEnchantment(enchantment))
|
||||
}
|
||||
|
||||
CustomAnvil.instance.logger.info("\"Excellent Enchants should now work as expected !")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -49,8 +49,8 @@ permissions:
|
|||
description: Allow player to use hexadecimal color if permission is required (toggleable)
|
||||
|
||||
|
||||
# soft depend on old name, so I can disable it if it is on the same server
|
||||
# as it is the old name for this plugin
|
||||
# soft depend on old name (UnsafeEnchantsPlus), so I can disable it if it is on the same server (old name for this plugin)
|
||||
# Also depend to other plugin for compatibility
|
||||
softdepend:
|
||||
- UnsafeEnchantsPlus
|
||||
- ProtocolLib
|
||||
|
|
@ -58,3 +58,4 @@ softdepend:
|
|||
- EnchantsSquared
|
||||
- EcoEnchants
|
||||
- eco
|
||||
- ExcellentEnchants
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue