SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static String fromComponent(IChatBaseComponent component) {
  2.         return fromComponent(component, EnumChatFormat.BLACK);
  3.     }
  4.  
  5.     public static String toJSON(IChatBaseComponent component) {
  6.         return IChatBaseComponent.ChatSerializer.a(component);
  7.     }
  8.  
  9.     public static String fromComponent(IChatBaseComponent component, EnumChatFormat defaultColor) {
  10.         if (component == null) return "";
  11.         StringBuilder out = new StringBuilder();
  12.  
  13.         for (IChatBaseComponent c : (Iterable<IChatBaseComponent>) component) {
  14.             ChatModifier modi = c.getChatModifier();
  15.             out.append(modi.getColor() == null ? defaultColor : modi.getColor());
  16.             if (modi.isBold()) {
  17.                 out.append(EnumChatFormat.BOLD);
  18.             }
  19.             if (modi.isItalic()) {
  20.                 out.append(EnumChatFormat.ITALIC);
  21.             }
  22.             if (modi.isUnderlined()) {
  23.                 out.append(EnumChatFormat.UNDERLINE);
  24.             }
  25.             if (modi.isStrikethrough()) {
  26.                 out.append(EnumChatFormat.STRIKETHROUGH);
  27.             }
  28.             if (modi.isRandom()) {
  29.                 out.append(EnumChatFormat.OBFUSCATED);
  30.             }
  31.             out.append(c.getText());
  32.         }
  33.         return out.toString().replaceFirst("^(" + defaultColor + ")*", "");
  34.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top