Java 类org.bukkit.inventory.ItemFlag 实例源码

项目:NetworkCore    文件:ValeUtil.java   
public static void setVale(Player player, int amount) throws SQLException {
    UUID uuid = player.getUniqueId();
    PreparedStatement stmt = plugin.getDb().getConnection().prepareStatement("UPDATE vale_eco SET amount = "+amount+" WHERE uuid = '"+uuid.toString()+"'");
    stmt.executeUpdate();

    ItemStack item = new ItemStack(Material.EMERALD, 1);
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(ChatColor.GREEN.toString() + getVale(player) + (getVale(player)==1?" Vale":" Vales"));
    meta.addEnchant(Enchantment.LUCK, 1, true);
    meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    item.setItemMeta(meta);
    if(plugin.getConfig().getString("valeitemininv").equals("true")){
        player.getInventory().setItem(8, item);
    }

}
项目:ZentrelaRPG    文件:EtcItem.java   
@Override
public ItemStack generate() {
    ItemStack item = new ItemStack(material);
    ItemMeta im = item.getItemMeta();
    im.setDisplayName(name);
    ArrayList<String> lore = new ArrayList<String>();
    if (soulbound) {
        lore.add(ChatColor.RED + ChatColor.ITALIC.toString() + "Soulbound");
    }
    if (description.length() > 0)
        lore.addAll(RFormatter.stringToLore(description, ChatColor.GRAY));
    im.setLore(lore);
    im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
    im.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
    item.setItemMeta(im);
    return item;
}
项目:WC    文件:ItemUtil.java   
public static ItemStack createItem(Material material, int amount, short data, String displayname, List<String> lore) {
    ItemStack item = new ItemStack(material, amount, data);
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(Utils.colorize(displayname));
    ArrayList<String> colorLore = new ArrayList<>();
    if (lore != null) {
        lore.forEach(str -> colorLore.add(Utils.colorize(str)));
        meta.setLore(colorLore);
    }

    meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ATTRIBUTES,
            ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_UNBREAKABLE);

    item.setItemMeta(meta);
    return item;
}
项目:OMGPI    文件:Inventories.java   
/**
 * 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);
}
项目:WC    文件:ItemUtil.java   
public static ItemStack createGlass(String displayname, List<String> lore, DyeColor dye) {
    ItemStack item = new ItemStack(Material.STAINED_GLASS_PANE, 1, dye.getWoolData());
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(Utils.colorize(displayname));

    ArrayList<String> colorLore = new ArrayList<>();
    if (lore != null) {
        lore.forEach(str -> colorLore.add(Utils.colorize(str)));
        meta.setLore(colorLore);
    }

    meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ATTRIBUTES,
            ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_UNBREAKABLE);
    item.setItemMeta(meta);
    return item;
}
项目:WC    文件:ItemUtil.java   
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;
}
项目:ProjectAres    文件:DefuseListener.java   
@EventHandler
public void giveKit(final ObserverKitApplyEvent event) {
    final MatchPlayer player = mm.getPlayer(event.getPlayer());
    if(player == null) return;
    if(!player.isObservingType()) return;
    if(!player.getBukkit().hasPermission("pgm.defuse")) return;

    ItemStack shears = new ItemStack(DEFUSE_ITEM);

    // TODO: Update information if locale changes
    ItemMeta meta = shears.getItemMeta();
    meta.addItemFlags(ItemFlag.values());
    meta.setDisplayName(PGMTranslations.t("defuse.displayName", player));
    meta.setLore(Lists.newArrayList(ChatColor.GRAY + PGMTranslations.t("defuse.tooltip", player)));
    shears.setItemMeta(meta);

    event.getPlayer().getInventory().setItem(DEFUSE_SLOT, shears);
}
项目:ProjectAres    文件:PickerMatchModule.java   
private ItemStack createJoinButton(final MatchPlayer player) {
    ItemStack stack = new ItemStack(Button.JOIN.material);

    ItemMeta meta = stack.getItemMeta();
    meta.addItemFlags(ItemFlag.values());

    String key;
    if(!canOpenWindow(player)) {
        key = "ffa.picker.displayName";
    } else if(hasTeams && hasClasses) {
        key = "teamClass.picker.displayName";
    } else if(hasTeams) {
        key = "teamSelection.picker.displayName";
    } else if(hasClasses) {
        key = "class.picker.displayName";
    } else {
        key = "ffa.picker.displayName";
    }

    meta.setDisplayName(OPEN_BUTTON_PREFIX + PGMTranslations.t(key, player));
    meta.setLore(Lists.newArrayList(ChatColor.DARK_PURPLE + PGMTranslations.t("teamSelection.picker.tooltip", player)));

    stack.setItemMeta(meta);
    ITEM_TAG.set(stack, "join");
    return stack;
}
项目:ProjectAres    文件:PickerMatchModule.java   
private ItemStack createClassButton(MatchPlayer viewer, PlayerClass cls) {
    ItemStack item = cls.getIcon().toItemStack(1);
    ItemMeta meta = item.getItemMeta();
    meta.addItemFlags(ItemFlag.values());

    meta.setDisplayName((cls.canUse(viewer.getBukkit()) ? ChatColor.GREEN : ChatColor.RED) + cls.getName());
    if(getMatch().getMatchModule(ClassMatchModule.class).selectedClass(viewer.getDocument()).equals(cls)) {
        meta.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
    }

    List<String> lore = Lists.newArrayList();
    if(cls.getLongDescription() != null) {
        ChatUtils.wordWrap(ChatColor.GOLD + cls.getLongDescription(), LORE_WIDTH_PIXELS, lore);
    } else if(cls.getDescription() != null) {
        lore.add(ChatColor.GOLD + cls.getDescription());
    }

    if(!cls.canUse(viewer.getBukkit())) {
        lore.add(ChatColor.RED + PGMTranslations.t("class.picker.restricted", viewer));
    }

    meta.setLore(lore);
    item.setItemMeta(meta);

    return item;
}
项目:KingdomFactions    文件:EmpireWandModule.java   
public ItemStack getEmpireWand() {


        ItemStack empirewand = new ItemStack(Material.BLAZE_ROD, 1);
        ItemMeta meta = empirewand.getItemMeta();
        meta.setDisplayName(ChatColor.RED + "Empire Wand");
        ArrayList<String> lore = new ArrayList<String>();
        try {
            lore.add(ChatColor.translateAlternateColorCodes('&', new Randomizer<String>(KingdomFactionsPlugin.getInstance()
                            .getDataManager().getArrayData("Empirewand.lores").getValue()).result()));
        } catch (DataException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        meta.setLore(lore);
        meta.addEnchant(Enchantment.LURE, 1, true);
        meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        empirewand.setItemMeta(meta);

        return empirewand;
    }
项目:FactionsXL    文件:SaturationMenu.java   
private void setupGUI() {
    gui = Bukkit.createInventory(null, 27, FMessage.POPULATION_ADJUST_CONSUME.getMessage(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, GUIButton.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, GRANT_BUTTON);
}
项目:FactionsXL    文件:DemandMenu.java   
public static ItemStack formButton(Faction faction, Resource resource) {
    ItemStack icon = resource.getIcon();
    ItemMeta meta = icon.getItemMeta();
    SaturationLevel level = faction.isResourceSaturated(resource);
    if (level == SaturationLevel.SURPLUS) {
        meta.addEnchant(Enchantment.LUCK, 1, true);
        meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    }
    meta.setDisplayName(level.getColor() + resource.getName());
    ArrayList<String> lore = new ArrayList<>();
    lore.add(ProgressBar.getBar((double) faction.getSaturatedResources().get(resource)));
    lore.add(level.getColor().toString() + faction.getSaturatedResources().get(resource) + "%");
    String population = String.valueOf(faction.getPopulation());
    String units = String.valueOf(faction.getDemand(resource));
    lore.add(FMessage.POPULATION_REQUIRED.getMessage(population, units, resource.getName()));
    lore.add(FMessage.POPULATION_GRANTING1.getMessage());
    lore.add(FMessage.POPULATION_GRANTING2.getMessage(String.valueOf(faction.getConsumableResources().get(resource)), resource.getName()));
    meta.setLore(lore);
    icon.setItemMeta(meta);
    return icon;
}
项目:FactionsXL    文件:ResourceMenu.java   
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);
}
项目:FactionsXL    文件:TradeOfferCommand.java   
private Inventory choosePartner(Faction creator) {
    int size = (int) (9 * Math.ceil(((double) factions.getActive().size() / 9)));
    Inventory gui = Bukkit.createInventory(null, size, FMessage.TRADE_OFFER_CHOOSE_PARTNER.getMessage());
    int i = 0;
    for (Faction faction : factions.getActive()) {
        ItemStack icon = faction.getBannerStack();
        ItemMeta meta = icon.getItemMeta();
        meta.setDisplayName(creator.getRelation(faction).getColor() + faction.getName());
        meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
        icon.setItemMeta(meta);
        gui.setItem(i, icon);
        factionBySlot.put(i, faction);
        i++;
    }
    return gui;
}
项目:AlphaLibary    文件:LeatherItemBuilder.java   
/**
 * Get the final {@link ItemStack} with all the attributes you have been adding
 *
 * @return the {@link ItemStack} of this {@link ItemBuilder}
 */
@Override
public ItemStack build() {
    ItemStack s = new ItemStack(this.getMaterial());
    s.setAmount(this.getAmount());
    s.setDurability(this.getDamage());
    LeatherArmorMeta m = (LeatherArmorMeta) s.getItemMeta();

    for (ItemFlag iflag : this.getAllItemflags()) {
        m.addItemFlags(iflag);
    }
    m.setDisplayName(this.getName());
    m.setLore(this.getLore());
    m.setColor(color);
    s.setItemMeta(m);
    for (Map.Entry<Enchantment, Integer> temp : this.getAllEnchantments().entrySet()) {
        s.addUnsafeEnchantment(temp.getKey(), temp.getValue());
    }
    return s;
}
项目:AlphaLibary    文件:ItemBuilder.java   
/**
 * Get the final {@link ItemStack} with all the attributes you have been adding
 *
 * @return the {@link ItemStack} out of this {@link ItemBuilder}
 */
public ItemStack build() {
    ItemStack s = new ItemStack(material);
    s.setAmount(amount);
    s.setDurability(damage);
    ItemMeta m = s.getItemMeta();

    for (ItemFlag iflag : itemflags)
        m.addItemFlags(iflag);
    m.setDisplayName(name);
    m.setLore(lore);
    s.setItemMeta(m);
    for (Map.Entry<Enchantment, Integer> temp : enchantments.entrySet())
        s.addUnsafeEnchantment(temp.getKey(), temp.getValue());

    for (ItemData id : getAllData())
        try {
            id.applyOn(s);
        } catch (WrongDataException e) {
            e.printStackTrace();
        }

    return s;
}
项目:SurvivalAPI    文件:GoneFishingModule.java   
/**
 * Give a cheated fishing rod to all the players
 *
 * @param game Game
 */
@Override
public void onGameStart(SurvivalGame game)
{
    ItemStack rod = new ItemStack(Material.FISHING_ROD);
    rod.addUnsafeEnchantment(Enchantment.LUCK, 255);
    rod.addUnsafeEnchantment(Enchantment.DURABILITY, 255);
    ItemMeta meta = rod.getItemMeta();
    meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    rod.setItemMeta(meta);

    for (GamePlayer player : (Collection<GamePlayer>) game.getInGamePlayers().values())
    {
        Player p = player.getPlayerIfOnline();

        if (p != null)
            p.getInventory().addItem(rod);
    }
}
项目:MiniWynn    文件:SimpleItemFactory.java   
@SuppressWarnings("unchecked")
public <T extends Weapon> ItemStack getWeapon(Class<T> weapon){
    T weaponInst = (T) weaponCache.computeIfAbsent(weapon, k->MiniWynnPlugin.getInjector().getInstance(weapon));
    weaponInst.getSpells().forEach(spell -> spellCache.put(spell.getPattern(), spell));
    weaponCache.putIfAbsent(weapon, weaponInst);
    ItemStack item = new ItemStack(
            weaponInst.getMaterial(),
            1,
            weaponInst.getDamage()
    );
    ItemMeta meta = item.getItemMeta();
    meta.setUnbreakable(true);
    meta.setDisplayName(weaponInst.getName());
    meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE);
    meta.setLore(weaponInst.getLore());
    item.setItemMeta(meta);
    return item;
}
项目:PA    文件:Picaro.java   
public void setItems(Player p) {
    p.getInventory().setItem(0, new ItemMaker(Material.SHEARS).setDisplayName("&bChas Chas Chas").setLores("&dDaño:", "&726").addItemFlag(ItemFlag.values()).setUnbreakable().build());

    p.getInventory().setItem(3, new ItemMaker(Material.ARMOR_STAND).setDisplayName("&eLadrón").build());
    p.getInventory().setItem(4, new ItemMaker(Material.SUGAR).setDisplayName("&eFrenesí").build());
    p.getInventory().setItem(5, new ItemMaker(Material.FEATHER).setDisplayName("&eDagas").build());

    p.getInventory().setItem(8, new ItemMaker(Material.APPLE).setDisplayName("&cFantasma").build());

    p.getInventory().setHelmet(new ItemMaker(Material.CHAINMAIL_HELMET).setUnbreakable().build());
    p.getInventory().setChestplate(new ItemMaker(Material.CHAINMAIL_CHESTPLATE).setUnbreakable().build());
    p.getInventory().setLeggings(new ItemMaker(Material.CHAINMAIL_LEGGINGS).setUnbreakable().build());
    p.getInventory().setBoots(new ItemMaker(Material.CHAINMAIL_BOOTS).setUnbreakable().build());

    addEffects(TOA.getPlayer(p));
}
项目:PA    文件:ItemUtil.java   
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;
}
项目:uppercore    文件:CustomItem.java   
public CustomItem(Material type, Config config, PlaceholderRegistry placeholders) {
    this.type = type;
    this.placeholders = placeholders;
    data = PlaceholderValue.shortValue(config.getString("data", "0"));//TODO: better api
    amount = PlaceholderUtil.parseInt(config.getString("amount", "1"));

    String rawName = config.getString("name");
    displayName = rawName == null ? null : PlaceholderValue.stringValue(ChatColor.RESET.toString() + rawName);
    if (config.has("lore")) {
        lore = ((Collection<String>) config.getCollection("lore"))
                .stream()
                .map(message -> PlaceholderUtil.process(ChatColor.RESET.toString() + message))
                .collect(Collectors.toList());
    } else lore = Collections.emptyList();
    if (config.has("flags")) {
        flags = ((Collection<String>) config.getCollection("flags"))
                .stream()
                .map(s -> s.replace(' ', '_').toUpperCase(Locale.ENGLISH))
                .map(ItemFlag::valueOf)
                .collect(Collectors.toList());
    } else
        flags = Collections.emptyList();

    if (config.has("enchantments")) {
        Map<String, Object> stEnch = config.getMap("enchantments");
        for(Map.Entry<String, Object> e : stEnch.entrySet()) {
            Enchantment ench = Enchantment.getByName(e.getKey().replace(' ', '_').toUpperCase(Locale.ENGLISH));
            if (ench == null)
                throw new InvalidConfigException("Cannot find enchantment: " + e.getKey());
            else
                enchantments.put(ench, PlaceholderValue.intValue(e.getValue().toString()));
        }
    }
}
项目:uppercore    文件:CustomItem.java   
public void processMeta(Player player, ItemMeta meta) {
    if (displayName != null)
        meta.setDisplayName(displayName.resolve(player, placeholders));
    meta.setLore(lore.stream().map(m -> m.resolve(player, placeholders)).collect(Collectors.toList()));
    meta.addItemFlags(flags.toArray(new ItemFlag[0]));
    for (Map.Entry<Enchantment, PlaceholderValue<Integer>> ench : enchantments.entrySet())
        meta.addEnchant(ench.getKey(), ench.getValue().resolve(player), true);
}
项目:ZentrelaRPG    文件:GrappleManager.java   
@Override
public void initialize() {
    ItemMeta im;
    grapple = new ItemStack(Material.FISHING_ROD);
    im = grapple.getItemMeta();
    im.addEnchant(Enchantment.DURABILITY, 5, true);
    im.setDisplayName(ChatColor.GOLD + "Grappling Hook");
    im.setLore(Arrays.asList(new String[] { ChatColor.YELLOW + "It's adventure time!", "", ChatColor.GREEN + "Right-click to shoot a hook.", ChatColor.GREEN + "Right-click again to grapple!" }));
    im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
    im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    im.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
    grapple.setItemMeta(im);
}
项目:ZentrelaRPG    文件:EquipItem.java   
@Override
public ItemStack generate() {
    ItemStack item = new ItemStack(material);
    ItemMeta im = item.getItemMeta();
    // prepend reset to clear the default name coloring
    im.setDisplayName(ChatColor.RESET + name);
    // Get lore from string
    List<String> lore = stats.lore();
    if (soulbound) {
        lore.add(ChatColor.RED + ChatColor.ITALIC.toString() + "Soulbound");
    }
    // Get description, if it exists
    if (description != null && description.length() > 0) {
        if (lore.size() > 0 && lore.get(lore.size() - 1).length() > 0)
            lore.add("");
        lore.addAll(RFormatter.stringToLore(description, ChatColor.GRAY));
    }

    im.setLore(lore);
    im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
    im.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
    im.addItemFlags(ItemFlag.HIDE_DESTROYS);
    im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    im.addItemFlags(ItemFlag.HIDE_PLACED_ON);
    im.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);

    // Add color for leather armors
    if (leatherColor != null) {
        ((LeatherArmorMeta) im).setColor(leatherColor);
    }

    item.setItemMeta(im);
    return item;
}
项目:bskyblock    文件:PanelItem.java   
public PanelItem(ItemStack icon, String name, String description, boolean glow, ClickHandler clickHandler) {
    // Create the final item
    ItemMeta meta = icon.getItemMeta();
    meta.setDisplayName(name);
    meta.setLore(Arrays.asList(description.split("\\n"))); // the \n is automatically generated by the YAML when getting a multi-line value.

    // Set flags to neaten up the view
    meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
    meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
    meta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
    meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);

    if (glow) {
        meta.addEnchant(Enchantment.ARROW_DAMAGE, 0, true);
    }

    icon.setItemMeta(meta);

    // Assign the values
    this.item = icon;
    this.clickHandler = clickHandler;

    // if clickHandler is null, set a default one which will prevent picking up the item from the Panel
    if (this.clickHandler == null) {
        this.clickHandler = new ClickHandler() {
            @Override
            public boolean onClick(Player player, ClickType click) {
                return false;
            }
        };
    }
}
项目:SparseBukkitAPI    文件:ItemBuilder.java   
/**
 * Creates an ItemBuilder with initial values.
 * @param material The material.
 * @param metadata The metadata or durability.
 * @param amount The amount of items in the stack.
 * @param name The display name of the item.
 * @param lore The lore of the item (the ItemBuilder will be backed by the provided list).
 * @param enchantments A map containing the enchantments to add. {@link org.bukkit.enchantments.Enchantment} as key, level as value.
 * @param flags A {@link java.util.Set} containing all the {@link org.bukkit.inventory.ItemFlag}s to apply to this item.
 */
public ItemBuilder(Material material, int metadata, int amount, String name, List<String> lore, Map<Enchantment, Integer> enchantments, Set<ItemFlag> flags)
{
    this.material = material;
    this.metadata = metadata;
    this.amount = amount;
    this.name = name;
    this.lore = lore;
    this.enchantments = enchantments == null ? null : new HashMap<>(enchantments);
    this.flags = flags;
}
项目:SamaGamesAPI    文件:ItemUtils.java   
/**
 * Hide all the special attributes of an
 * {@link ItemStack}
 *
 * @param itemStack The stack
 * @return Cleaned stack
 */
public static ItemStack hideAllAttributes(ItemStack itemStack)
{
    ItemMeta meta = itemStack.getItemMeta();

    for (ItemFlag itemFlag : ItemFlag.values())
        if (itemFlag.name().startsWith("HIDE_"))
            meta.addItemFlags(itemFlag);

    itemStack.setItemMeta(meta);

    return itemStack;
}
项目:WC    文件:ItemMaker.java   
public ItemMaker setUnbreakable(){
    ItemMeta meta = this.itemStack.getItemMeta();
    meta.spigot().setUnbreakable(true);
    meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
    this.itemStack.setItemMeta(meta);
    return this;
}
项目:WC    文件:ItemUtil.java   
public static ItemStack createWool(String displayname, DyeColor dye) {
    ItemStack item = new Wool(dye).toItemStack(1);
    ItemMeta meta = item.getItemMeta();
    meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ATTRIBUTES,
            ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_UNBREAKABLE);
    meta.setDisplayName(displayname);
    item.setItemMeta(meta);
    return item;
}
项目:Locked    文件:ScrapsUtil.java   
public static void setScraps(Player player, int amount) throws SQLException {
    UUID uuid = player.getUniqueId();
    PreparedStatement stmt = plugin.getDb().getConnection().prepareStatement("UPDATE scraps_eco SET amount = " + amount + " WHERE uuid = '" + uuid.toString() + "'");
    stmt.executeUpdate();

    ItemStack item = new ItemStack(Material.SULPHUR, 1);
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(ChatColor.GREEN.toString() + getScraps(player) + (getScraps(player) == 1 ? " Scrap" : " Scraps"));
    meta.addEnchant(Enchantment.LUCK, 1, true);
    meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    item.setItemMeta(meta);
    player.getInventory().setItem(8, item);
}
项目:WC    文件:FichasMaker.java   
public FichasMaker setDisplayName(String displayName) {
    ItemMeta itemMeta = this.itemStack.getItemMeta();
    itemMeta.setDisplayName(displayName);
    itemMeta.setLore(Arrays.asList("Item de Casino"));
    addItemFlag(ItemFlag.HIDE_ENCHANTS);
    this.itemStack.setItemMeta(itemMeta);
    return this;
}
项目:WC    文件:ItemMaker.java   
public ItemMaker addItemFlag(ItemFlag... itemFlags) {
    ItemMeta itemMeta = this.itemStack.getItemMeta();
    itemMeta.addItemFlags(itemFlags);
    this.itemStack.setItemMeta(itemMeta);
    addItemFlag(ItemFlag.HIDE_ENCHANTS);
    return this;
}
项目:SuperiorCraft    文件:CustomPanelTexture.java   
public CustomPanelTexture(int texture) {
    setTexture(texture);
    ItemStack textureItem = new ItemStack(Material.DIAMOND_HOE);
    textureItem.setDurability((short) texture);
    ItemMeta am = textureItem.getItemMeta();
    am.setUnbreakable(true);
    am.setDisplayName("&rPanel".replace('&', '�'));
    am.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
    am.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
    textureItem.setItemMeta(am);

    setTextureItem(textureItem);
}
项目:SuperiorCraft    文件:ItemMetaConstruct.java   
public ItemMetaConstruct removeFlags() {
    meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
    meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
    meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
    meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    meta.addItemFlags(ItemFlag.HIDE_PLACED_ON);

    return this;
}
项目:ProjectAres    文件:MapRatingsMatchModule.java   
private ItemStack getOpenButton(MatchPlayer player) {
    ItemStack stack = new ItemStack(Material.HOPPER);
    ItemMeta meta = stack.getItemMeta();
    meta.addItemFlags(ItemFlag.values());
    meta.setDisplayName(BUTTON_PREFIX + ChatColor.BLUE.toString() + ChatColor.BOLD + PGMTranslations.t("rating.rateThisMap", player));
    stack.setItemMeta(meta);
    return stack;
}
项目:ProjectAres    文件:GlobalItemParser.java   
String itemFlagName(ItemFlag flag) {
    switch(flag) {
        case HIDE_ATTRIBUTES: return "attributes";
        case HIDE_ENCHANTS: return "enchantments";
        case HIDE_UNBREAKABLE: return "unbreakable";
        case HIDE_DESTROYS: return "can-destroy";
        case HIDE_PLACED_ON: return "can-place-on";
        case HIDE_POTION_EFFECTS: return "other";
    }
    throw new IllegalStateException("Unknown item flag " + flag);
}
项目:ProjectAres    文件:PickerMatchModule.java   
private ItemStack createLeaveButton(final MatchPlayer player) {
    ItemStack stack = new ItemStack(Button.LEAVE.material);

    ItemMeta meta = stack.getItemMeta();
    meta.addItemFlags(ItemFlag.values());
    meta.setDisplayName(OPEN_BUTTON_PREFIX + PGMTranslations.t("leave.picker.displayName", player));
    meta.setLore(Lists.newArrayList(ChatColor.DARK_PURPLE + PGMTranslations.t("leave.picker.tooltip", player)));

    stack.setItemMeta(meta);
    ITEM_TAG.set(stack, "leave");
    return stack;
}
项目:ProjectAres    文件:PickerMatchModule.java   
private ItemStack createAutoJoinButton(MatchPlayer viewer) {
    ItemStack autojoin = new ItemStack(Button.AUTO_JOIN.material);

    ItemMeta autojoinMeta = autojoin.getItemMeta();
    autojoinMeta.addItemFlags(ItemFlag.values());
    autojoinMeta.setDisplayName(ChatColor.GRAY.toString() + ChatColor.BOLD + PGMTranslations.t("teamSelection.picker.autoJoin.displayName", viewer));
    autojoinMeta.setLore(Lists.newArrayList(this.getTeamSizeDescription(viewer.getMatch().getParticipatingPlayers().size(),
                                                                        viewer.getMatch().getMaxPlayers()),
                                            ChatColor.AQUA + PGMTranslations.t("teamSelection.picker.autoJoin.tooltip", viewer)));
    autojoin.setItemMeta(autojoinMeta);

    return autojoin;
}
项目:ProjectAres    文件:PickerMatchModule.java   
private ItemStack createTeamJoinButton(final MatchPlayer player, final Team team) {
    ItemStack item = new ItemStack(Button.TEAM_JOIN.material);
    String capacityMessage = this.getTeamSizeDescription(team.getPlayers().size(), team.getMaxPlayers());
    List<String> lore = Lists.newArrayList(capacityMessage);

    final JoinResult result = jmm.queryJoin(player, JoinRequest.user(team));
    if(result.isAllowed()) {
        final String label = result.isRejoin() ? "teamSelection.picker.clickToRejoin"
                                               : "teamSelection.picker.clickToJoin";
        lore.add(renderer.renderLegacy(new Component(new TranslatableComponent(label), ChatColor.GREEN), player.getBukkit()));
    } else if(result.message().isPresent()) {
        lore.add(renderer.renderLegacy(new Component(result.message().get(), ChatColor.RED), player.getBukkit()));
        result.extra().forEach(line -> {
            lore.add(renderer.renderLegacy(line, player.getBukkit()));
        });
    }

    LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
    meta.addItemFlags(ItemFlag.values());
    meta.setColor(team.getFullColor());
    meta.setDisplayName(team.getColor().toString() + ChatColor.BOLD + team.getName());
    meta.setLore(lore);
    meta.addItemFlags(ItemFlag.values()); // Hides a lot more than potion effects
    item.setItemMeta(meta);

    return item;
}
项目:ProjectAres    文件:TutorialPlayerFacet.java   
private ItemStack createItem(CommandSender viewer) {
    final ItemStack item = new ItemStack(TUTORIAL_ITEM);
    final ItemMeta meta = item.getItemMeta();
    meta.addItemFlags(ItemFlag.values());
    meta.setDisplayName(renderer.renderLegacy(new Component(new TranslatableComponent("tutorial.displayName"), ChatColor.GOLD, ChatColor.BOLD), viewer));
    meta.setLore(ImmutableList.of(renderer.renderLegacy(new Component(new TranslatableComponent("tutorial.tooltip", mapInfo.getColoredName()), ChatColor.WHITE), viewer)));
    item.setItemMeta(meta);
    return item;
}