use of org.bukkit.inventory.meta.ItemMeta in project Village_Defense by Plajer.
the class SpecialItem method getItemStack.
public ItemStack getItemStack() {
ItemStack itemStack;
if (data != null) {
itemStack = new ItemStack(getMaterial(), 1, getData());
} else {
itemStack = new ItemStack(getMaterial());
}
ItemMeta im = itemStack.getItemMeta();
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', this.getDisplayName()));
im.setLore(Arrays.asList(lore));
itemStack.setItemMeta(im);
return itemStack;
}
use of org.bukkit.inventory.meta.ItemMeta in project Village_Defense by Plajer.
the class AdminCommands method setItemPrice.
public void setItemPrice(CommandSender sender, String price) {
if (checkSenderIsConsole(sender))
return;
if (!hasPermission(sender, "villagedefense.admin.setprice"))
return;
Player player = (Player) sender;
ItemStack item = player.getItemInHand();
if (item == null || item.getType().equals(Material.AIR)) {
player.sendMessage(ChatColor.RED + "You must hold any item!");
return;
}
// check any price from lore
if (item.hasItemMeta() && item.getItemMeta().hasLore()) {
ItemMeta meta = item.getItemMeta();
List<String> lore = item.getItemMeta().getLore();
for (String search : lore) {
if (search.contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop"))) {
lore.remove(search);
break;
}
}
lore.add(0, ChatColor.GOLD + price + " " + ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop"));
meta.setLore(lore);
item.setItemMeta(meta);
player.sendMessage(ChatColor.GREEN + "Command succesfully executed, item updated!");
} else {
Util.addLore(item, ChatColor.GOLD + price + " " + ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop"));
player.sendMessage(ChatColor.GREEN + "Command succesfully executed!");
}
}
use of org.bukkit.inventory.meta.ItemMeta in project Village_Defense by Plajer.
the class Kit method setItemNameAndLore.
protected ItemStack setItemNameAndLore(ItemStack item, String name, String[] lore) {
ItemMeta im = item.getItemMeta();
im.setDisplayName(name);
im.setLore(Arrays.asList(lore));
item.setItemMeta(im);
return item;
}
use of org.bukkit.inventory.meta.ItemMeta in project Village_Defense by Plajer.
the class Util method addLore.
public static void addLore(ItemStack itemStack, String string) {
ItemMeta meta = itemStack.getItemMeta();
List<String> lore = new ArrayList<>();
if (meta != null && meta.hasLore())
lore.addAll(meta.getLore());
lore.add(string);
meta.setLore(lore);
itemStack.setItemMeta(meta);
}
use of org.bukkit.inventory.meta.ItemMeta in project TriggerReactor by wysohn.
the class InventoryTriggerManager method getColoredItem.
/**
* @param item
* @return copy of colored item
*/
private ItemStack getColoredItem(ItemStack item) {
item = item.clone();
ItemMeta IM = item.getItemMeta();
if (IM != null) {
if (IM.hasDisplayName()) {
IM.setDisplayName(ChatColor.translateAlternateColorCodes('&', IM.getDisplayName()));
}
if (IM.hasLore()) {
List<String> lore = new ArrayList<>(IM.getLore());
for (int i = 0; i < IM.getLore().size(); i++) {
lore.set(i, ChatColor.translateAlternateColorCodes('&', IM.getLore().get(i)));
}
IM.setLore(lore);
}
item.setItemMeta(IM);
}
return item;
}
Aggregations