Search in sources :

Example 1 with TwitchBadges

use of com.glitchcog.fontificator.emoji.loader.twitch.TwitchBadges 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

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 TwitchBadges (com.glitchcog.fontificator.emoji.loader.twitch.TwitchBadges)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 HashMap (java.util.HashMap)1 Map (java.util.Map)1