mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Use correct default. Also disable Enchantment Squared anvil listener.
This commit is contained in:
parent
88c4f0509b
commit
fc033460b4
4 changed files with 22 additions and 4 deletions
|
|
@ -460,7 +460,7 @@ class AnvilEventListener(private val packetManager: PacketManager) : Listener {
|
||||||
|
|
||||||
val enchantmentMultiplier = ConfigOptions.enchantmentValue(enchantment.key, rightIsFormBook)
|
val enchantmentMultiplier = ConfigOptions.enchantmentValue(enchantment.key, rightIsFormBook)
|
||||||
val value = resultLevel * enchantmentMultiplier
|
val value = resultLevel * enchantmentMultiplier
|
||||||
CustomAnvil.log("Value for ${enchantment.key.enchantmentName} level ${enchantment.value} is $value")
|
CustomAnvil.log("Value for ${enchantment.key.enchantmentName} level ${enchantment.value} is $value ($resultLevel * $enchantmentMultiplier)")
|
||||||
rightValue += value
|
rightValue += value
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -306,6 +306,17 @@ object ConfigOptions {
|
||||||
if(enchantmentName == "sweeping_edge"){
|
if(enchantmentName == "sweeping_edge"){
|
||||||
return enchantmentValue("sweeping", isFromBook)
|
return enchantmentValue("sweeping", isFromBook)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val enchantment = WrappedEnchantment.getByName(enchantmentName)
|
||||||
|
if(enchantment != null){
|
||||||
|
val rarity = enchantment.defaultRarity()
|
||||||
|
if(rarity != null){
|
||||||
|
return if(isFromBook) rarity.bookValue
|
||||||
|
else rarity.itemValue
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return DEFAULT_ENCHANT_VALUE
|
return DEFAULT_ENCHANT_VALUE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ object DependencyManager {
|
||||||
else NoProtocoLib()
|
else NoProtocoLib()
|
||||||
|
|
||||||
// Enchantment Squared dependency
|
// Enchantment Squared dependency
|
||||||
enchantmentSquaredCompatibility =
|
if(pluginManager.isPluginEnabled("EnchantsSquared")){
|
||||||
if(pluginManager.isPluginEnabled("EnchantsSquared")) EnchantmentSquaredDependency(pluginManager.getPlugin("EnchantsSquared")!!)
|
enchantmentSquaredCompatibility = EnchantmentSquaredDependency(pluginManager.getPlugin("EnchantsSquared")!!)
|
||||||
else null
|
enchantmentSquaredCompatibility!!.disableAnvilListener()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package xyz.alexcrea.cuanvil.dependency
|
||||||
import me.athlaeos.enchantssquared.enchantments.CustomEnchant
|
import me.athlaeos.enchantssquared.enchantments.CustomEnchant
|
||||||
import me.athlaeos.enchantssquared.managers.CustomEnchantManager
|
import me.athlaeos.enchantssquared.managers.CustomEnchantManager
|
||||||
import org.bukkit.NamespacedKey
|
import org.bukkit.NamespacedKey
|
||||||
|
import org.bukkit.event.inventory.PrepareAnvilEvent
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.plugin.Plugin
|
import org.bukkit.plugin.Plugin
|
||||||
import xyz.alexcrea.cuanvil.enchant.WrappedEnchantment
|
import xyz.alexcrea.cuanvil.enchant.WrappedEnchantment
|
||||||
|
|
@ -11,6 +12,11 @@ import java.util.*
|
||||||
|
|
||||||
class EnchantmentSquaredDependency(private val enchantmentSquaredPlugin: Plugin) {
|
class EnchantmentSquaredDependency(private val enchantmentSquaredPlugin: Plugin) {
|
||||||
|
|
||||||
|
fun disableAnvilListener(){
|
||||||
|
PrepareAnvilEvent.getHandlerList().unregister(this.enchantmentSquaredPlugin)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fun registerEnchantments(){
|
fun registerEnchantments(){
|
||||||
for (enchant in CustomEnchantManager.getInstance().allEnchants.values) {
|
for (enchant in CustomEnchantManager.getInstance().allEnchants.values) {
|
||||||
WrappedEnchantment.register(EnchantSquaredEnchantment(enchant))
|
WrappedEnchantment.register(EnchantSquaredEnchantment(enchant))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue