Search in sources :

Example 1 with WrappedGameProfile

use of com.comphenix.protocol.wrappers.WrappedGameProfile in project ChangeSkin by games647.

the class BukkitSkinAPI method applySkin.

@Override
public void applySkin(Player receiver, SkinModel targetSkin) {
    WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(receiver);
    applyProperties(gameProfile, targetSkin);
}
Also used : WrappedGameProfile(com.comphenix.protocol.wrappers.WrappedGameProfile)

Example 2 with WrappedGameProfile

use of com.comphenix.protocol.wrappers.WrappedGameProfile in project ChangeSkin by games647.

the class SkullCommand method setSkullSkin.

private void setSkullSkin(ItemStack itemStack, SkinModel skinData) {
    if (itemStack == null || skinData == null || itemStack.getType() != Material.SKULL_ITEM)
        return;
    try {
        SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
        WrappedGameProfile gameProfile = new WrappedGameProfile(UUID.randomUUID(), null);
        plugin.getApi().applyProperties(gameProfile, skinData);
        skullProfileSetter.invoke(skullMeta, gameProfile.getHandle());
        itemStack.setItemMeta(skullMeta);
    } catch (Exception ex) {
        plugin.getLog().info("Failed to set skull item {} to {}", itemStack, skinData, ex);
    } catch (Throwable throwable) {
        // rethrow errors we shouldn't silence them like OutOfMemory
        throw (Error) throwable;
    }
}
Also used : SkullMeta(org.bukkit.inventory.meta.SkullMeta) WrappedGameProfile(com.comphenix.protocol.wrappers.WrappedGameProfile)

Aggregations

WrappedGameProfile (com.comphenix.protocol.wrappers.WrappedGameProfile)2 SkullMeta (org.bukkit.inventory.meta.SkullMeta)1