Added following placeholders to the enchantment info slot:

%tradeable% - returns if the enchantment can be traded from villagers
%discoverable% - returns if the enchantment can be found in the loot chests
%enchantable% - returns if the enchantment can be found in the enchantment table
This commit is contained in:
_OfTeN_
2023-04-15 13:24:13 +03:00
parent 90f7a3bbac
commit 36ad5e0ee4
2 changed files with 14 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ import com.willfp.eco.core.items.builder.ItemStackBuilder
import com.willfp.eco.core.items.isEmpty
import com.willfp.eco.util.StringUtils
import com.willfp.eco.util.formatEco
import com.willfp.eco.util.toNiceString
import com.willfp.ecoenchants.EcoEnchantsPlugin
import com.willfp.ecoenchants.display.EnchantSorter.sortForDisplay
import com.willfp.ecoenchants.display.getFormattedName
@@ -261,6 +262,12 @@ 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))
}
.flatMap {
WordUtils.wrap(it, 45, "\n", false)
@@ -279,3 +286,8 @@ private fun EcoEnchant.getInformationSlot(plugin: EcoEnchantsPlugin): Slot {
)
}
}
val Boolean.yesOrNo: String
get() {
return if (this) "yes" else "no"
}

View File

@@ -17,5 +17,7 @@ messages:
all: "All"
yes: "&aYes"
no: "&cNo"
no-conflicts: "No Conflicts"
all-conflicts: "All Other Enchantments"