Cleaned up PR, updated preloading
This commit is contained in:
@@ -18,6 +18,7 @@ import com.willfp.ecoenchants.target.EnchantLookup.getEnchantLevel
|
||||
import com.willfp.ecoenchants.target.EnchantmentTargets
|
||||
import com.willfp.ecoenchants.target.TargetSlot
|
||||
import com.willfp.ecoenchants.type.EnchantmentTypes
|
||||
import com.willfp.libreforge.SilentViolationContext
|
||||
import com.willfp.libreforge.ViolationContext
|
||||
import com.willfp.libreforge.conditions.ConditionList
|
||||
import com.willfp.libreforge.conditions.Conditions
|
||||
@@ -44,7 +45,7 @@ import java.util.Objects
|
||||
abstract class EcoEnchant(
|
||||
val id: String,
|
||||
configProvider: (EcoEnchant) -> Config,
|
||||
protected val plugin: EcoPlugin
|
||||
protected val plugin: EcoEnchantsPlugin
|
||||
) : Enchantment(NamespacedKey.minecraft(id)), EcoEnchantLike {
|
||||
final override val config by lazy { configProvider(this) }
|
||||
override val enchant by lazy { this }
|
||||
@@ -85,19 +86,19 @@ abstract class EcoEnchant(
|
||||
|
||||
constructor(
|
||||
config: Config,
|
||||
plugin: EcoPlugin
|
||||
plugin: EcoEnchantsPlugin
|
||||
) : this(config.getString("id"), { config }, plugin)
|
||||
|
||||
constructor(
|
||||
id: String,
|
||||
config: Config,
|
||||
plugin: EcoPlugin
|
||||
plugin: EcoEnchantsPlugin
|
||||
) : this(id, { config }, plugin)
|
||||
|
||||
@JvmOverloads
|
||||
constructor(
|
||||
id: String,
|
||||
plugin: EcoPlugin,
|
||||
plugin: EcoEnchantsPlugin,
|
||||
force: Boolean = true
|
||||
) : this(
|
||||
id,
|
||||
@@ -130,7 +131,8 @@ abstract class EcoEnchant(
|
||||
|
||||
conditions = Conditions.compile(
|
||||
config.getSubsections("conditions"),
|
||||
ViolationContext(plugin, "Enchantment $id")
|
||||
if (plugin.isLoaded) ViolationContext(plugin, "Enchantment $id")
|
||||
else SilentViolationContext
|
||||
)
|
||||
|
||||
if (Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.$id") == null) {
|
||||
|
||||
@@ -27,6 +27,8 @@ object EcoEnchants : ConfigCategory("enchant", "enchants") {
|
||||
private val BY_KEY = HashBiMap.create<String, EcoEnchant>()
|
||||
private val BY_NAME = HashBiMap.create<String, EcoEnchant>()
|
||||
|
||||
override val shouldPreload = true
|
||||
|
||||
/**
|
||||
* Get all registered [EcoEnchant]s.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.ecoenchants.enchants
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine
|
||||
import com.willfp.eco.core.config.base.LangYml
|
||||
import com.willfp.eco.core.config.updating.ConfigUpdater
|
||||
import com.willfp.eco.core.drops.DropQueue
|
||||
import com.willfp.eco.core.fast.fast
|
||||
@@ -262,12 +263,9 @@ private fun EcoEnchant.getInformationSlot(plugin: EcoEnchantsPlugin): Slot {
|
||||
}.ifEmpty { plugin.langYml.getFormattedString("no-conflicts").toWrappable() }
|
||||
}
|
||||
)
|
||||
.replace("%tradeable%", plugin.langYml
|
||||
.getFormattedString(this.isTradeable.yesOrNo))
|
||||
.replace("%discoverable%", plugin.langYml
|
||||
.getFormattedString(this.isDiscoverable.yesOrNo))
|
||||
.replace("%enchantable%", plugin.langYml
|
||||
.getFormattedString(this.isEnchantable.yesOrNo))
|
||||
.replace("%tradeable%", this.isTradeable.parseYesOrNo(plugin.langYml))
|
||||
.replace("%discoverable%", this.isDiscoverable.parseYesOrNo(plugin.langYml))
|
||||
.replace("%enchantable%", this.isEnchantable.parseYesOrNo(plugin.langYml))
|
||||
}
|
||||
.flatMap {
|
||||
WordUtils.wrap(it, 45, "\n", false)
|
||||
@@ -287,7 +285,6 @@ private fun EcoEnchant.getInformationSlot(plugin: EcoEnchantsPlugin): Slot {
|
||||
}
|
||||
}
|
||||
|
||||
val Boolean.yesOrNo: String
|
||||
get() {
|
||||
return if (this) "yes" else "no"
|
||||
fun Boolean.parseYesOrNo(langYml: LangYml): String {
|
||||
return if (this) langYml.getFormattedString("yes") else langYml.getFormattedString("no")
|
||||
}
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
package com.willfp.ecoenchants.enchants
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.config.interfaces.Config
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin
|
||||
import com.willfp.libreforge.Holder
|
||||
import com.willfp.libreforge.SilentViolationContext
|
||||
import com.willfp.libreforge.ViolationContext
|
||||
import com.willfp.libreforge.conditions.ConditionList
|
||||
import com.willfp.libreforge.effects.EffectList
|
||||
import com.willfp.libreforge.effects.Effects
|
||||
import com.willfp.libreforge.effects.emptyEffectList
|
||||
import com.willfp.libreforge.loader.LibreforgePlugin
|
||||
import java.util.Objects
|
||||
|
||||
class LibReforgeEcoEnchant(
|
||||
id: String,
|
||||
config: Config,
|
||||
plugin: EcoPlugin
|
||||
plugin: EcoEnchantsPlugin
|
||||
) : EcoEnchant(
|
||||
id,
|
||||
config,
|
||||
@@ -23,7 +18,8 @@ class LibReforgeEcoEnchant(
|
||||
) {
|
||||
private val effects = Effects.compile(
|
||||
config.getSubsections("effects"),
|
||||
ViolationContext(plugin, "Enchantment $id")
|
||||
if (plugin.isLoaded) ViolationContext(plugin, "Enchantment $id")
|
||||
else SilentViolationContext
|
||||
)
|
||||
|
||||
override fun createLevel(level: Int): EcoEnchantLevel =
|
||||
|
||||
@@ -20,4 +20,4 @@ all: "All"
|
||||
yes: "&aYes"
|
||||
no: "&cNo"
|
||||
no-conflicts: "No Conflicts"
|
||||
all-conflicts: "All Other Enchantments"
|
||||
all-conflicts: "All Other Enchantments"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#libreforge-updater
|
||||
#Wed Apr 19 12:21:42 BST 2023
|
||||
kotlin.code.style=official
|
||||
libreforge-version=4.3.0
|
||||
libreforge-version=4.4.0
|
||||
version=10.3.1
|
||||
|
||||
Reference in New Issue
Block a user