use of com.glitchcog.fontificator.emoji.loader.twitch.TwitchEmoteV3 in project ChatGameFontificator by GlitchCog.
the class EmojiParser method parseTwitchEmoteJsonV3.
/**
* Parses emotes loaded using Twitch's emote API version 3. It parses emotes into two different maps, one of all
* emoji, and one that are accessible via set ID.
*
* Twitch V3 API retired on February 14, 2017
*
* @param manager
* @param jsonData
* @param jsonMapData
* @throws IOException
*/
@Deprecated
private void parseTwitchEmoteJsonV3(EmojiManager manager, String jsonData, String jsonMapData) throws IOException {
logger.trace(jsonData.substring(0, Math.min(jsonData.length(), 512)));
TypedEmojiMap emoji = manager.getEmojiByType(EmojiType.TWITCH_V3);
Gson gson = new Gson();
// Handle actual emotes
JsonElement emoteElement = new JsonParser().parse(jsonData).getAsJsonObject().get("emoticons");
Type emoteType = new TypeToken<TwitchEmoteV3[]>() {
}.getType();
TwitchEmoteV3[] jsonEmoteObjects = gson.fromJson(emoteElement, emoteType);
int eMultiCount = 0;
for (TwitchEmoteV3 e : jsonEmoteObjects) {
LazyLoadEmoji lle = new LazyLoadEmoji(e.getRegex(), e.getImages()[0].getUrl(), e.getImages()[0].getWidth(), e.getImages()[0].getHeight(), EmojiType.TWITCH_V3);
if (e.getImages().length > 1) {
eMultiCount++;
}
emoji.put(e.getRegex(), lle);
}
logBox.log(jsonEmoteObjects.length + " Twitch emote" + (jsonEmoteObjects.length == 1 ? "" : "s") + " loaded (" + eMultiCount + " multi-image emote" + (eMultiCount == 1 ? "" : "s") + ")");
}
Aggregations