mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Use Bulk operation object for bukkit and enchantment² enchants.
This commit is contained in:
parent
d3252eecbd
commit
b89a8951b7
5 changed files with 73 additions and 40 deletions
|
|
@ -116,7 +116,7 @@ class CustomAnvil : JavaPlugin() {
|
|||
if (!ConfigHolder.loadDefaultConfig()) return
|
||||
|
||||
// Register enchantments
|
||||
CAEnchantmentRegistry.getInstance().registerStartupEnchantments()
|
||||
CAEnchantmentRegistry.getInstance().registerBukkit()
|
||||
DependencyManager.registerEnchantments()
|
||||
|
||||
val enchantReadyEvent = CAEnchantRegistryReadyEvent()
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import xyz.alexcrea.cuanvil.api.EnchantmentApi
|
|||
import xyz.alexcrea.cuanvil.api.MaterialGroupApi
|
||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment
|
||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
|
||||
import xyz.alexcrea.cuanvil.enchant.bulk.EnchantSquaredBulkOperation
|
||||
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEnchantSquaredEnchantment
|
||||
import xyz.alexcrea.cuanvil.group.IncludeGroup
|
||||
import java.util.*
|
||||
|
|
@ -36,10 +37,17 @@ class EnchantmentSquaredDependency(private val enchantmentSquaredPlugin: Plugin)
|
|||
|
||||
fun registerEnchantments(){
|
||||
CustomAnvil.instance.logger.info("Preparing Enchantment Squared compatibility...")
|
||||
|
||||
// Register enchantments
|
||||
for (enchant in CustomEnchantManager.getInstance().allEnchants.values) {
|
||||
EnchantmentApi.registerEnchantment(CAEnchantSquaredEnchantment(enchant))
|
||||
}
|
||||
|
||||
// Register bulk operation
|
||||
val bulkOpperations = EnchantSquaredBulkOperation()
|
||||
EnchantmentApi.addBulkGet(bulkOpperations)
|
||||
EnchantmentApi.addBulkClean(bulkOpperations)
|
||||
|
||||
}
|
||||
|
||||
fun getEnchantmentsSquared(item: ItemStack, enchantments: MutableMap<CAEnchantment, Int>) {
|
||||
|
|
@ -51,10 +59,6 @@ class EnchantmentSquaredDependency(private val enchantmentSquaredPlugin: Plugin)
|
|||
|
||||
}
|
||||
|
||||
fun clearEnchantments(item: ItemStack) {
|
||||
CustomEnchantManager.getInstance().removeAllEnchants(item)
|
||||
}
|
||||
|
||||
fun getKeyFromEnchant(enchant: CustomEnchant): NamespacedKey{
|
||||
return NamespacedKey.fromString(enchant.type.lowercase(Locale.getDefault()), this.enchantmentSquaredPlugin)!!
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue