當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。