Commits
md_5 authored 1601ec31e3e
37 37 | } |
38 38 | |
39 39 | public static ChatColor getColor(EnumChatFormat format) { |
40 40 | return ChatColor.getByChar(format.character); |
41 41 | } |
42 42 | |
43 43 | private static final class StringMessage { |
44 44 | private static final Pattern INCREMENTAL_PATTERN = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-orx])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " \\n]|$))))|(\\n)", Pattern.CASE_INSENSITIVE); |
45 45 | // Separate pattern with no group 3, new lines are part of previous string |
46 46 | private static final Pattern INCREMENTAL_PATTERN_KEEP_NEWLINES = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-orx])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " ]|$))))", Pattern.CASE_INSENSITIVE); |
47 + | // ChatColor.b does not explicitly reset, its more of empty |
48 + | private static final ChatModifier RESET = ChatModifier.b.setBold(false).setItalic(false).setUnderline(false).setStrikethrough(false).setRandom(false); |
47 49 | |
48 50 | private final List<IChatBaseComponent> list = new ArrayList<IChatBaseComponent>(); |
49 51 | private IChatMutableComponent currentChatComponent = new ChatComponentText(""); |
50 52 | private ChatModifier modifier = ChatModifier.b; |
51 53 | private final IChatBaseComponent[] output; |
52 54 | private int currentIndex; |
53 55 | private StringBuilder hex; |
54 56 | private final String message; |
55 57 | |
56 58 | private StringMessage(String message, boolean keepNewlines) { |
102 104 | case UNDERLINE: |
103 105 | modifier = modifier.setUnderline(Boolean.TRUE); |
104 106 | break; |
105 107 | case OBFUSCATED: |
106 108 | modifier = modifier.setRandom(Boolean.TRUE); |
107 109 | break; |
108 110 | default: |
109 111 | throw new AssertionError("Unexpected message format"); |
110 112 | } |
111 113 | } else { // Color resets formatting |
112 - | modifier = ChatModifier.b.setColor(format); |
114 + | modifier = RESET.setColor(format); |
113 115 | } |
114 116 | needsAdd = true; |
115 117 | break; |
116 118 | case 2: |
117 119 | if (!(match.startsWith("http://") || match.startsWith("https://"))) { |
118 120 | match = "http://" + match; |
119 121 | } |
120 122 | modifier = modifier.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match)); |
121 123 | appendNewComponent(matcher.end(groupId)); |
122 124 | modifier = modifier.setChatClickable((ChatClickable) null); |