static SkullType getSkullType(int id) { switch (id) { case 0: return SkullType.SKELETON; case 1: return SkullType.WITHER; case 2: return SkullType.ZOMBIE; case 3: return SkullType.PLAYER; case 4: return SkullType.CREEPER; default: throw new AssertionError(id); } }
static int getSkullType(SkullType type) { switch(type) { case SKELETON: return 0; case WITHER: return 1; case ZOMBIE: return 2; case PLAYER: return 3; case CREEPER: return 4; default: throw new AssertionError(type); } }
public boolean setOwner(String name) { if (name == null || name.length() > MAX_OWNER_LENGTH) { return false; } GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a (name); if (profile == null) { return false; } if (skullType != SkullType.PLAYER) { skullType = SkullType.PLAYER; } this.profile = profile; return true; }
@Override public boolean update(boolean force, boolean applyPhysics) { boolean result = super.update(force, applyPhysics); if (result) { if (skullType == SkullType.PLAYER) { skull.func_152106_a(profile); } else { skull.func_152107_a(getSkullType(skullType)); } skull.func_145903_a(rotation); skull.markDirty(); } return result; }
private ItemStack createPlayerHead(Player player) { AbstractPlayerData playerData = SamaGamesAPI.get().getPlayerManager().getPlayerData(player.getUniqueId()); ItemStack stack = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal()); SkullMeta meta = (SkullMeta) stack.getItemMeta(); meta.setOwner(player.getName()); meta.setDisplayName(PlayerUtils.getFullyFormattedPlayerName(player)); List<String> lore = new ArrayList<>(); lore.add(ChatColor.GRAY + "Pièces : " + ChatColor.GOLD + NumberUtils.format(playerData.getCoins())); lore.add(ChatColor.GRAY + "Perles : " + ChatColor.GREEN + NumberUtils.format(this.hub.getInteractionManager().getGraouManager().getPlayerPearls(player.getUniqueId()).size())); lore.add(ChatColor.GRAY + "Poussière d'" + ChatColor.AQUA + "\u272F" + ChatColor.GRAY + " : " + ChatColor.AQUA + NumberUtils.format(playerData.getPowders())); meta.setLore(lore); stack.setItemMeta(meta); return stack; }
public static ItemStack createSkullItemStack(String uuid, String textureValue, String textureSignature) { WrappedGameProfile wrappedProfile = new WrappedGameProfile(UUID.fromString(uuid), null); wrappedProfile.getProperties().put("textures", new WrappedSignedProperty("textures", textureValue, textureSignature)); ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal()); SkullMeta sm = (SkullMeta) skull.getItemMeta(); Field profileField = null; try { profileField = sm.getClass().getDeclaredField("profile"); profileField.setAccessible(true); profileField.set(sm, wrappedProfile.getHandle()); } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) { e1.printStackTrace(); } skull.setItemMeta(sm); return skull; }
@Override public void run() { if (loc == null) { return; } Block b = loc.getBlock(); if (b.getType() != Material.SKULL) { return; } Skull skull = (Skull) b.getState(); if (type == SkullType.PLAYER) { skull.setSkullType(type); skull.setOwner(owner); } else { skull.setSkullType(type); } skull.update(); }
public static List<Inventory> createMemberMenu(Clans clan){ Clan clanProfile = new Clan(clan); List<Inventory> pages = new ArrayList<Inventory>(); int page = 1; pages.add(Bukkit.createInventory(null, 54, "Page "+page)); List<ca.damocles.accountsystem.Character> clansmen = clanProfile.getClansmen(); for(ca.damocles.accountsystem.Character members : clansmen){ ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal()); SkullMeta meta = (SkullMeta) skull.getItemMeta(); meta.setOwningPlayer(Bukkit.getOfflinePlayer(members.uuid)); skull.setItemMeta(meta); if(pages.get(pages.size()-1).firstEmpty() == -1){ page = page+1; pages.add(Bukkit.createInventory(null, 54, "Page "+page)); pages.get(pages.size()-1).addItem(skull); }else{ pages.get(pages.size()-1).addItem(skull); } members.getPlayer().updateInventory(); } return pages; }
public boolean setOwner(String name) { if (name == null || name.length() > MAX_OWNER_LENGTH) { return false; } GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(name); if (profile == null) { return false; } if (skullType != SkullType.PLAYER) { skullType = SkullType.PLAYER; } this.profile = profile; return true; }
@Override public boolean update(boolean force, boolean applyPhysics) { boolean result = super.update(force, applyPhysics); if (result) { if (skullType == SkullType.PLAYER) { skull.setGameProfile(profile); } else { skull.setSkullType(getSkullType(skullType)); } skull.setRotation(rotation); skull.update(); } return result; }