You can now use <tier-color-cleaned> as a substitute of <tier-color>.

`<tier-color-cleaned>` will NOT include Bold, Italic, Underline, Strike, and Magic from your tier.
This can be used if you want your Tier to be Bold, but only want your Item Name to match the color and not the Boldness for example.

https://git.mythiccraft.io/mythiccraft/mmoitems/-/wikis/Display-Name-Placeholders
This commit is contained in:
Dancull47 2021-04-14 21:29:51 -04:00
parent 47a2fe0fbc
commit b0f442f9be
2 changed files with 13 additions and 1 deletions

View File

@ -70,7 +70,7 @@ public class MMOItemIngredient extends Ingredient {
private String findName() {
if (template.getBaseItemData().containsKey(ItemStats.NAME))
return template.getBaseItemData().get(ItemStats.NAME).toString().replace("<tier-color>", "").replace("<tier-name>", "");
return template.getBaseItemData().get(ItemStats.NAME).toString().replace("<tier-color>", "").replace("<tier-name>", "").replace("<tier-color-cleaned>", "");
if (template.getBaseItemData().containsKey(ItemStats.MATERIAL))
return MMOUtils.caseOnWords(
((MaterialData) template.getBaseItemData().get(ItemStats.MATERIAL)).getMaterial().name().toLowerCase().replace("_", " "));

View File

@ -10,13 +10,17 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.stat.data.StringData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.StringStat;
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.ChatColor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.logging.Level;
public class DisplayName extends StringStat {
private final String[] cleanFilter = {ChatColor.BOLD.toString(), ChatColor.ITALIC.toString(), ChatColor.UNDERLINE.toString(), ChatColor.STRIKETHROUGH.toString(), ChatColor.MAGIC.toString()};
public DisplayName() {
super("NAME", VersionMaterial.OAK_SIGN.toMaterial(), "Display Name", new String[] { "The item display name." },
new String[] { "all" });
@ -30,6 +34,13 @@ public class DisplayName extends StringStat {
ItemTier tier = MMOItems.plugin.getTiers().findTier(item.getMMOItem());
format = format.replace("<tier-name>", tier != null ? ChatColor.stripColor(tier.getName()) : "");
format = format.replace("<tier-color>", tier != null ? ChatColor.getLastColors(tier.getName()) : "&f");
if (tier != null) {
for (String filter: cleanFilter){
if (ChatColor.getLastColors(tier.getName()).contains(filter)){
format = format.replace("<tier-color-cleaned>", ChatColor.getLastColors(tier.getName().replace(filter, "")));
}
}
}
// Is this upgradable?
if (item.getMMOItem().hasUpgradeTemplate()) {
@ -119,6 +130,7 @@ public class DisplayName extends StringStat {
item.getMeta().setDisplayName(MythicLib.plugin.parseColors(format));
}
String levelPrefix(@NotNull String template, int toLevel) {
// Ez