use of org.bukkit.inventory.meta.SkullMeta in project MagicPlugin by elBukkit.
the class ShrinkEntityAction method dropHead.
@SuppressWarnings("deprecation")
protected void dropHead(Location location, String ownerName, String itemName, byte data) {
ItemStack shrunkenHead = new ItemStack(Material.SKULL_ITEM, 1, (short) 0, data);
ItemMeta meta = shrunkenHead.getItemMeta();
if (itemName != null) {
meta.setDisplayName(itemName);
}
if (meta instanceof SkullMeta && ownerName != null) {
SkullMeta skullData = (SkullMeta) meta;
skullData.setOwner(ownerName);
}
shrunkenHead.setItemMeta(meta);
location.getWorld().dropItemNaturally(location, shrunkenHead);
}
use of org.bukkit.inventory.meta.SkullMeta in project FireAPI by FireBlade-Serv.
the class EventsAT method generateSkull.
public static ItemStack generateSkull(String owner) {
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
skullMeta.setOwner(owner);
skullMeta.setDisplayName("§d" + owner);
skull.setItemMeta(skullMeta);
return skull;
}
use of org.bukkit.inventory.meta.SkullMeta in project FireAPI by FireBlade-Serv.
the class FriendsActionInventoryGUI method formHead.
public ItemStack formHead(String owner) {
ItemStack i = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
SkullMeta m = (SkullMeta) i.getItemMeta();
m.setDisplayName((this.connected.contains(owner)) ? "§2" + owner : "§8" + owner);
m.setLore((this.connected.contains(owner) ? Arrays.asList("§a§oConnecté") : Arrays.asList("§c§oDéconnecté")));
m.setOwner(owner);
i.setItemMeta(m);
return i;
}
use of org.bukkit.inventory.meta.SkullMeta in project Citizens2 by CitizensDev.
the class EventListen method onMetaDeserialise.
@EventHandler
public void onMetaDeserialise(CitizensDeserialiseMetaEvent event) {
if (event.getKey().keyExists("skull")) {
String owner = event.getKey().getString("skull.owner", "");
UUID uuid = event.getKey().keyExists("skull.uuid") ? UUID.fromString(event.getKey().getString("skull.uuid")) : null;
if (owner.isEmpty() && uuid == null) {
return;
}
GameProfile profile = new GameProfile(uuid, owner);
for (DataKey sub : event.getKey().getRelative("skull.properties").getSubKeys()) {
String propertyName = sub.name();
for (DataKey property : sub.getIntegerSubKeys()) {
profile.getProperties().put(propertyName, new Property(property.getString("name"), property.getString("value"), property.keyExists("signature") ? property.getString("signature") : null));
}
}
SkullMeta meta = (SkullMeta) Bukkit.getItemFactory().getItemMeta(Material.SKULL_ITEM);
NMS.setProfile(meta, profile);
event.getItemStack().setItemMeta(meta);
}
}
use of org.bukkit.inventory.meta.SkullMeta in project Citizens2 by CitizensDev.
the class EventListen method onMetaSerialise.
@EventHandler
public void onMetaSerialise(CitizensSerialiseMetaEvent event) {
if (!(event.getMeta() instanceof SkullMeta))
return;
SkullMeta meta = (SkullMeta) event.getMeta();
GameProfile profile = NMS.getProfile(meta);
if (profile == null)
return;
if (profile.getName() != null) {
event.getKey().setString("skull.owner", profile.getName());
}
if (profile.getId() != null) {
event.getKey().setString("skull.uuid", profile.getId().toString());
}
if (profile.getProperties() != null) {
for (Entry<String, Collection<Property>> entry : profile.getProperties().asMap().entrySet()) {
DataKey relative = event.getKey().getRelative("skull.properties." + entry.getKey());
int i = 0;
for (Property value : entry.getValue()) {
relative.getRelative(i).setString("name", value.getName());
if (value.getSignature() != null) {
relative.getRelative(i).setString("signature", value.getSignature());
}
relative.getRelative(i).setString("value", value.getValue());
i++;
}
}
}
}
Aggregations