use of chatty.util.api.CheerEmoticon in project chatty by chatty.
the class ChannelTextPane method findBits.
private void findBits(Set<CheerEmoticon> emotes, String text, Map<Integer, Integer> ranges, Map<Integer, MutableAttributeSet> rangesStyle, User user) {
for (CheerEmoticon emote : emotes) {
if (!emote.matchesUser(user)) {
// CONTINUE
continue;
}
Matcher m = emote.getMatcher(text);
while (m.find()) {
int start = m.start();
int end = m.end() - 1;
try {
int bits = Integer.parseInt(m.group(1));
int bitsLength = m.group(1).length();
if (bits < emote.min_bits) {
// CONTINUE
continue;
}
boolean ignored = main.emoticons.isEmoteIgnored(emote);
if (!ignored && addEmoticon(emote, start, end - bitsLength, ranges, rangesStyle)) {
// Add emote
addFormattedText(emote.color, end - bitsLength + 1, end, ranges, rangesStyle);
} else {
// Add just text
addFormattedText(emote.color, start, end, ranges, rangesStyle);
}
} catch (NumberFormatException ex) {
System.out.println("Error parsing cheer: " + ex);
}
}
}
}
Aggregations