本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}