Search in sources :

Example 1 with SkinCallback

use of org.mineskin.data.SkinCallback in project VoxelGamesLibv2 by VoxelGamesLib.

the class TextureHandler method fetchSkin.

public void fetchSkin(int id, String fallBackName, @Nullable SkinCallback skinCallback) {
    // check cache
    Optional<Skin> s = getSkin(id);
    if (s.isPresent()) {
        if (skinCallback != null) {
            skinCallback.done(s.get());
        }
        return;
    }
    // fetch from mineskin
    mineskinClient.getSkin(id, new SkinCallback() {

        @Override
        public void done(Skin skin) {
            if (skin.name.equals("")) {
                skin.name = fallBackName;
            }
            loadedSkins.add(skin);
            TextureHandler.this.saveSkin(skin);
            if (skinCallback != null) {
                skinCallback.done(skin);
            }
        }

        @Override
        public void error(String errorMessage) {
            log.warning("Error while fetching skin #" + id + " (" + fallBackName + "): " + errorMessage);
        }

        @Override
        public void exception(Exception exception) {
            log.log(Level.WARNING, "Error while fetching skin #" + id + " (" + fallBackName + "): ", exception);
        }
    });
}
Also used : Skin(org.mineskin.data.Skin) SkinCallback(org.mineskin.data.SkinCallback) IOException(java.io.IOException)

Example 2 with SkinCallback

use of org.mineskin.data.SkinCallback in project VoxelGamesLibv2 by VoxelGamesLib.

the class TextureHandler method fetchSkin.

public void fetchSkin(@Nonnull String name, @Nonnull String url, @Nullable SkinCallback skinCallback) {
    // check cache
    Optional<Skin> s = getSkin(name);
    if (s.isPresent()) {
        if (skinCallback != null) {
            skinCallback.done(s.get());
        }
        return;
    }
    // fetch from mineskin
    mineskinClient.generateUrl(url, SkinOptions.create(name, Model.DEFAULT, Visibility.PRIVATE), new SkinCallback() {

        @Override
        public void done(Skin skin) {
            loadedSkins.add(skin);
            TextureHandler.this.saveSkin(skin);
            if (skinCallback != null) {
                skinCallback.done(skin);
            }
        }

        @Override
        public void error(String errorMessage) {
            log.warning("Error while fetching skin " + name + " (" + url + "): " + errorMessage);
        }

        @Override
        public void exception(Exception exception) {
            log.log(Level.WARNING, "Error while fetching skin " + name + " (" + url + "): ", exception);
        }
    });
}
Also used : Skin(org.mineskin.data.Skin) SkinCallback(org.mineskin.data.SkinCallback) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 Skin (org.mineskin.data.Skin)2 SkinCallback (org.mineskin.data.SkinCallback)2