stelar7/R4J

Fixing ImageAPI.getSplashArt() methods

samDobsonDev opened this issue · 0 comments

When retrieving splash art images from DDragon, the version of the game is not needed, the image suffix is .jpg rather than .png, and the StaticChampion.getKey() field is used as a prefix to the skin number. To fix this issue:

Within ImageAPI I've added a new method buildSplashImageURL():

private String buildSplashImageURL(String file)
    {
        Realm  realm         = DDragonAPI.getInstance().getRealm();
        String cdn           = realm.getCDN();

        String preReplace = cdn + Constants.SEPARATOR  + "img/champion/splash" + Constants.SEPARATOR + file;
        return preReplace.replace(" ", "%20");
    }

I've then amended both the pre-existing getSplashArt() methods:

public String getSplashArt(String championKey, int skinNum)
{
        // http://ddragon.leagueoflegends.com/cdn/img/champion/splash/Aatrox_0.jpg
        return buildSplashImageURL(championKey + "_" + skinNum + ".jpg");
}
public String getSplashArt(String championKey, Skin skin)
{
        // http://ddragon.leagueoflegends.com/cdn/img/champion/splash/Aatrox_0.jpg
        return buildSplashImageURL(championKey + "_" + skin.getNum() + ".jpg");
}

This will now return the splash art for a given champion's skin in the correct format, e.g:

https://ddragon.leagueoflegends.com/cdn/img/champion/splash/Gnar_0.jpg

whereas before it was returning it in this format:

https://ddragon.leagueoflegends.com/cdn/13.11.1/img/champion/splash/150_0.png (where 150 is the champion ID)
or
https://ddragon.leagueoflegends.com/cdn/13.11.1/img/champion/splash/150000_0.png (where 150000 is the skin ID)