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


Java ItemMeta.getLore方法代码示例

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


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

示例1: onBlockPlace

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) {
    Block block = event.getBlockPlaced();
    ItemStack stack = event.getItemInHand();
    Player player = event.getPlayer();
    if (block.getState() instanceof CreatureSpawner && stack.hasItemMeta()) {
        ItemMeta meta = stack.getItemMeta();

        if (meta.hasLore() && meta.hasDisplayName()) {
            CreatureSpawner spawner = (CreatureSpawner) block.getState();
            List<String> lore = meta.getLore();
            if (!lore.isEmpty()) {
                String spawnerName = ChatColor.stripColor(lore.get(0).toUpperCase());
                Optional<EntityType> entityTypeOptional = GuavaCompat.getIfPresent(EntityType.class, spawnerName);
                if (entityTypeOptional.isPresent()) {
                    spawner.setSpawnedType(entityTypeOptional.get());
                    spawner.update(true, true);
                    player.sendMessage(ChatColor.AQUA + "Placed a " + ChatColor.BLUE + spawnerName + ChatColor.AQUA + " spawner.");
                }
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:24,代码来源:CrowbarListener.java

示例2: open

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public void open(Player p){
    Inventory inv = Bukkit.createInventory(null, 54, getInventoryName());

    Set<String> list = config.getConfigurationSection("items").getKeys(false);

    int slot = 0;
    for(String name : list){
        ItemStack is = ItemHelper.toItemStack(name);
        ItemMeta im = is.getItemMeta();
        List<String> lore = im.hasLore() ? im.getLore() : new ArrayList<>();
        lore.add("§f");
        lore.add("§7아이템 이름: " + name);
        Util.setItem(im.getDisplayName(),is.getType(),is.getDurability(),is.getAmount(),lore,is.getEnchantments(),slot,inv);
        slot++;

    }

    p.openInventory(inv);
}
 
开发者ID:SkyLightQP,项目名称:ItemUtility,代码行数:20,代码来源:ItemListGui.java

示例3: getValidEnchantments

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
private Map<CustomEnchantment, Integer> getValidEnchantments(ArrayList<ItemStack> items) {
    Map<CustomEnchantment, Integer> validEnchantments = new HashMap<>();
    for (ItemStack item : items) {
        if (item == null) continue;
        ItemMeta meta = item.getItemMeta();
        if (meta == null) continue;
        if (!meta.hasLore()) continue;
        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() && validEnchantments.containsKey(enchant)) {
                    level += validEnchantments.get(enchant);
                }
                validEnchantments.put(enchant, level);
            }
        }
    }
    return validEnchantments;
}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:24,代码来源:EnchantListener.java

示例4: onBlockPlace

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent event)
{
  ItemStack stack = event.getItemInHand();
  BlockState state = event.getBlock().getState();
  if (((state instanceof Sign)) && (stack.hasItemMeta()))
  {
    ItemMeta meta = stack.getItemMeta();
    if ((meta.hasDisplayName()) && (meta.getDisplayName().equals(EVENT_SIGN_ITEM_NAME)))
    {
      Sign sign = (Sign)state;
      List<String> lore = meta.getLore();
      int count = 0;
      for (String loreLine : lore)
      {
        sign.setLine(count++, loreLine);
        if (count == 4) {
          break;
        }
      }
      sign.update();
    }
  }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:25,代码来源:EventSignListener.java

示例5: getBuyableSlotForLine

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
@NotNull
public static ItemStack getBuyableSlotForLine(int line) {
    ItemStack slot = buyableSlot.clone();
    ItemMeta im = slot.getItemMeta();
    List<String> lore = im.getLore();
    FileLanguage lang = RPGInventory.getLanguage();

    if (Config.getConfig().getBoolean("slots.money.enabled")) {
        lore.add(lang.getMessage("buyable.money", StringUtils.doubleToString(Config.getConfig().getDouble("slots.money.cost.line" + line))));
    }

    if (Config.getConfig().getBoolean("slots.level.enabled")) {
        lore.add(lang.getMessage("buyable.level", Config.getConfig().getInt("slots.level.required.line" + line)));
    }
    im.setLore(lore);
    slot.setItemMeta(im);

    return addId(slot);
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:20,代码来源:InventoryLocker.java

示例6: attach

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public static ItemStack attach(ItemStack it, String id) {
	ItemStack i = it.clone();
	ItemMeta m = i.getItemMeta();
	
	List<String> lore = new ArrayList<String>();
	
	lore.addAll(Arrays.asList(new String[] {ChatColor.RESET + "" + ChatColor.DARK_GRAY + id}));
	if (m.getLore() != null && !m.getLore().isEmpty()) {
		lore.add("");
		lore.addAll(m.getLore());
	}
	
	m.setLore(lore);
	i.setItemMeta(m);
	
	return i;
}
 
开发者ID:GigaGamma,项目名称:McLink,代码行数:18,代码来源:ItemId.java

示例7: syncInfoSlots

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public static void syncInfoSlots(PlayerWrapper playerWrapper) {
    final Player player = (Player) playerWrapper.getPlayer();
    for (Slot infoSlot : SlotManager.instance().getInfoSlots()) {
        ItemStack cup = infoSlot.getCup();
        ItemMeta meta = cup.getItemMeta();
        List<String> lore = meta.getLore();

        for (int i = 0; i < lore.size(); i++) {
            String line = lore.get(i);
            lore.set(i, StringUtils.setPlaceholders(player, line));
        }

        meta.setLore(lore);
        cup.setItemMeta(meta);
        playerWrapper.getInventory().setItem(infoSlot.getSlotId(), cup);
    }

    player.updateInventory();
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:20,代码来源:InventoryManager.java

示例8: ShopIcon

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
ShopIcon(Hub hub, String categoryName, int storageId, int slot, int[] resetIds) throws Exception
{
    this.hub = hub;
    this.storageId = storageId;
    this.slot = slot;
    this.resetIds = resetIds;

    hub.getGameManager().log(Level.INFO, "Fetching shop icon data for the id: " + storageId);

    this.itemDescription = SamaGamesAPI.get().getShopsManager().getItemDescription(storageId);
    this.icon = PersistanceUtils.makeStack(hub, this.itemDescription);

    if (categoryName != null)
    {
        ItemMeta meta = this.icon.getItemMeta();
        List<String> lore = (meta.getLore() != null) ? meta.getLore() : new ArrayList<>();

        lore.add(0, ChatColor.DARK_GRAY + categoryName);

        if (meta.getLore() != null)
            lore.add(1, "");

        meta.setLore(lore);
        this.icon.setItemMeta(meta);
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:27,代码来源:ShopIcon.java

示例9: removeItemLore

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public ItemStack removeItemLore(ItemStack item, Ability ability) {
	ItemStack newItem = item.clone();
	ItemMeta newMeta = newItem.getItemMeta();
	List<String> newLore = newMeta.getLore();
	newLore.remove(ChatColor.GRAY + "Ability: " + ChatColor.RED + ability.getName());
	newLore.remove(ChatColor.GRAY + "Temporary");
	newMeta.setLore(newLore);
	newItem.setItemMeta(newMeta);
	return newItem;
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:11,代码来源:AbilityManager.java

示例10: toItemStack

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
private ItemStack toItemStack(VillagerTrade trade, Player player, Game game) {
	ItemStack tradeStack = trade.getRewardItem().clone();
	Method colorable = Utils.getColorableMethod(tradeStack.getType());
	ItemMeta meta = tradeStack.getItemMeta();
	ItemStack item1 = trade.getItem1();
	ItemStack item2 = trade.getItem2();
	if ((tradeStack.getType().equals(Material.STAINED_GLASS))
			|| (tradeStack.getType().equals(Material.WOOL))
			|| (tradeStack.getType().equals(Material.STAINED_CLAY))) {
		tradeStack.setDurability((short) game.getPlayerTeam(player)
				.getColor().getDyeColor().getData());
	} else if (colorable != null) {
		colorable.setAccessible(true);
		try {
			colorable.invoke(meta, new Object[] { game
					.getPlayerTeam(player).getColor().getColor() });
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	List<String> lores = meta.getLore();
	if (lores == null) {
		lores = new ArrayList<String>();
	}
	if (trade instanceof XPVillagerTrade) {
		lores.add("��a" + ((XPVillagerTrade) trade).getXP() + " ����");
	} else {
		lores.add(ChatColor.WHITE + String.valueOf(item1.getAmount()) + " "
				+ item1.getItemMeta().getDisplayName());
		if (item2 != null) {
			lores.add(ChatColor.WHITE + String.valueOf(item2.getAmount())
					+ " " + item2.getItemMeta().getDisplayName());
		}
	}
	meta.setLore(lores);
	tradeStack.setItemMeta(meta);
	return tradeStack;
}
 
开发者ID:Ldcr993519867,项目名称:BedwarsXP,代码行数:39,代码来源:XPItemShop.java

示例11: addToItem

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public ItemStack addToItem(ItemStack item, int enchantLevel)
{
    Validate.notNull(item);
    ItemMeta meta = item.getItemMeta();
    if (meta == null) meta = Bukkit.getServer().getItemFactory().getItemMeta(item.getType());
    List<String> metaLore = meta.getLore() == null ? new ArrayList<>() : meta.getLore();

    // Make sure the enchantment doesn't already exist on the item
    for (Map.Entry<CustomEnchantment, Integer> entry : getEnchantments(item).entrySet())
    {
        if (entry.getKey().getName().equals(getName()))
        {
            if (entry.getValue() < enchantLevel)
            {
                metaLore.remove(ChatColor.GRAY + getName() + " " + RomanNumerals.numeralOf(entry.getValue()));
            }
            else
            {
                return item;
            }
        }
    }

    // Add the enchantment
    metaLore.add(0, ChatColor.GRAY + getName() + " " + RomanNumerals.numeralOf(enchantLevel));
    meta.setLore(metaLore);
    String name = EnchantUtils.getName(item);
    if (name != null) meta.setDisplayName(name);
    item.setItemMeta(meta);
    return item;
}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:32,代码来源:CustomEnchantment.java

示例12: withLore

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public ItemStackBuilder withLore(String name) {
    if (itemStack.getType() == Material.AIR) return this;
    final ItemMeta meta = itemStack.getItemMeta();
    List<String> lore = meta.getLore();
    if (lore == null) {
        lore = new ArrayList<>();
    }
    lore.add(Colors.color(name));
    meta.setLore(lore);
    itemStack.setItemMeta(meta);
    return this;
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:13,代码来源:ItemStackBuilder.java

示例13: fromStack

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
/**
 * Parses an {@link Crowbar} from a given {@link ItemStack}.
 *
 * @param stack
 *            the stack to parse from
 * @return the {@link Crowbar} instance
 */
public static Optional<Crowbar> fromStack(ItemStack stack) {
    if (stack == null || !stack.hasItemMeta()) {
        return Optional.absent();
    }

    ItemMeta meta = stack.getItemMeta();
    if (!meta.hasDisplayName() || !meta.hasLore() || !meta.getDisplayName().equals(CROWBAR_NAME)) {
        return Optional.absent();
    }

    Crowbar crowbar = new Crowbar();
    List<String> loreList = meta.getLore();
    for (String lore : loreList) {
        lore = ChatColor.stripColor(lore);
        int length = lore.length();
        for (int i = 0; i < length; i++) {
            char character = lore.charAt(i);
            if (Character.isDigit(character)) {
                int amount = Integer.parseInt(String.valueOf(character));
                if (lore.startsWith(END_FRAME_USE_TAG)) {
                    crowbar.setEndFrameUses(amount);
                    break;
                } else if (lore.startsWith(SPAWNER_USE_TAG)) {
                    crowbar.setSpawnerUses(amount);
                    break;
                }
            }
        }
    }

    return Optional.of(crowbar);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:40,代码来源:Crowbar.java

示例14: getReleaseCrateKey

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public static ItemStack getReleaseCrateKey(){
    ItemStack key = new ItemStack(Material.TRIPWIRE_HOOK);
    ItemMeta keyMeta = key.getItemMeta();
    keyMeta.setDisplayName(ChatColor.GOLD + "Release Crate Key");
    List<String> lore = keyMeta.getLore();
    lore.clear();
    lore.add("Bring this to the release crate at spawn to open!");
    keyMeta.setLore(lore);
    key.setItemMeta(keyMeta);
    return key;
}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:12,代码来源:Crate.java

示例15: updateMagazineLore

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
/**
 * Given a magazine object, updates the lore to reflect the NBT
 * 
 * @param magazine the magazine to update
 * @return the magazine, with updated lore.
 */
public ItemStack updateMagazineLore(ItemStack magazine) {
	ItemMeta meta = magazine.getItemMeta();
	List<String> lore = meta.getLore();
	if (lore == null) {
		lore = new ArrayList<String>();
	} else {
		lore.clear();
	}
	lore.add(this.tag);
	if (this.exampleLore != null && !this.exampleLore.isEmpty()) {
		lore.addAll(this.exampleLore);
	}
	Map<String, Object> magazineData = getMagazineData(magazine);
	
	String ammo = magazineData.containsKey("ammo") ? (String) magazineData.get("ammo") : null;
	Integer rounds = (Integer) magazineData.get("rounds");
	
	if (ammo != null) { // locked / has a bullet
		lore.add(ChatColor.GREEN + "Magazine of " + ChatColor.GRAY + ammo);
		if (rounds <= 0) {
			lore.add(ChatColor.RED + "  EMPTY " + ChatColor.DARK_AQUA + "(out of " + ChatColor.WHITE + this.allowsRounds.get(ammo) + ChatColor.DARK_AQUA + " max)");
		} else if (rounds == 1) {
			lore.add(ChatColor.GOLD + "  1 " + ChatColor.BLUE + "Round " + ChatColor.DARK_AQUA + "(out of " + ChatColor.WHITE + this.allowsRounds.get(ammo) + ChatColor.DARK_AQUA + " max)");
		} else {
			lore.add(ChatColor.GREEN + String.format("  %d ", rounds) + ChatColor.BLUE + "Rounds " + ChatColor.DARK_AQUA + "(out of " + ChatColor.WHITE + this.allowsRounds.get(ammo) + ChatColor.DARK_AQUA + " max)");
		}
	} else {
		lore.add(ChatColor.RED + "Magazine Empty");
		lore.add(ChatColor.GREEN + "Accepts bullets: ");
		for (String bull : this.allowedBullets) {
			lore.add(ChatColor.GREEN + " - " + ChatColor.GRAY + bull);
		}
	}

	meta.setLore(lore);
	magazine.setItemMeta(meta);
	return magazine;
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:45,代码来源:Magazine.java


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