本文整理汇总了Java中org.bukkit.inventory.ItemStack.getItemMeta方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.getItemMeta方法的具体用法?Java ItemStack.getItemMeta怎么用?Java ItemStack.getItemMeta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.ItemStack
的用法示例。
在下文中一共展示了ItemStack.getItemMeta方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHeadPlayer
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public static ItemStack createHeadPlayer(String displayname, String username, List<String> lore) {
ItemStack playerHead = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta sm = (SkullMeta)playerHead.getItemMeta();
sm.setOwner(username);
ArrayList<String> colorLore = new ArrayList<>();
if (lore != null) {
lore.forEach(str -> colorLore.add(Utils.colorize(str)));
sm.setLore(colorLore);
}
sm.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ATTRIBUTES,
ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_UNBREAKABLE);
sm.setDisplayName(Utils.colorize(displayname));
playerHead.setItemMeta(sm);
return playerHead;
}
示例2: choosePartner
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
private Inventory choosePartner(Faction creator) {
int size = (int) (9 * Math.ceil(((double) factions.getActive().size() / 9)));
Inventory gui = Bukkit.createInventory(null, size, FMessage.TRADE_OFFER_CHOOSE_PARTNER.getMessage());
int i = 0;
for (Faction faction : factions.getActive()) {
ItemStack icon = faction.getBannerStack();
ItemMeta meta = icon.getItemMeta();
meta.setDisplayName(creator.getRelation(faction).getColor() + faction.getName());
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
icon.setItemMeta(meta);
gui.setItem(i, icon);
factionBySlot.put(i, faction);
i++;
}
return gui;
}
示例3: getEnchantments
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public static Map<CustomEnchantment, Integer> getEnchantments(ItemStack item) {
HashMap<CustomEnchantment, Integer> list = new HashMap<>();
if (item == null) return list;
ItemMeta meta = item.getItemMeta();
if (meta == null) return list;
if (!meta.hasLore()) return list;
for (String lore : meta.getLore()) {
String name = EnchantUtils.parseName(lore);
int level = EnchantUtils.parseLevel(lore);
if (name == null) continue;
if (level == 0) continue;
if (Main.isEnchantmentRegistered(name)) {
CustomEnchantment enchant = Main.getEnchantment(name);
if (enchant.isStackable() && list.containsKey(enchant)) {
level += list.get(enchant);
}
list.put(enchant, level);
}
}
return list;
}
示例4: getSeaWater
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
/**
* l.add("��2��ˮ,����...");
l.add("��4�������ܽ��,��l���м�������!");
l.add("��b��Ҫ�þ�ˮװ�����������������!");
* @return ��ˮ
*/
public static ItemStack getSeaWater(){
ItemStack sw=new ItemStack(Material.POTION);
PotionMeta im = (PotionMeta) sw.getItemMeta();
im.setColor(Color.fromRGB(15, 103, 219));
im.setDisplayName("��1��l��ˮ");
List<String> l=new LinkedList<String>();
l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l-"+Utils.random(2, 20)+"%");
l.add("��2��l"+rs.getLoreTabel("SickKind")+": ��c��l"+rs.defSick.split(";")[(int)Utils.random(0, rs.defSick.split(";").length)]);
l.add("��2��l"+rs.getLoreTabel("Sickness")+": ��c��l"+Utils.random(20, 30)+"%");
l.add("");
l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
l.add("");
l.add("��2��ˮ,����...");
l.add("��4�������ܽ��,��l���м�������!");
l.add("��b��Ҫ�þ�ˮװ�����������������!");
im.setLore(l);
sw.setItemMeta(im);
return sw;
}
示例5: isGun
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Override
public boolean isGun(ItemStack toCheck) {
if (!enabled || toCheck == null)
return false;
if (!Material.DIAMOND_HOE.equals(toCheck.getType()))
return false;
if (!toCheck.hasItemMeta())
return false;
ItemMeta meta = toCheck.getItemMeta();
if (meta.getLore().contains(gunTag()))
return true;
return false;
}
示例6: getNameFromItemStack
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public static String getNameFromItemStack(ItemStack itemStack) {
if (itemStack.getItemMeta() instanceof SkullMeta) {
final SkullMeta meta = (SkullMeta) itemStack.getItemMeta();
return meta.getOwner();
}
return null;
}
示例7: getTeamSelector
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public static ItemStack getTeamSelector()
{
ItemStack stack = new ItemStack(Material.WOOL, 1);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.GOLD + "Select Team " + ChatColor.GRAY + "(Right click)");
meta.setLore(null);
stack.setItemMeta(meta);
return stack;
}
示例8: unplaceable
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void unplaceable(BlockPlaceEvent evt) {
ItemStack stack = evt.getItemInHand();
if (stack == null) return;
ItemMeta meta = stack.getItemMeta();
if (!meta.hasLore()) return;
for (String lore : meta.getLore()) {
Item item = ItemFactory.items.get(lore);
if (item instanceof UnplaceableItem) {
evt.setCancelled(true);
}
}
}
示例9: getFormattedIcon
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack getFormattedIcon(Player player)
{
ItemStack stack = getIcon().clone();
ItemMeta meta = stack.getItemMeta();
List<String> lore = meta.getLore() != null ? meta.getLore() : new ArrayList<>();
if (CosmeticAccessibility.valueOf(this.itemDescription.getRankAccessibility()) != CosmeticAccessibility.ALL)
{
lore.add("");
lore.add(ChatColor.GRAY + "Vous devez posséder le grade");
lore.add(CosmeticAccessibility.valueOf(this.itemDescription.getRankAccessibility()).getDisplay() + ChatColor.GRAY + " pour pouvoir utiliser cet");
lore.add(ChatColor.GRAY + "objet.");
}
lore.add("");
if (this.isActive(player))
lore.add(ChatColor.GREEN + "Objet actif");
else if (this.isOwned(player) || this.isDefaultItem())
lore.add(ChatColor.GREEN + "Objet possédé");
else if (( this.dependsOn != null && this.hasDepend(player)) || this.dependsOn == null)
lore.add(ChatColor.GRAY + "Prix : " + ChatColor.GOLD + this.itemDescription.getPriceCoins() + " pièces");
else
lore.add(ChatColor.RED + "Nécessite " + ChatColor.AQUA + this.dependsOn.getIcon().getItemMeta().getDisplayName());
meta.setLore(lore);
stack.setItemMeta(meta);
return stack;
}
示例10: SimpleWand
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public SimpleWand() {
baseItem = new ItemStack(Material.STICK, 1);
ItemMeta meta = baseItem.getItemMeta();
meta.setDisplayName(displayName + "none");
meta.setLore(Arrays.asList(new String[]{"Right click to cast", "'/bind <spell>' to bind"}));
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addEnchant(Enchantment.MENDING, 1, true);
baseItem.setItemMeta(meta);
}
示例11: chooseExport
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
private Inventory chooseExport() {
Inventory gui = Bukkit.createInventory(null, 9, FMessage.TRADE_OFFER_CHOOSE_EXPORT.getMessage());
ItemStack exportIcon = GUIButton.E.clone();
ItemMeta exMeta = exportIcon.getItemMeta();
exMeta.setDisplayName(ChatColor.GREEN + FMessage.TRADE_EXPORT.getMessage());
exportIcon.setItemMeta(exMeta);
ItemStack importIcon = GUIButton.I.clone();
ItemMeta imMeta = importIcon.getItemMeta();
imMeta.setDisplayName(ChatColor.GREEN + FMessage.TRADE_IMPORT.getMessage());
importIcon.setItemMeta(imMeta);
gui.setItem(3, exportIcon);
gui.setItem(5, importIcon);
return gui;
}
示例12: getRepresentation
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public default ItemStack getRepresentation() {
ItemStack stack = new ItemStack(Material.MAP);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.GRAY + "Map Extend");
stack.setItemMeta(meta);
return stack;
}
示例13: getItem
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack getItem() {
ItemStack item = new ItemStack(Material.END_CRYSTAL);
List<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + getName());
lore.add(ChatColor.GRAY + getDescription());
lore.add(ChatColor.GRAY + "Rarity: " + getRarity().getName());
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(getRarity().getColor() + "Enchanted Crystal");
itemMeta.setLore(lore);
item.setItemMeta(itemMeta);
return item;
}
示例14: createItemKey
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public static ItemStack createItemKey(Material type,short damage,String key){
ItemStack is=new ItemStack(type,1,damage);
ItemMeta im=is.getItemMeta();
//set Key
im.setDisplayName(key);
is.setItemMeta(im);
return is;
}
示例15: newInventory
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public static void newInventory(CommandSender sender) {
Inventory tpheremenu = Bukkit.createInventory(null, 54, ChatColor.DARK_GRAY + "Teleport Here Menu - Page 1");
ItemStack empty = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) 15);
ItemMeta emptyMeta = empty.getItemMeta();
emptyMeta.setDisplayName(" ");
empty.setItemMeta(emptyMeta);
ItemStack close = new ItemStack(Material.BARRIER);
ItemStack nextpage = new ItemStack(Material.SIGN);
ItemStack previouspage = new ItemStack(Material.SIGN);
ItemMeta npMeta = nextpage.getItemMeta();
ItemMeta ppMeta = previouspage.getItemMeta();
ItemMeta closeMeta = close.getItemMeta();
closeMeta.setDisplayName(ChatColor.RED + "Close the menu.");
npMeta.setDisplayName(ChatColor.AQUA + "" + ChatColor.BOLD + "Next Page");
ppMeta.setDisplayName(ChatColor.AQUA + "" + ChatColor.BOLD + "Previous Page");
for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {
Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
ItemStack skulls = new ItemStack(Material.SKULL_ITEM, 1,(byte) 3);
SkullMeta skullsMeta = (SkullMeta) skulls.getItemMeta();
skullsMeta.setDisplayName(ChatColor.YELLOW + "Teleport " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.YELLOW + " to you.");
skullsMeta.setOwner(targetPlayer.getName());
skulls.setItemMeta(skullsMeta);
int beginningSlot = 9;
tpheremenu.setItem(i+beginningSlot, skulls);
}
tpheremenu.setItem(0, empty);
tpheremenu.setItem(1, empty);
tpheremenu.setItem(2, empty);
tpheremenu.setItem(3, empty);
tpheremenu.setItem(4, empty);
tpheremenu.setItem(5, empty);
tpheremenu.setItem(6, empty);
tpheremenu.setItem(7, empty);
tpheremenu.setItem(8, empty);
tpheremenu.setItem(45, empty);
tpheremenu.setItem(46, empty);
tpheremenu.setItem(47, empty);
tpheremenu.setItem(48, empty);
tpheremenu.setItem(49, close);
tpheremenu.setItem(50, empty);
tpheremenu.setItem(51, empty);
tpheremenu.setItem(52, empty);
tpheremenu.setItem(53, nextpage);
((HumanEntity) sender).openInventory(tpheremenu);
}