use of org.bukkit.inventory.meta.SkullMeta in project EliteMobs by MagmaGuy.
the class CustomConfigFields method processItemStack.
public ItemStack processItemStack(String path, ItemStack value, ItemStack pluginDefault, boolean forceWriteDefault) {
if (!configHas(path)) {
if (forceWriteDefault || value != pluginDefault)
processString(path, itemStackDeserializer(value), itemStackDeserializer(pluginDefault), forceWriteDefault);
return value;
}
try {
String materialString = processString(path, itemStackDeserializer(value), itemStackDeserializer(pluginDefault), forceWriteDefault);
if (materialString == null)
return null;
if (materialString.matches("[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}")) {
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
SkullMeta skullMeta = (SkullMeta) playerHead.getItemMeta();
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(materialString)));
playerHead.setItemMeta(skullMeta);
return playerHead;
}
if (materialString.contains(":")) {
ItemStack itemStack = ItemStackGenerator.generateItemStack(Material.getMaterial(materialString.split(":")[0]));
if (materialString.split(":")[1].contains("leather_") || materialString.split(":")[1].contains("LEATHER_")) {
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) itemStack.getItemMeta();
leatherArmorMeta.setColor(Color.fromRGB(Integer.parseInt(materialString.split(":")[1])));
itemStack.setItemMeta(leatherArmorMeta);
} else {
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setCustomModelData(Integer.parseInt(materialString.split(":")[1]));
itemStack.setItemMeta(itemMeta);
}
return itemStack;
} else
return ItemStackGenerator.generateItemStack(Material.getMaterial(materialString));
} catch (Exception ex) {
new WarningMessage("File " + filename + " has an incorrect entry for " + path);
new WarningMessage("Entry: " + value);
}
return value;
}
use of org.bukkit.inventory.meta.SkullMeta in project Glowstone by GlowstoneMC.
the class BlockSkull method afterPlace.
@Override
public void afterPlace(GlowPlayer player, GlowBlock block, ItemStack holding, GlowBlockState oldState) {
GlowSkull skull = (GlowSkull) block.getState();
skull.setSkullType(getType(holding.getDurability()));
if (skull.getSkullType() == SkullType.PLAYER) {
SkullMeta meta = (SkullMeta) holding.getItemMeta();
if (meta != null) {
skull.setOwner(meta.getOwner());
}
}
MaterialData data = skull.getData();
if (!(data instanceof Skull)) {
warnMaterialData(Skull.class, data);
return;
}
Skull skullData = (Skull) data;
if (canRotate(skullData)) {
// Can be rotated
skull.setRotation(player.getFacing().getOppositeFace());
}
skull.update();
// Wither
for (int i = 0; i < 3; i++) {
if (WITHER_PATTERN.matches(block.getLocation().clone(), true, i, 0)) {
block.getWorld().spawnEntity(block.getLocation().clone().subtract(0, 2, 0), EntityType.WITHER);
break;
}
}
}
Aggregations