Search in sources :

Example 6 with Skin

use of org.mineskin.data.Skin 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 7 with Skin

use of org.mineskin.data.Skin 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

Skin (org.mineskin.data.Skin)7 IOException (java.io.IOException)3 CommandPermission (co.aikar.commands.annotation.CommandPermission)2 Subcommand (co.aikar.commands.annotation.Subcommand)2 ProfileProperty (com.destroystokyo.paper.profile.ProfileProperty)2 VoxelGameLibException (com.voxelgameslib.voxelgameslib.exception.VoxelGameLibException)2 ItemBuilder (com.voxelgameslib.voxelgameslib.utils.ItemBuilder)2 ItemStack (org.bukkit.inventory.ItemStack)2 SkullMeta (org.bukkit.inventory.meta.SkullMeta)2 SkinCallback (org.mineskin.data.SkinCallback)2 Syntax (co.aikar.commands.annotation.Syntax)1 MarkerDefinition (com.voxelgameslib.voxelgameslib.map.MarkerDefinition)1 File (java.io.File)1 FileReader (java.io.FileReader)1 Nullable (javax.annotation.Nullable)1 EventHandler (org.bukkit.event.EventHandler)1 InventoryMenuBuilder (org.inventivetalent.menubuilder.inventory.InventoryMenuBuilder)1