Skip to content

Commit

Permalink
Added tags.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Jul 21, 2024
1 parent bfbdfb7 commit 33c2b20
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import com.willfp.eco.core.command.impl.PluginCommand
import com.willfp.eco.core.display.DisplayModule
import com.willfp.eco.core.integrations.IntegrationLoader
import com.willfp.eco.core.integrations.afk.AFKManager
import com.willfp.eco.core.items.Items
import com.willfp.libreforge.commands.CommandLibreforge
import com.willfp.libreforge.configs.ChainsYml
import com.willfp.libreforge.configs.TagsYml
import com.willfp.libreforge.configs.lrcdb.CommandLrcdb
import com.willfp.libreforge.display.ItemFlagDisplay
import com.willfp.libreforge.effects.Effects
Expand All @@ -33,6 +35,7 @@ import com.willfp.libreforge.integrations.worldguard.WorldGuardIntegration
import com.willfp.libreforge.levels.LevelTypes
import com.willfp.libreforge.levels.placeholder.*
import com.willfp.libreforge.placeholders.CustomPlaceholders
import com.willfp.libreforge.tags.CustomTag
import com.willfp.libreforge.triggers.DispatchedTriggerFactory
import org.bukkit.Bukkit
import org.bukkit.entity.LivingEntity
Expand All @@ -43,6 +46,7 @@ internal lateinit var plugin: LibreforgeSpigotPlugin

class LibreforgeSpigotPlugin : EcoPlugin() {
val chainsYml = ChainsYml(this)
val tagsYml = TagsYml(this)

val dispatchedTriggerFactory = DispatchedTriggerFactory(this)

Expand Down Expand Up @@ -106,6 +110,10 @@ class LibreforgeSpigotPlugin : EcoPlugin() {
)
}

for (config in tagsYml.getSubsections("tags")) {
Items.registerTag(CustomTag(config, this))
}

for (customPlaceholder in this.configYml.getSubsections("placeholders")) {
CustomPlaceholders.load(customPlaceholder, this)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.willfp.libreforge.configs

import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.config.BaseConfig
import com.willfp.eco.core.config.ConfigType

class TagsYml(
plugin: EcoPlugin
): BaseConfig(
"tags",
plugin,
true,
ConfigType.YAML
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.willfp.libreforge.tags

import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.config.interfaces.Config
import com.willfp.eco.core.items.Items
import com.willfp.eco.core.items.matches
import com.willfp.eco.core.items.tag.CustomItemTag
import com.willfp.eco.core.recipe.parts.EmptyTestableItem
import org.bukkit.inventory.ItemStack

class CustomTag(
config: Config,
plugin: EcoPlugin
): CustomItemTag(plugin.createNamespacedKey(config.getString("id"))) {
private val items = config.getStrings("items")
.map { Items.lookup(it) }
.filterNot { it is EmptyTestableItem }

override fun matches(p0: ItemStack): Boolean {
return items.matches(p0)
}

override fun getExampleItem(): ItemStack? {
return items.firstOrNull()?.item
}
}
8 changes: 8 additions & 0 deletions core/common/src/main/resources/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Custom item tags, read here for more: https://plugins.auxilor.io/all-plugins/the-item-lookup-system#item-tags
# You can use these tags in the item lookup system with "#libreforge:<tag_id>"

tags:
- id: example_tag
items:
- "netherite_sword"
- "diamond_sword"

0 comments on commit 33c2b20

Please sign in to comment.