mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-22 04:37:42 +01:00
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:
parent
47a2fe0fbc
commit
b0f442f9be
@ -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("_", " "));
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user