| 123456789101112131415161718192021222324252627282930313233343536 |
- package me.lethunderhawk.main.util;
- import net.kyori.adventure.text.Component;
- import net.kyori.adventure.text.format.NamedTextColor;
- import net.kyori.adventure.text.format.TextDecoration;
- import org.bukkit.inventory.meta.ItemMeta;
- import java.util.ArrayList;
- import java.util.List;
- public class UnItalic {
- public static Component removeItalic(Component component){
- return component.decoration(TextDecoration.ITALIC, false);
- }
- public static List<Component> removeItalic(List<Component> components){
- List<Component> newComponents = new ArrayList<>();
- for(Component component : components){
- newComponents.add(component.decoration(TextDecoration.ITALIC, false));
- }
- return newComponents;
- }
- public static Component text(String text){
- return removeItalic(Component.text(text, NamedTextColor.GRAY));
- }
- /**
- *
- * @param itemMeta The {@link ItemMeta} you want to remove the Italic from
- * @return The {@link ItemMeta} with Italic style removed from lore and displayName
- */
- public static ItemMeta removeItalicFromMeta(ItemMeta itemMeta) {
- if(itemMeta.hasLore()) itemMeta.lore(removeItalic(itemMeta.lore()));
- if(itemMeta.hasDisplayName()) itemMeta.displayName(removeItalic(itemMeta.displayName()));
- return itemMeta;
- }
- }
|