SHARE
TWEET

Untitled

a guest Feb 17th, 2019 339 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.massivecraft.factions.util;
  2.  
  3. import java.lang.reflect.Field;
  4. import java.util.UUID;
  5.  
  6. import org.apache.commons.codec.binary.Base64;
  7. import org.bukkit.Material;
  8. import org.bukkit.entity.EntityType;
  9. import org.bukkit.inventory.ItemStack;
  10. import org.bukkit.inventory.meta.SkullMeta;
  11.  
  12. import com.mojang.authlib.GameProfile;
  13. import com.mojang.authlib.properties.Property;
  14.  
  15. public class Heads {
  16.  
  17.     public static ItemStack VERDE;
  18.     public static ItemStack MAGENTA;
  19.     public static ItemStack BRANCO;
  20.     public static ItemStack AMARELO;
  21.     public static ItemStack ROXO;
  22.     public static ItemStack LARANJA;
  23.     public static ItemStack CINZA;
  24.    
  25.    
  26.     static {
  27.         VERDE = getSkull("http://textures.minecraft.net/texture/361e5b333c2a3868bb6a58b6674a2639323815738e77e053977419af3f77");
  28.         MAGENTA = new ItemBuilder(Material.SKULL_ITEM).durability(3).owner("diablo3pk").build();
  29.         BRANCO = new ItemBuilder(Material.SKULL_ITEM).durability(3).owner("cy1337").build();
  30.         LARANJA = new ItemBuilder(Material.SKULL_ITEM).durability(3).owner("wulfric17").build();
  31.         AMARELO = getSkull("http://textures.minecraft.net/texture/14c4141c1edf3f7e41236bd658c5bc7b5aa7abf7e2a852b647258818acd70d8");
  32.         ROXO = getSkull("http://textures.minecraft.net/texture/e9352bcabfc27edb44ceb51b04786542f26a299a0529475346186ee94738f");
  33.         CINZA = getSkull("http://textures.minecraft.net/texture/f2f085c6b3cb228e5ba81df562c4786762f3c257127e9725c77b7fd301d37");
  34.     }
  35.    
  36.     public static ItemStack getSkull(String url) {
  37.         ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
  38.         if (url == null || url.isEmpty())
  39.             return skull;
  40.         SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
  41.         GameProfile profile = new GameProfile(UUID.randomUUID(), null);
  42.         byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
  43.         profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
  44.         Field profileField = null;
  45.         try {
  46.             profileField = skullMeta.getClass().getDeclaredField("profile");
  47.         } catch (NoSuchFieldException | SecurityException e) {
  48.             e.printStackTrace();
  49.         }
  50.         profileField.setAccessible(true);
  51.         try {
  52.             profileField.set(skullMeta, profile);
  53.         } catch (IllegalArgumentException | IllegalAccessException e) {
  54.             e.printStackTrace();
  55.         }
  56.         skull.setItemMeta(skullMeta);
  57.         return skull;
  58.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top