use of org.bukkit.inventory.meta.SkullMeta in project Essentials by drtshock.
the class Commandskull method run.
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
String owner;
if (args.length > 0 && user.isAuthorized("essentials.skull.others")) {
if (!args[0].matches("^[A-Za-z0-9_]+$")) {
throw new IllegalArgumentException(tl("alphaNames"));
}
owner = args[0];
} else {
owner = user.getName();
}
ItemStack itemSkull = user.getBase().getItemInHand();
SkullMeta metaSkull = null;
boolean spawn = false;
if (itemSkull != null && itemSkull.getType() == Material.SKULL_ITEM && itemSkull.getDurability() == 3) {
metaSkull = (SkullMeta) itemSkull.getItemMeta();
} else if (user.isAuthorized("essentials.skull.spawn")) {
itemSkull = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
metaSkull = (SkullMeta) itemSkull.getItemMeta();
spawn = true;
} else {
throw new Exception(tl("invalidSkull"));
}
if (metaSkull.hasOwner() && !user.isAuthorized("essentials.skull.modify")) {
throw new Exception(tl("noPermissionSkull"));
}
metaSkull.setDisplayName("§fSkull of " + owner);
metaSkull.setOwner(owner);
itemSkull.setItemMeta(metaSkull);
if (spawn) {
InventoryWorkaround.addItems(user.getBase().getInventory(), itemSkull);
user.sendMessage(tl("givenSkull", owner));
} else {
user.sendMessage(tl("skullChanged", owner));
}
}
use of org.bukkit.inventory.meta.SkullMeta in project PixelsSkyblock by dudullle.
the class Inventories method run_PlayersInventory_invite.
public static void run_PlayersInventory_invite(InventoryClickEvent event) {
try {
Player pl = (Player) event.getWhoClicked();
SkullMeta skull = (SkullMeta) event.getInventory().getItem(event.getSlot()).getItemMeta();
Player cible = Bukkit.getPlayer(skull.getOwner());
SPlayer p_sender = PlayersManager.getSPlayer(pl);
SPlayer p_cible = PlayersManager.getSPlayer(cible);
p_cible.setLastIsInvite(p_sender.getIsland().getID());
cible.sendTitle("§a" + pl.getDisplayName() + " vous veut sur son île!", "§eFaites /is accept pour accepter !", 10, 20, 10);
} catch (Exception ex) {
}
}
use of org.bukkit.inventory.meta.SkullMeta in project PixelsSkyblock by dudullle.
the class Items method getHead.
public static ItemStack getHead(Player player) {
ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta skull = (SkullMeta) item.getItemMeta();
skull.setDisplayName(player.getName());
skull.setOwner(player.getName());
item.setItemMeta(skull);
return item;
}
use of org.bukkit.inventory.meta.SkullMeta in project PixelsSkyblock by dudullle.
the class Items method getHead.
public static ItemStack getHead(String pName, String itemName) {
ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta skull = (SkullMeta) item.getItemMeta();
skull.setDisplayName(itemName);
skull.setOwner(pName);
item.setItemMeta(skull);
return item;
}
use of org.bukkit.inventory.meta.SkullMeta in project SkinsRestorerX by DoNotSpamPls.
the class SkinsGUI method createSkull.
private static ItemStack createSkull(Object s, String name) {
ItemStack is = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta sm = (SkullMeta) is.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add(Locale.SELECT_SKIN);
sm.setDisplayName(name);
sm.setLore(lore);
is.setItemMeta(sm);
is = setSkin(is, ((Property) s).getValue());
return is;
}
Aggregations