mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-21 14:55:17 +01:00
Fixed sweeping_edge
This commit is contained in:
parent
6aac6c586b
commit
4de4a4ce89
@ -7,7 +7,13 @@ import org.bukkit.enchantments.Enchantment
|
||||
|
||||
val Enchantment.vanillaEnchantmentData: VanillaEnchantmentData?
|
||||
get() {
|
||||
val vanilla = plugin.vanillaEnchantsYml.getSubsectionOrNull(key.key) ?: return null
|
||||
val configKey = if (key.key == "sweeping_edge") {
|
||||
"sweeping"
|
||||
} else {
|
||||
key.key
|
||||
}
|
||||
|
||||
val vanilla = plugin.vanillaEnchantsYml.getSubsectionOrNull(configKey) ?: return null
|
||||
|
||||
return VanillaEnchantmentData(
|
||||
vanilla.getIntOrNull("max-level"),
|
||||
@ -31,12 +37,18 @@ private val enchantmentOptions = arrayOf(
|
||||
|
||||
fun legacyRegisterVanillaEnchantmentData(plugin: EcoEnchantsPlugin) {
|
||||
for (vanilla in plugin.vanillaEnchantsYml.getKeys(false)) {
|
||||
if (enchantmentOptions.any { plugin.vanillaEnchantsYml.has("$vanilla.$it") }) {
|
||||
val key = if (vanilla == "sweeping_edge") {
|
||||
"sweeping"
|
||||
} else {
|
||||
vanilla
|
||||
}
|
||||
|
||||
if (enchantmentOptions.any { plugin.vanillaEnchantsYml.has("$key.$it") }) {
|
||||
plugin.getProxy(EcoCraftEnchantmentManagerProxy::class.java).registerNewCraftEnchantment(
|
||||
Enchantment.getByKey(NamespacedKey.minecraft(vanilla))!!,
|
||||
VanillaEnchantmentData(
|
||||
plugin.vanillaEnchantsYml.getIntOrNull("$vanilla.max-level"),
|
||||
plugin.vanillaEnchantsYml.getStringsOrNull("$vanilla.conflicts")
|
||||
plugin.vanillaEnchantsYml.getIntOrNull("$key.max-level"),
|
||||
plugin.vanillaEnchantsYml.getStringsOrNull("$key.conflicts")
|
||||
?.map { NamespacedKey.minecraft(it) }
|
||||
)
|
||||
)
|
||||
|
@ -13,20 +13,26 @@ class VanillaEcoEnchantLike(
|
||||
override val enchantment: Enchantment,
|
||||
override val plugin: EcoEnchantsPlugin
|
||||
) : EcoEnchantLike {
|
||||
override val config = plugin.vanillaEnchantsYml.getSubsection(enchantment.key.key)
|
||||
private val section = if (enchantment.key.key == "sweeping_edge") {
|
||||
"sweeping"
|
||||
} else {
|
||||
enchantment.key.key
|
||||
}
|
||||
|
||||
override val config = plugin.vanillaEnchantsYml.getSubsection(section)
|
||||
|
||||
override val maximumLevel
|
||||
get() = enchantment.maxLevel
|
||||
|
||||
override val type: EnchantmentType =
|
||||
EnchantmentTypes[plugin.vanillaEnchantsYml.getString("${enchantment.key.key}.type")]
|
||||
EnchantmentTypes[plugin.vanillaEnchantsYml.getString("${section}.type")]
|
||||
?: EnchantmentTypes.values().first()
|
||||
|
||||
override val enchantmentRarity: EnchantmentRarity =
|
||||
EnchantmentRarities[plugin.vanillaEnchantsYml.getString("${enchantment.key.key}.rarity")]
|
||||
EnchantmentRarities[plugin.vanillaEnchantsYml.getString("${section}.rarity")]
|
||||
?: EnchantmentRarities.values().first()
|
||||
|
||||
override val rawDisplayName = plugin.vanillaEnchantsYml.getString("${enchantment.key.key}.name")
|
||||
override val rawDisplayName = plugin.vanillaEnchantsYml.getString("${section}.name")
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is VanillaEcoEnchantLike) {
|
||||
|
Loading…
Reference in New Issue
Block a user