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


Java ItemMeta.hasLore方法代码示例

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


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

示例1: CustomItem

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public CustomItem(ItemStack item) {
    type = item.getType();
    data = PlaceholderValue.shortValue(String.valueOf(item.getData().getData()));
    amount = PlaceholderValue.intValue(String.valueOf(item.getAmount()));

    ItemMeta meta = item.getItemMeta();
    if(meta != null) {
        displayName = meta.hasDisplayName() ? PlaceholderValue.stringValue(meta.getDisplayName()) : null;
        lore = meta.hasLore() ? meta.getLore().stream().map(PlaceholderValue::stringValue).collect(Collectors.toList()) : new ArrayList<>();
        flags = new ArrayList<>(meta.getItemFlags());
        for (Map.Entry<Enchantment, Integer> entry : meta.getEnchants().entrySet())
            enchantments.put(entry.getKey(), PlaceholderValue.intValue(String.valueOf(entry.getValue())));
    } else {
        displayName = PlaceholderValue.fake("");
        lore = Collections.emptyList();
    }
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:18,代码来源:CustomItem.java

示例2: executePlayer

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerDataRPG pd, String[] args) {
    ItemStack item = p.getInventory().getItemInMainHand();
    if (item.hasItemMeta()) {
        ItemMeta im = item.getItemMeta();
        ArrayList<String> lore = new ArrayList<String>();
        if (im.hasLore())
            lore.addAll(im.getLore());
        StringBuilder sb = new StringBuilder();
        for (int k = 1; k < args.length; k++) {
            sb.append(args[k]);
            sb.append(' ');
        }
        String newLine = ChatColor.translateAlternateColorCodes('&', sb.toString().trim());
        if (args[0].equalsIgnoreCase("append")) {
            lore.add(newLine);
        } else {
            lore.set(Integer.parseInt(args[0]), newLine);
        }
        im.setLore(lore);
        item.setItemMeta(im);
        p.sendMessage("Updated item.");
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:25,代码来源:EditLoreCommand.java

示例3: serializeForMenu

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
private static String serializeForMenu(ItemStack item) {
    StringBuilder sb = new StringBuilder();
    sb.append(item.getType());
    sb.append('$');
    sb.append(item.getAmount());
    if (item.hasItemMeta()) {
        ItemMeta im = item.getItemMeta();
        if (im.hasDisplayName()) {
            sb.append('#');
            sb.append(im.getDisplayName());
        }
        if (im.hasLore()) {
            sb.append('#');
            sb.append(im.getLore().toString());
        }
        if (im.hasEnchants()) {
            sb.append('#');
            sb.append(im.getEnchants().toString());
        }
    }
    return sb.toString();
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:23,代码来源:MenuManager.java

示例4: 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

示例5: removeFromItem

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public ItemStack removeFromItem(ItemStack item)
{
    ItemMeta meta = item.getItemMeta();
    if (meta == null) return item;
    if (!meta.hasLore()) return item;
    List<String> metaLore = 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()))
        {
            metaLore.remove(ChatColor.GRAY + getName() + " " + RomanNumerals.numeralOf(entry.getValue()));
        }
    }
    return item;
}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:18,代码来源:CustomEnchantment.java

示例6: getEnchantments

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的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;
}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:22,代码来源:CustomEnchantment.java

示例7: 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

示例8: addLootItem

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
/**
 * Add a loot item to the random loot collection
 * 
 * @param item the item to add
 * @param weight the generation weight of the item
 * @param updateFile whether to update the dragon file or not
 */
@SuppressWarnings("deprecation")
public void addLootItem(ItemStack item, double weight, boolean updateFile) {
	Validate.notNull(item, "Cannot add null ItemStack to loot");
	if (weight < 0) weight = 0;
	
	this.loot.add(weight, item);
	
	if (updateFile && template.configFile != null) {
		FileConfiguration config = template.configFile;
		int itemID = loot.size();
		
		config.set("loot." + itemID + ".weight", weight);
		config.set("loot." + itemID + ".type", item.getType().name());
		if (item.getData().getData() != 0) config.set("loot." + itemID + ".data", item.getData().getData());
		if (item.getDurability() != 0) config.set("loot." + itemID + ".damage", item.getDurability());
		config.set("loot." + itemID + ".amount", item.getAmount());
		
		if (item.hasItemMeta()) {
			ItemMeta meta = item.getItemMeta();
			
			if (meta.hasDisplayName()) config.set("loot." + itemID + ".display-name", meta.getDisplayName());
			if (meta.hasLore()) config.set("loot." + itemID + ".lore", meta.getLore());
			if (meta.hasEnchants()) {
				for (Enchantment enchant : meta.getEnchants().keySet()) {
					config.set("loot." + itemID + ".enchantments." + enchant.getName(), meta.getEnchantLevel(enchant));
				}
			}
		}
		
		try {
			config.save(template.file);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:44,代码来源:DragonLoot.java

示例9: addLore

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public ItemStack addLore(SpawnLocation spawnLocation, ItemStack itemStack) {
    ItemMeta meta = itemStack.getItemMeta();
    List<String> lore;
    if (meta.hasLore()) {
        lore = meta.getLore();
    } else {
        lore = new ArrayList<>();
    }
    meta.setDisplayName(I18n.format("user.select.gui.item.name", spawnLocation.getName()));
    if (spawnLocation.getDescription().length() > 0) {
        String[] split = spawnLocation.getDescription().split("\\\\n");
        for (String s : split) {
            lore.add(market_lore_code + ChatColor.RESET +
                    I18n.format("user.select.gui.item.description", ChatColor.translateAlternateColorCodes('&', s)));
        }
    }
    if (!spawnLocation.isAvailable()) {
        lore.add(I18n.format("user.select.gui.item.unavailable"));
    }
    if (!currentSpawn.getName().equals(spawnLocation.getName())) {
        if (spawnLocation.isAvailable()) {
            if (!plugin.config.lock_spawn && plugin.config.select_fee > 0) {
                if (plugin.hasSpawn(player)) {
                    lore.add(I18n.format("user.select.gui.item.fee", plugin.config.select_fee));
                }
            }
            lore.add(I18n.format("user.select.gui.item.click", player.getName()));
        }
    } else {
        lore.add(I18n.format("user.select.gui.item.selected"));
    }
    meta.setLore(lore);
    itemStack.setItemMeta(meta);
    return itemStack;
}
 
开发者ID:NyaaCat,项目名称:Ourtown,代码行数:36,代码来源:SpawnGUI.java

示例10: unplaceable

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的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);
        }
    }
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:15,代码来源:ItemActionListener.java

示例11: applyAbility

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public void applyAbility(Player player, ItemStack item, Ability ability, boolean temporary) {
	// Adding lore
	ItemMeta meta = item.getItemMeta();
	List<String> lore = meta.hasLore() ?
			meta.getLore() : new ArrayList<>();
	
	lore.add(ChatColor.GRAY + "Ability: " + ChatColor.RED + ability.getName());
	if(temporary)
		lore.add(ChatColor.GRAY + "Temporary");
	meta.setLore(lore);
	item.setItemMeta(meta);
	player.getInventory().setItemInMainHand(item);
	
	if(!temporary)
		return;
	
	// Adding timer for temporary abilities
	new BukkitRunnable() {
		
		@Override
		public void run() {
			if(!isActive(player, item)) {
				this.cancel();
			}
			
			updateTemporaryItem(player, item, ability);
			
			player.sendMessage(Lang.HEADERS_TOKENS.toString() 
					+ Lang.TOKENS_SHOP_EXPIRED.toString()
						.replaceAll("%s", ability.getName()));
		}
		
	}.runTaskLater(plugin, 100 * 60 * 20);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:35,代码来源:AbilityManager.java

示例12: onBlockPlace

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {

	if (event.getItemInHand().getType() != Material.MOB_SPAWNER)
		return;

	ItemStack is = event.getItemInHand();
	if (!is.hasItemMeta())
		return;

	ItemMeta im = is.getItemMeta();

	if (!im.hasLore())
		return;

	String lore = im.getLore().toString();

	if (!lore.contains("Spawner:"))
		return;

	EntityType entity = getEntity(lore);

	if (entity == EntityType.AREA_EFFECT_CLOUD) {
		event.setCancelled(true);
		return;
	}

	setSpawner(event.getBlock(), entity);
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:30,代码来源:BlockPlace.java

示例13: serialize

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
@Override
public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject result = new JsonObject();
    JsonArray enchantments = new JsonArray();

    for (Enchantment e : src.getEnchantments().keySet()) {
        JsonObject ench = new JsonObject();

        ench.addProperty("id", e.getName());
        ench.addProperty("lvl", src.getEnchantments().get(e));

        enchantments.add(ench);
    }

    result.addProperty("type", src.getType().name());
    result.addProperty("amount", src.getAmount());
    result.addProperty("durability", src.getDurability());
    result.add("enchantments", enchantments);

    if (src.hasItemMeta()) {
        JsonObject meta = new JsonObject();
        ItemMeta itemMeta = src.getItemMeta();

        if (itemMeta.hasDisplayName())
            meta.addProperty("displayName", itemMeta.getDisplayName().replace("§", "&"));

        if (itemMeta.hasLore())
            meta.add("lore", JSONUtil.getGson().toJsonTree(Arrays.asList(Util.replaceInArray("§", "&", itemMeta.getLore().toArray(new String[itemMeta.getLore().size()])))));

        meta.add("flags", JSONUtil.getGson().toJsonTree(itemMeta.getItemFlags()));

        result.add("meta", meta);
    }

    return result;
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:37,代码来源:JSONUtil.java

示例14: isSameMeta

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
private static boolean isSameMeta(ItemMeta a, ItemMeta b) {
    if (a == null || b == null) return false;

    boolean dn = a.hasDisplayName() == b.hasDisplayName();
    boolean l = a.hasLore() == b.hasLore();
    boolean hdn = a.hasDisplayName();
    boolean hl = a.hasLore();

    if (dn) {
        if (l) {
            if (hdn) {
                if (hl) {
                    return a.getDisplayName().equals(b.getDisplayName()) && a.getLore().equals(b.getLore());
                } else { //only name
                    return a.getDisplayName().equals(b.getDisplayName());
                }
            } else { //maybe lore
                return !hl || a.getLore().equals(b.getLore());
            }
        } else { //maybe name
            return !hdn || a.getDisplayName().equals(b.getDisplayName());
        }
    } else if (l) {
        return !hl || a.getLore().equals(b.getLore());
    }
    return false;
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:28,代码来源:Util.java

示例15: itemStackToString

import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static String itemStackToString(ItemStack item) {
    StringBuilder builder = new StringBuilder();

    if (item != null) {
        String isType = String.valueOf(item.getType().getId());
        builder.append("[email protected]").append(isType);

        if (item.getDurability() != 0) {
            String isDurability = String.valueOf(item.getDurability());
            builder.append(":[email protected]").append(isDurability);
        }

        if (item.getAmount() != 1) {
            String isAmount = String.valueOf(item.getAmount());
            builder.append(":[email protected]").append(isAmount);
        }

        Map<Enchantment, Integer> isEnch = (Map<Enchantment, Integer>) item.getEnchantments();
        if (isEnch.size() > 0) {
            for (Map.Entry<Enchantment, Integer> ench : isEnch.entrySet()) {
                builder.append(":[email protected]").append(ench.getKey().getId()).append("@").append(ench.getValue());
            }
        }

        if (item.hasItemMeta()) {
            ItemMeta imeta = item.getItemMeta();
            if (imeta.hasDisplayName()) {
                builder.append(":[email protected]").append(imeta.getDisplayName());
            }
            if (imeta.hasLore()) {
                builder.append(":[email protected]").append(imeta.getLore());
            }
        }
    }

    return builder.toString();
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:39,代码来源:InventoryUtils.java


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