9
0
mirror of https://github.com/Auxilor/EcoSkills.git synced 2025-12-19 15:09:23 +00:00

Migrated from CategoryWithRegistry to RegistrableCategory

This commit is contained in:
Auxilor
2024-07-07 15:09:06 +01:00
parent 2f1ae21b9e
commit e34b731b67
5 changed files with 8 additions and 24 deletions

View File

@@ -1,16 +0,0 @@
package com.willfp.ecoskills
import com.willfp.eco.core.registry.Registrable
import com.willfp.eco.core.registry.Registry
import com.willfp.libreforge.loader.configs.ConfigCategory
abstract class CategoryWithRegistry<T : Registrable>(
id: String,
directory: String
) : ConfigCategory(id, directory) {
protected val registry = Registry<T>()
fun getByID(id: String?): T? = id?.let { registry[id] }
fun values(): Set<T> = registry.values()
}

View File

@@ -1,11 +1,11 @@
package com.willfp.ecoskills.effects
import com.willfp.eco.core.config.interfaces.Config
import com.willfp.ecoskills.CategoryWithRegistry
import com.willfp.ecoskills.EcoSkillsPlugin
import com.willfp.libreforge.loader.LibreforgePlugin
import com.willfp.libreforge.loader.configs.RegistrableCategory
object Effects : CategoryWithRegistry<Effect>("effect", "effects") {
object Effects : RegistrableCategory<Effect>("effect", "effects") {
override val supportsSharing = false
override fun clear(plugin: LibreforgePlugin) {

View File

@@ -1,11 +1,11 @@
package com.willfp.ecoskills.magic
import com.willfp.eco.core.config.interfaces.Config
import com.willfp.ecoskills.CategoryWithRegistry
import com.willfp.ecoskills.EcoSkillsPlugin
import com.willfp.libreforge.loader.LibreforgePlugin
import com.willfp.libreforge.loader.configs.RegistrableCategory
object MagicTypes : CategoryWithRegistry<MagicType>("magic_type", "magic_types") {
object MagicTypes : RegistrableCategory<MagicType>("magic_type", "magic_types") {
override val supportsSharing = false
override fun clear(plugin: LibreforgePlugin) {

View File

@@ -2,18 +2,18 @@ package com.willfp.ecoskills.skills
import com.github.benmanes.caffeine.cache.Caffeine
import com.willfp.eco.core.config.interfaces.Config
import com.willfp.ecoskills.CategoryWithRegistry
import com.willfp.ecoskills.EcoSkillsPlugin
import com.willfp.ecoskills.api.totalSkillLevel
import com.willfp.ecoskills.gui.menus.SkillsGUI
import com.willfp.ecoskills.util.InvalidConfigurationException
import com.willfp.ecoskills.util.LeaderboardEntry
import com.willfp.libreforge.loader.LibreforgePlugin
import com.willfp.libreforge.loader.configs.RegistrableCategory
import org.bukkit.Bukkit
import java.util.UUID
import java.util.concurrent.TimeUnit
object Skills : CategoryWithRegistry<Skill>("skill", "skills") {
object Skills : RegistrableCategory<Skill>("skill", "skills") {
// Totally not copied over from Levellable
private val leaderboardCache = Caffeine.newBuilder()
.expireAfterWrite(1, TimeUnit.MINUTES)

View File

@@ -3,14 +3,14 @@ package com.willfp.ecoskills.stats
import com.willfp.eco.core.config.interfaces.Config
import com.willfp.eco.core.placeholder.PlayerPlaceholder
import com.willfp.eco.util.toNiceString
import com.willfp.ecoskills.CategoryWithRegistry
import com.willfp.ecoskills.EcoSkillsPlugin
import com.willfp.ecoskills.api.averageSkillLevel
import com.willfp.ecoskills.api.totalSkillLevel
import com.willfp.ecoskills.gui.menus.StatsGUI
import com.willfp.libreforge.loader.LibreforgePlugin
import com.willfp.libreforge.loader.configs.RegistrableCategory
object Stats : CategoryWithRegistry<Stat>("stat", "stats") {
object Stats : RegistrableCategory<Stat>("stat", "stats") {
override val supportsSharing = false
override fun beforeReload(plugin: LibreforgePlugin) {