Search in sources :

Example 1 with TwitchEmoteV2

use of com.glitchcog.fontificator.emoji.loader.twitch.TwitchEmoteV2 in project ChatGameFontificator by GlitchCog.

the class EmojiParser method parseTwitchEmoteJsonV2.

/**
     * Parse emotes loaded using Twitch's emote API version 2
     * 
     * Twitch V2 API retired on February 14, 2017
     * 
     * @param manager
     * @param jsonData
     * @param jsonMapData
     * @throws IOException
     */
@Deprecated
private void parseTwitchEmoteJsonV2(EmojiManager manager, String jsonData, String jsonMapData) throws IOException {
    TypedEmojiMap emoji = manager.getEmojiByType(EmojiType.TWITCH_V2);
    JsonElement emoteElement = new JsonParser().parse(jsonData).getAsJsonObject().get("emoticons");
    Gson gson = new Gson();
    Type emoteType = new TypeToken<TwitchEmoteV2[]>() {
    }.getType();
    TwitchEmoteV2[] jsonEmoteObjects = gson.fromJson(emoteElement, emoteType);
    for (TwitchEmoteV2 e : jsonEmoteObjects) {
        // For Twitch emotes V2, there are no multi-image emotes, I think, based on the JSON structure
        LazyLoadEmoji lle = new LazyLoadEmoji(e.getRegex(), e.getUrl(), e.getWidth(), e.getHeight(), EmojiType.TWITCH_V2);
        lle.setSubscriber(e.isSubscriber_only());
        lle.setState(e.getState());
        emoji.put(e.getRegex(), lle);
    }
    logBox.log(jsonEmoteObjects.length + " Twitch emote" + (jsonEmoteObjects.length == 1 ? "" : "s") + " loaded");
}
Also used : TypedEmojiMap(com.glitchcog.fontificator.emoji.TypedEmojiMap) LazyLoadEmoji(com.glitchcog.fontificator.emoji.LazyLoadEmoji) EmojiType(com.glitchcog.fontificator.emoji.EmojiType) UserType(com.glitchcog.fontificator.bot.UserType) Type(java.lang.reflect.Type) JsonElement(com.google.gson.JsonElement) Gson(com.google.gson.Gson) TwitchEmoteV2(com.glitchcog.fontificator.emoji.loader.twitch.TwitchEmoteV2) JsonParser(com.google.gson.JsonParser)

Aggregations

UserType (com.glitchcog.fontificator.bot.UserType)1 EmojiType (com.glitchcog.fontificator.emoji.EmojiType)1 LazyLoadEmoji (com.glitchcog.fontificator.emoji.LazyLoadEmoji)1 TypedEmojiMap (com.glitchcog.fontificator.emoji.TypedEmojiMap)1 TwitchEmoteV2 (com.glitchcog.fontificator.emoji.loader.twitch.TwitchEmoteV2)1 Gson (com.google.gson.Gson)1 JsonElement (com.google.gson.JsonElement)1 JsonParser (com.google.gson.JsonParser)1 Type (java.lang.reflect.Type)1