Skip to content

Commit

Permalink
Merge branch 'Auxilor:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
LangZongz authored Jan 15, 2024
2 parents ce6ff5c + 0959d55 commit 42ae3ae
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class EcoEnchantsCraftEnchantment(
}

override fun onRegister() {
enchant.onRegister()
// Fix for hardcoded enchantments
if (plugin.isLoaded) {
enchant.onRegister()
}
}

override fun onRemove() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.bukkit.ChatColor
object EcoEnchants : RegistrableCategory<EcoEnchant>("enchant", "enchants") {
private val BY_NAME = HashBiMap.create<String, EcoEnchant>()

override val shouldPreload = true

override fun clear(plugin: LibreforgePlugin) {
plugin as EcoEnchantsPlugin

Expand Down Expand Up @@ -56,6 +58,26 @@ object EcoEnchants : RegistrableCategory<EcoEnchant>("enchant", "enchants") {
registerHardcodedEnchantments(plugin)
}

override fun acceptPreloadConfig(plugin: LibreforgePlugin, id: String, config: Config) {
plugin as EcoEnchantsPlugin

if (!config.has("effects")) {
return
}

try {
val enchant = LibreforgeEcoEnchant(
id,
config,
plugin
)

doRegister(plugin, enchant)
} catch (e: MissingDependencyException) {
// Ignore missing dependencies for preloaded enchants
}
}

override fun acceptConfig(plugin: LibreforgePlugin, id: String, config: Config) {
plugin as EcoEnchantsPlugin

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.willfp.ecoenchants.enchant.impl

import com.willfp.eco.core.config.interfaces.Config
import com.willfp.eco.core.fast.fast
import com.willfp.eco.core.placeholder.PlayerlessPlaceholder
import com.willfp.eco.core.placeholder.context.PlaceholderContext
import com.willfp.eco.core.placeholder.templates.SimpleInjectablePlaceholder
import com.willfp.eco.util.containsIgnoreCase
import com.willfp.ecoenchants.EcoEnchantsPlugin
import com.willfp.ecoenchants.display.getFormattedName
Expand All @@ -15,6 +12,7 @@ import com.willfp.ecoenchants.rarity.EnchantmentRarity
import com.willfp.ecoenchants.target.EnchantmentTargets
import com.willfp.ecoenchants.type.EnchantmentType
import com.willfp.ecoenchants.type.EnchantmentTypes
import com.willfp.libreforge.SilentViolationContext
import com.willfp.libreforge.ViolationContext
import com.willfp.libreforge.conditions.Conditions
import org.bukkit.Bukkit
Expand Down Expand Up @@ -68,7 +66,7 @@ abstract class EcoEnchantBase(

override val conditions = Conditions.compile(
config.getSubsections("conditions"),
context.with("conditions")
if (plugin.isLoaded) context.with("conditions") else SilentViolationContext
)

override val isObtainableThroughEnchanting = config.getBool("enchantable")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class LegacyDelegatedEnchantment(
}

override fun onRegister() {
enchant.onRegister()
// Fix for hardcoded enchantments
if (plugin.isLoaded) {
enchant.onRegister()
}
}

override fun onRemove() {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#libreforge-updater
#Sun Jan 07 13:52:14 GMT 2024
#Sat Jan 13 14:24:20 GMT 2024
kotlin.code.style=official
libreforge-version=4.54.0
version=12.1.0
libreforge-version=4.55.0
version=12.2.1

0 comments on commit 42ae3ae

Please sign in to comment.