Search in sources :

Example 6 with TypedEmojiMap

use of com.glitchcog.fontificator.emoji.TypedEmojiMap in project ChatGameFontificator by GlitchCog.

the class EmojiParser method parseTwitchBadges.

private void parseTwitchBadges(TypedEmojiMap badgeMap, String jsonData) throws IOException {
    JsonElement jsonElement = new JsonParser().parse(jsonData);
    Gson gson = new Gson();
    Type emoteType = new TypeToken<Map<String, TwitchBadges>>() {
    }.getType();
    Map<String, TwitchBadges> jsonMap = gson.fromJson(jsonElement, emoteType);
    int badgeCount = 0;
    for (Entry<String, TwitchBadges> badge : jsonMap.entrySet()) {
        if (badge.getValue() != null && badge.getValue().getImage() != null) {
            badgeCount++;
            LazyLoadEmoji llBadge = new LazyLoadEmoji(badge.getKey(), badge.getValue().getImage(), TWITCH_BADGE_PIXEL_SIZE, TWITCH_BADGE_PIXEL_SIZE, EmojiType.TWITCH_BADGE);
            badgeMap.put(badge.getKey(), llBadge);
        }
    }
    logBox.log(badgeCount + " Twitch badge" + (badgeCount == 1 ? "" : "s") + " loaded");
}
Also used : 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) TypedEmojiMap(com.glitchcog.fontificator.emoji.TypedEmojiMap) HashMap(java.util.HashMap) Map(java.util.Map) TwitchBadges(com.glitchcog.fontificator.emoji.loader.twitch.TwitchBadges) JsonParser(com.google.gson.JsonParser)

Aggregations

LazyLoadEmoji (com.glitchcog.fontificator.emoji.LazyLoadEmoji)6 TypedEmojiMap (com.glitchcog.fontificator.emoji.TypedEmojiMap)6 EmojiType (com.glitchcog.fontificator.emoji.EmojiType)5 UserType (com.glitchcog.fontificator.bot.UserType)4 Gson (com.google.gson.Gson)4 JsonElement (com.google.gson.JsonElement)4 JsonParser (com.google.gson.JsonParser)4 Type (java.lang.reflect.Type)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 EmojiOperation (com.glitchcog.fontificator.emoji.EmojiOperation)1 FfzEmote (com.glitchcog.fontificator.emoji.loader.frankerfacez.FfzEmote)1 TwitchBadges (com.glitchcog.fontificator.emoji.loader.twitch.TwitchBadges)1 TwitchEmoteV2 (com.glitchcog.fontificator.emoji.loader.twitch.TwitchEmoteV2)1 TwitchEmoteV3 (com.glitchcog.fontificator.emoji.loader.twitch.TwitchEmoteV3)1 EmojiCancelException (com.glitchcog.fontificator.gui.emoji.exception.EmojiCancelException)1 EmojiHaltException (com.glitchcog.fontificator.gui.emoji.exception.EmojiHaltException)1 SpriteCharacterKey (com.glitchcog.fontificator.sprite.SpriteCharacterKey)1 JsonArray (com.google.gson.JsonArray)1