当前位置: 首页>>代码示例>>Java>>正文


Java ItemStack.setItemMeta方法代码示例

本文整理汇总了Java中org.bukkit.inventory.ItemStack.setItemMeta方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.setItemMeta方法的具体用法?Java ItemStack.setItemMeta怎么用?Java ItemStack.setItemMeta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.inventory.ItemStack的用法示例。


在下文中一共展示了ItemStack.setItemMeta方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openFakeInv

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
/**
 * Copy an inventory and open it for player
 *
 * @param i Inventory to open
 * @param p Player that needs the inventory
 */
public static void openFakeInv(Inventory i, OMGPlayer p) {
    Inventory fake = Bukkit.createInventory(p.bukkit, i.getSize(), i.getTitle());
    for (int slot = 0; slot < i.getContents().length; slot++) {
        ItemStack e = i.getContents()[slot];
        if (e != null) {
            e = e.clone();
            ItemMeta im = e.getItemMeta();
            im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
            im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
            if ((NBTParser.getTagCompound(e).hasKey("kitid") && NBTParser.getTagCompound(e).getString("kitid").equals(p.kit.name)) || (NBTParser.getTagCompound(e).hasKey("teamid") && NBTParser.getTagCompound(e).getString("teamid").equals(p.requestedTeam.id)))
                im.addEnchant(Enchantment.DURABILITY, 1, true);
            if (NBTParser.getTagCompound(e).hasKey("kitid")) {
                ItemStack finalE = e;
                OMGKit.kits.stream().filter(k -> k.getName().equals(NBTParser.getTagCompound(finalE).getString("kitid"))).forEach(k -> {
                    List<String> ss = im.hasLore() ? im.getLore() : new ArrayList<>();
                    ss.add(ChatColor.GREEN + "Can use: " + (OMGPI.g.player_hasKit(p, k) ? (ChatColor.GREEN + "YES") : (ChatColor.RED + "NO")));
                    im.setLore(ss);
                });
            }
            e.setItemMeta(im);
            fake.setItem(slot, e);
        }
    }
    p.bukkit.openInventory(fake);
}
 
开发者ID:BurnyDaKath,项目名称:OMGPI,代码行数:32,代码来源:Inventories.java

示例2: 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;
}
 
开发者ID:cadox8,项目名称:WC,代码行数:17,代码来源:ItemUtil.java

示例3: createBook

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public static ItemStack createBook(String name, List<String> lore, String... pages) {
    ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
    BookMeta meta = (BookMeta) book.getItemMeta();
    ItemMeta bookMeta = book.getItemMeta();

    bookMeta.setDisplayName(Utils.colorize(name));
    ArrayList<String> colorLore = new ArrayList<>();
    if (lore != null) lore.forEach(str -> colorLore.add(Utils.colorize(str)));
    bookMeta.setLore(colorLore);

    meta.addPage(pages);
    meta.setAuthor(Utils.colorize("&6ProjectAlpha"));

    book.setItemMeta(bookMeta);

    return book;
}
 
开发者ID:cadox8,项目名称:PA,代码行数:18,代码来源:ItemUtil.java

示例4: modifyItemStack

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack modifyItemStack(ItemStack stack, String arguments) {
    net.minecraft.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(stack);

    try
    {
        nmsStack.setTagCompound((net.minecraft.nbt.NBTTagCompound) net.minecraft.nbt.JsonToNBT.func_150315_a(arguments));
    }
    catch (net.minecraft.nbt.NBTException e)
    {
        e.printStackTrace();
    }

    stack.setItemMeta(CraftItemStack.getItemMeta(nmsStack));

    return stack;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:18,代码来源:CraftMagicNumbers.java

示例5: 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;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:26,代码来源:Items.java

示例6: LongRangeWeapon

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public LongRangeWeapon(Material wep, String name, Material ammo, String desc, String type, double damage, int cooltime, boolean isCrit, int knockback) {
	this.wep = wep;
	this.name = name;
	this.ammo = ammo;
	this.desc = desc;
	this.type = type;
	this.damage = damage;
	this.cooltime = cooltime;
	this.isCrit = isCrit;
	this.knockback = knockback;
	
	ItemStack item = new ItemStack(wep);
	
	ItemMeta meta = item.getItemMeta();
	meta.setDisplayName(ChatColor.BOLD + name);
	ArrayList<String> lore = new ArrayList<String>();
	lore.add(ChatColor.BOLD + desc);
	lore.add(ChatColor.WHITE + type);
	meta.setLore(lore);
	item.setItemMeta(meta);
	
	addWep(item);
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:24,代码来源:LongRangeWeapon.java

示例7: getIceWater

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
/**
 * l.add("��2����ֱ������");
	l.add("��b��l���Ը����彵��!");
 * @return ��ˮ
 */
public static ItemStack getIceWater(){
	ItemStack sw=new ItemStack(Material.POTION);
	PotionMeta im = (PotionMeta) sw.getItemMeta();
	im.setColor(Color.fromRGB(36, 165, 229));
	im.setDisplayName("��3��l��ˮ");
	List<String> l=new LinkedList<String>();
	l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l"+Utils.random(10, 25)+"%");
	l.add("��3��l"+rs.getLoreTabel("Tem")+": ��c��l-"+Utils.random(0.1, 1.5)+"%");
	l.add("");
	l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
	l.add("");
	l.add("��2����ֱ������");
	l.add("��b��l���Ը����彵��!");
	im.setLore(l);
	sw.setItemMeta(im);
	return sw;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:23,代码来源:Items.java

示例8: setupGUI

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
private void setupGUI() {
    gui = Bukkit.createInventory(null, 27, FMessage.TRADE_RESOURCE_TITLE.getMessage(resource.getName(), faction.getName()));
    ItemStack banner = faction.getBannerStack();
    ItemMeta meta = banner.getItemMeta();
    meta.setDisplayName(ChatColor.GOLD + faction.getName());
    meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
    banner.setItemMeta(meta);
    gui.setItem(0, BACK);
    gui.setItem(1, banner);
    gui.setItem(2, banner);
    gui.setItem(3, banner);
    gui.setItem(5, banner);
    gui.setItem(6, banner);
    gui.setItem(7, banner);
    gui.setItem(8, banner);
    gui.setItem(13, importButton);
    gui.setItem(22, exportButton);
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:19,代码来源:ResourceMenu.java

示例9: change

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode mode) {
	ItemStack i = item.getSingle(e);
	if (i == null) {
		return;
	}
	if (i.getType() == Material.BANNER || i.getType() == Material.SHIELD) {
		BannerMeta meta = ((BannerMeta) i.getItemMeta());
		switch (mode) {
			case ADD:
				Arrays.asList(((Pattern[]) delta)).forEach(meta::addPattern);
				break;
			case SET:
				meta.setPatterns(Arrays.asList(((Pattern[]) delta)));
				break;
			case DELETE:
			case RESET:
				for (int j = 1; j <= meta.numberOfPatterns(); j++) {
					meta.removePattern(j);
				}
				break;
		}
		i.setItemMeta(meta);
	}

}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:27,代码来源:SExprItemLayers.java

示例10: getRainwater

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
/**
	l.add("��2��ˮ�����˵���DZȽϸɾ���");
	l.add("��b���ǻ����н�С���ʵò�");
 * @return ��ˮ
 */
public static ItemStack getRainwater(){
	ItemStack sw=new ItemStack(Material.POTION);
	PotionMeta im = (PotionMeta) sw.getItemMeta();
	im.setColor(Color.fromRGB(36, 165, 229));
	im.setDisplayName("��b��l��ˮ");
	List<String> l=new LinkedList<String>();
	l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l"+Utils.random(5, 25)+"%");
	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(2, 10)+"%");
	l.add("");
	l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
	l.add("");
	l.add("��2��ˮ�����˵���DZȽϸɾ���");
	l.add("��b���ǻ����н�С���ʵò�");
	im.setLore(l);
	sw.setItemMeta(im);
	return sw;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:24,代码来源:Items.java

示例11: addToLore

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
private static ItemStack addToLore(ItemStack i, String... toAdd){
    List<String> lore = new ArrayList<>();
    if (!lore.isEmpty()) lore.clear();
    lore.addAll(i.getItemMeta().getLore());

    for(String s : toAdd){
        lore.add(s);
    }

    ItemMeta im = i.getItemMeta();
    im.setLore(lore);
    i.setItemMeta(im);

    return i;
}
 
开发者ID:cadox8,项目名称:WC,代码行数:16,代码来源:FichasMenu.java

示例12: potionItem

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Test
public void potionItem() throws Exception {
    final ItemStack item = new ItemStack(Material.POTION);
    final PotionMeta meta = (PotionMeta) item.getItemMeta();
    meta.setPotionBrew(Bukkit.potionRegistry().get(Bukkit.key("healing")));
    item.setItemMeta(meta);

}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:PotionClassificationTest.java

示例13: getSpawnEgg

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    ItemStack egg = new ItemStack(Material.MONSTER_EGG, amount);
    SpawnEggMeta spm = (SpawnEggMeta)egg.getItemMeta();
    spm.setSpawnedType(type);
    egg.setItemMeta(spm);
    return egg;
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:9,代码来源:NMSHandler.java

示例14: openGUI

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public void openGUI(Player player, int page) {
    Inventory inventory = Bukkit.createInventory(this, 54, I18n.format("user.select.gui.title"));
    int pageCount;
    pageCount = (spawnPoints.size() + 45 - 1) / 45;
    int offset = 0;
    if (page < 1 || page > pageCount) {
        page = 1;
    }
    if (page > 1) {
        offset = (page - 1) * (45);
    }
    setCurrentPage(page);
    for (int i = 0; i < 45; i++) {
        if (spawnPoints.size() > (offset + i)) {
            String spawnName = spawnPoints.getOrDefault(offset + i, null);
            if (spawnName != null) {
                ItemStack itemStack = new ItemStack(plugin.config.gui_item);
                addLore(plugin.config.spawnConfig.spawns.get(spawnName), itemStack);
                inventory.setItem(i, itemStack);
                continue;
            }
        }
        break;
    }
    if (page > 1) {
        ItemStack back = new ItemStack(Material.ARROW);
        ItemMeta backItemMeta = back.getItemMeta();
        backItemMeta.setDisplayName(I18n.format("user.info.back"));
        back.setItemMeta(backItemMeta);
        inventory.setItem(45, back);
    }
    if (page < pageCount) {
        ItemStack nextPage = new ItemStack(Material.ARROW);
        ItemMeta nextPageMeta = nextPage.getItemMeta();
        nextPageMeta.setDisplayName(I18n.format("user.info.next_page"));
        nextPage.setItemMeta(nextPageMeta);
        inventory.setItem(53, nextPage);
    }
    player.openInventory(inventory);
}
 
开发者ID:NyaaCat,项目名称:Ourtown,代码行数:41,代码来源:SpawnGUI.java

示例15: getRainWaterCollector

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public static ItemStack getRainWaterCollector(){
	ItemStack sw=new ItemStack(Material.HOPPER);
	//ItemStack sw=new ItemStack(Material.CAULDRON_ITEM);
	ItemMeta im = sw.getItemMeta();
	im.setDisplayName("��3��l��ˮ�ռ���");
	sw.setItemMeta(im);
	return sw;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:9,代码来源:Items.java


注:本文中的org.bukkit.inventory.ItemStack.setItemMeta方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。