UnItalic.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package me.lethunderhawk.main.util;
  2. import net.kyori.adventure.text.Component;
  3. import net.kyori.adventure.text.format.NamedTextColor;
  4. import net.kyori.adventure.text.format.TextDecoration;
  5. import org.bukkit.inventory.meta.ItemMeta;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8. public class UnItalic {
  9. public static Component removeItalic(Component component){
  10. return component.decoration(TextDecoration.ITALIC, false);
  11. }
  12. public static List<Component> removeItalic(List<Component> components){
  13. List<Component> newComponents = new ArrayList<>();
  14. for(Component component : components){
  15. newComponents.add(component.decoration(TextDecoration.ITALIC, false));
  16. }
  17. return newComponents;
  18. }
  19. public static Component text(String text){
  20. return removeItalic(Component.text(text, NamedTextColor.GRAY));
  21. }
  22. /**
  23. *
  24. * @param itemMeta The {@link ItemMeta} you want to remove the Italic from
  25. * @return The {@link ItemMeta} with Italic style removed from lore and displayName
  26. */
  27. public static ItemMeta removeItalicFromMeta(ItemMeta itemMeta) {
  28. if(itemMeta.hasLore()) itemMeta.lore(removeItalic(itemMeta.lore()));
  29. if(itemMeta.hasDisplayName()) itemMeta.displayName(removeItalic(itemMeta.displayName()));
  30. return itemMeta;
  31. }
  32. }