java类org.bukkit.inventory.ItemFlag的实例源码

ValeUtil.java 文件源码 项目:NetworkCore 阅读 17 收藏 0 点赞 0 评论 0
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);
    }

}
EtcItem.java 文件源码 项目:ZentrelaRPG 阅读 24 收藏 0 点赞 0 评论 0
@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;
}
ItemUtil.java 文件源码 项目:WC 阅读 26 收藏 0 点赞 0 评论 0
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;
}
Inventories.java 文件源码 项目:OMGPI 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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);
}
ItemUtil.java 文件源码 项目:WC 阅读 27 收藏 0 点赞 0 评论 0
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;
}
ItemUtil.java 文件源码 项目:WC 阅读 20 收藏 0 点赞 0 评论 0
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;
}
DefuseListener.java 文件源码 项目:ProjectAres 阅读 28 收藏 0 点赞 0 评论 0
@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);
}
PickerMatchModule.java 文件源码 项目:ProjectAres 阅读 23 收藏 0 点赞 0 评论 0
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;
}
PickerMatchModule.java 文件源码 项目:ProjectAres 阅读 22 收藏 0 点赞 0 评论 0
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;
}
EmpireWandModule.java 文件源码 项目:KingdomFactions 阅读 26 收藏 0 点赞 0 评论 0
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;
    }
SaturationMenu.java 文件源码 项目:FactionsXL 阅读 45 收藏 0 点赞 0 评论 0
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);
}
DemandMenu.java 文件源码 项目:FactionsXL 阅读 25 收藏 0 点赞 0 评论 0
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;
}
ResourceMenu.java 文件源码 项目:FactionsXL 阅读 29 收藏 0 点赞 0 评论 0
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);
}
TradeOfferCommand.java 文件源码 项目:FactionsXL 阅读 22 收藏 0 点赞 0 评论 0
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;
}
LeatherItemBuilder.java 文件源码 项目:AlphaLibary 阅读 29 收藏 0 点赞 0 评论 0
/**
 * 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;
}
ItemBuilder.java 文件源码 项目:AlphaLibary 阅读 26 收藏 0 点赞 0 评论 0
/**
 * 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;
}
GoneFishingModule.java 文件源码 项目:SurvivalAPI 阅读 19 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
SimpleItemFactory.java 文件源码 项目:MiniWynn 阅读 21 收藏 0 点赞 0 评论 0
@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;
}
Picaro.java 文件源码 项目:PA 阅读 20 收藏 0 点赞 0 评论 0
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));
}
ItemUtil.java 文件源码 项目:PA 阅读 22 收藏 0 点赞 0 评论 0
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;
}
CustomItem.java 文件源码 项目:uppercore 阅读 27 收藏 0 点赞 0 评论 0
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()));
        }
    }
}
CustomItem.java 文件源码 项目:uppercore 阅读 24 收藏 0 点赞 0 评论 0
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);
}
GrappleManager.java 文件源码 项目:ZentrelaRPG 阅读 24 收藏 0 点赞 0 评论 0
@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);
}
EquipItem.java 文件源码 项目:ZentrelaRPG 阅读 23 收藏 0 点赞 0 评论 0
@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;
}
PanelItem.java 文件源码 项目:bskyblock 阅读 16 收藏 0 点赞 0 评论 0
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;
            }
        };
    }
}
ItemBuilder.java 文件源码 项目:SparseBukkitAPI 阅读 26 收藏 0 点赞 0 评论 0
/**
 * 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;
}
ItemUtils.java 文件源码 项目:SamaGamesAPI 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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;
}
ItemMaker.java 文件源码 项目:WC 阅读 37 收藏 0 点赞 0 评论 0
public ItemMaker setUnbreakable(){
    ItemMeta meta = this.itemStack.getItemMeta();
    meta.spigot().setUnbreakable(true);
    meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
    this.itemStack.setItemMeta(meta);
    return this;
}
ItemUtil.java 文件源码 项目:WC 阅读 31 收藏 0 点赞 0 评论 0
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;
}
ScrapsUtil.java 文件源码 项目:Locked 阅读 18 收藏 0 点赞 0 评论 0
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);
}


问题


面经


文章

微信
公众号

扫码关注公众号