9
0
mirror of https://github.com/Auxilor/Reforges.git synced 2026-01-04 15:41:40 +00:00

Added support for item placeholders

This commit is contained in:
Auxilor
2023-11-11 15:00:10 +00:00
parent 7bd43e6506
commit ff3af6b412
3 changed files with 12 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ import com.willfp.eco.core.display.DisplayPriority
import com.willfp.eco.core.display.DisplayProperties
import com.willfp.eco.core.fast.FastItemStack
import com.willfp.eco.core.fast.fast
import com.willfp.eco.core.placeholder.context.placeholderContext
import com.willfp.eco.util.SkullUtils
import com.willfp.eco.util.StringUtils
import com.willfp.eco.util.formatEco
@@ -47,12 +48,15 @@ class ReforgesDisplay(private val plugin: ReforgesPlugin) : DisplayModule(plugin
val reforge = fast.persistentDataContainer.reforge
val context = placeholderContext(
player = player,
item = itemStack
)
if (reforge == null && stone == null) {
if (plugin.configYml.getBool("reforge.show-reforgable")) {
if (plugin.configYml.getBool("reforge.no-reforgable-in-gui")) {
if (props.inGui) {
return
}
if (props.inGui) {
return
}
val addLore: MutableList<String> = ArrayList()
@@ -91,10 +95,11 @@ class ReforgesDisplay(private val plugin: ReforgesPlugin) : DisplayModule(plugin
for (string in plugin.configYml.getFormattedStrings("reforge.reforged-prefix")) {
addLore.add(Display.PREFIX + string.replace("%reforge%", reforge.name))
}
addLore.addAll(reforge.description)
addLore.addAll(reforge.description.formatEco(context))
addLore.replaceAll { "${Display.PREFIX}$it" }
lore.addAll(addLore)
}
if (plugin.configYml.getBool("reforge.display-in-name")) {
val displayName = fastItemStack.displayNameComponent

View File

@@ -33,7 +33,7 @@ class Reforge(
val namePrefixComponent = StringUtils.toComponent("$name ").decoration(TextDecoration.ITALIC, false)
val description: List<String> = config.getFormattedStrings("description")
val description: List<String> = config.getStrings("description")
val targets = config.getStrings("targets").mapNotNull { ReforgeTargets.getByName(it) }.toSet()

View File

@@ -146,12 +146,11 @@ reforge:
reforgable-suffix:
- ""
- "&8This item can be reforged!"
no-reforgable-in-gui: true # Not perfect, won't work 100% of the time
# due to how GUIs are handled differently in different plugins, but should help.
display-in-lore: true
display-in-name: true
# The lore to display if an item is reforged, above the reforge description
reforged-prefix:
- ""
- "%reforge%"