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:EcoEnchants:12.5.1")
|
||||||
compileOnly("com.willfp:eco:6.70.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
|
// Disenchantment
|
||||||
compileOnly("cz.kominekjan:Disenchantment:v5.4.0")
|
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 enchantmentSquaredCompatibility: EnchantmentSquaredDependency? = null
|
||||||
var ecoEnchantCompatibility: EcoEnchantDependency? = null
|
var ecoEnchantCompatibility: EcoEnchantDependency? = null
|
||||||
|
var excellentEnchantsCompatibility: ExcellentEnchantsDependency? = null
|
||||||
|
|
||||||
var disenchantmentCompatibility: DisenchantmentDependency? = null
|
var disenchantmentCompatibility: DisenchantmentDependency? = null
|
||||||
|
|
||||||
fun loadDependency(){
|
fun loadDependency(){
|
||||||
|
|
@ -53,6 +55,11 @@ object DependencyManager {
|
||||||
ecoEnchantCompatibility!!.disableAnvilListener()
|
ecoEnchantCompatibility!!.disableAnvilListener()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Excellent Enchants dependency
|
||||||
|
if(pluginManager.isPluginEnabled("ExcellentEnchants")){
|
||||||
|
excellentEnchantsCompatibility = ExcellentEnchantsDependency(pluginManager.getPlugin("ExcellentEnchants")!!)
|
||||||
|
}
|
||||||
|
|
||||||
// Disenchantment dependency
|
// Disenchantment dependency
|
||||||
if(pluginManager.isPluginEnabled("Disenchantment")){
|
if(pluginManager.isPluginEnabled("Disenchantment")){
|
||||||
disenchantmentCompatibility = DisenchantmentDependency()
|
disenchantmentCompatibility = DisenchantmentDependency()
|
||||||
|
|
@ -69,6 +76,7 @@ object DependencyManager {
|
||||||
fun registerEnchantments() {
|
fun registerEnchantments() {
|
||||||
enchantmentSquaredCompatibility?.registerEnchantments()
|
enchantmentSquaredCompatibility?.registerEnchantments()
|
||||||
ecoEnchantCompatibility?.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,12 +49,13 @@ permissions:
|
||||||
description: Allow player to use hexadecimal color if permission is required (toggleable)
|
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
|
# soft depend on old name (UnsafeEnchantsPlus), so I can disable it if it is on the same server (old name for this plugin)
|
||||||
# as it is the old name for this plugin
|
# Also depend to other plugin for compatibility
|
||||||
softdepend:
|
softdepend:
|
||||||
- UnsafeEnchantsPlus
|
- UnsafeEnchantsPlus
|
||||||
- ProtocolLib
|
- ProtocolLib
|
||||||
- Disenchantment
|
- Disenchantment
|
||||||
- EnchantsSquared
|
- EnchantsSquared
|
||||||
- EcoEnchants
|
- EcoEnchants
|
||||||
- eco
|
- eco
|
||||||
|
- ExcellentEnchants
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue