org.bukkit.inventory.ItemFlag Java Examples
The following examples show how to use
org.bukkit.inventory.ItemFlag.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PickerMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
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; }
Example #2
Source File: ItemData.java From Skript with GNU General Public License v3.0 | 6 votes |
/** * Applies an item meta to this item. Currently, it copies the following, * provided that they exist in given meta: * <ul> * <li>Lore * <li>Display name * <li>Enchantments * <li>Item flags * </ul> * @param meta Item meta. */ public void applyMeta(ItemMeta meta) { ItemMeta our = getItemMeta(); if (meta.hasLore()) our.setLore(meta.getLore()); if (meta.hasDisplayName()) our.setDisplayName(meta.getDisplayName()); if (meta.hasEnchants()) { for (Map.Entry<Enchantment, Integer> entry : meta.getEnchants().entrySet()) { our.addEnchant(entry.getKey(), entry.getValue(), true); } } for (ItemFlag flag : meta.getItemFlags()) { our.addItemFlags(flag); } setItemMeta(meta); }
Example #3
Source File: KitParser.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
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); }
Example #4
Source File: Item.java From TrMenu with MIT License | 6 votes |
public Item(List<String> names, List<Mat> materials, List<List<String>> lores, List<List<Integer>> slots, List<ItemFlag> itemFlags, NBTCompound nbtCompound, String shiny, String amount) { this.names = names; this.materials = materials; this.lores = lores; this.rawSlots = slots; this.itemFlags = itemFlags; this.nbtCompound = nbtCompound; this.shiny = shiny; this.amount = amount; this.finalShiny = Boolean.parseBoolean(shiny); this.finalAmount = NumberUtils.toInt(amount, -1); this.curSlots = new HashMap<>(); this.slots = new HashMap<>(); this.indexMap = new HashMap<>(); this.updateNbt = PlaceholderAPI.containsPlaceholders(nbtCompound.toJsonSimplified()); }
Example #5
Source File: ItemBuilder.java From Crazy-Crates with MIT License | 6 votes |
private ItemStack addGlow(ItemStack item) { if (glowing) { try { if (item != null) { if (item.hasItemMeta()) { if (item.getItemMeta().hasEnchants()) { return item; } } item.addUnsafeEnchantment(Enchantment.LUCK, 1); ItemMeta meta = item.getItemMeta(); meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); item.setItemMeta(meta); } return item; } catch (NoClassDefFoundError e) { return item; } } return item; }
Example #6
Source File: BuildersWandListener.java From MineTinker with GNU General Public License v3.0 | 6 votes |
private static ItemStack buildersWandCreator(Material m, String name) { //TODO: Modify to implement Modifiers ItemStack wand = new ItemStack(m, 1); ItemMeta meta = wand.getItemMeta(); if (meta != null) { ArrayList<String> lore = new ArrayList<>(); if (config.getBoolean("OverrideLanguagesystem")) { lore.add(ChatWriter.addColors(config.getString("Description"))); } else { lore.add(LanguageManager.getString("Builderswand.Description")); } meta.setLore(lore); meta.setDisplayName(ChatWriter.addColors(name)); meta.addItemFlags(ItemFlag.HIDE_DESTROYS); wand.setItemMeta(meta); } //TODO: DataHandler.setStringList(wand, "CanDestroy", true, "minecraft:air"); DataHandler.setTag(wand, "identifier_builderswand", 0, PersistentDataType.INTEGER, false); return wand; }
Example #7
Source File: Reinforced.java From MineTinker with GNU General Public License v3.0 | 6 votes |
@Override public boolean applyMod(Player player, ItemStack tool, boolean isCommand) { ItemMeta meta = tool.getItemMeta(); if (meta != null) { meta.addEnchant(Enchantment.DURABILITY, modManager.getModLevel(tool, this), true); if (modManager.getModLevel(tool, this) == this.getMaxLvl() && this.applyUnbreakableOnMaxLevel) { meta.setUnbreakable(true); if (hideUnbreakableFlag) { meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE); } } tool.setItemMeta(meta); } return true; }
Example #8
Source File: SlimefunLocalization.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
public ItemStack getRecipeTypeItem(Player p, RecipeType recipeType) { Language language = getLanguage(p); ItemStack item = recipeType.toItem(); NamespacedKey key = recipeType.getKey(); if (language.getRecipeTypesFile() == null || !language.getRecipeTypesFile().contains(key.getNamespace() + "." + key.getKey())) { language = getLanguage("en"); } if (!language.getRecipeTypesFile().contains(key.getNamespace() + "." + key.getKey())) { return item; } FileConfiguration config = language.getRecipeTypesFile(); return new CustomItem(item, meta -> { meta.setDisplayName(ChatColor.AQUA + config.getString(key.getNamespace() + "." + key.getKey() + ".name")); List<String> lore = config.getStringList(key.getNamespace() + "." + key.getKey() + ".lore"); lore.replaceAll(line -> ChatColor.GRAY + line); meta.setLore(lore); meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); }); }
Example #9
Source File: ModManager.java From MineTinker with GNU General Public License v3.0 | 6 votes |
public @NotNull ItemStack createModifierItem(@NotNull Material m, @NotNull String name, @NotNull String description, @NotNull Modifier mod) { ItemStack is = new ItemStack(m, 1); ItemMeta meta = is.getItemMeta(); if (meta != null) { meta.setDisplayName(name); ArrayList<String> lore = new ArrayList<>(ChatWriter.splitString(description, 40)); meta.setLore(lore); meta.addItemFlags(ItemFlag.HIDE_PLACED_ON); is.setItemMeta(meta); } DataHandler.setTag(is, "modifier_item", mod.getKey(), PersistentDataType.STRING, false); //TODO: DataHandler.setStringList(is, "CanPlaceOn", true, "minecraft:air"); return is; }
Example #10
Source File: CVItem.java From Civs with GNU General Public License v3.0 | 6 votes |
public ItemStack createItemStack() { if (mmoItemType != null && mmoItemName != null && Civs.mmoItems != null) { Type mmoType = Civs.mmoItems.getTypes().get(mmoItemType); MMOItem mmoItem = Civs.mmoItems.getItems().getMMOItem(mmoType, mmoItemName); ItemStack itemStack = mmoItem.newBuilder().build(); if (displayName != null) { itemStack.getItemMeta().setDisplayName(displayName); } if (!lore.isEmpty()) { itemStack.getItemMeta().setLore(lore); } itemStack.setAmount(qty); return itemStack; } ItemStack is = new ItemStack(mat, qty); if (displayName != null || (lore != null && !lore.isEmpty())) { if (!is.hasItemMeta()) { is.setItemMeta(Bukkit.getItemFactory().getItemMeta(is.getType())); } ItemMeta im = is.getItemMeta(); if (displayName != null) { im.setDisplayName(displayName); } if (lore == null) { lore = new ArrayList<>(); } else if (!lore.isEmpty()) { im.setLore(lore); } im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); is.setItemMeta(im); } return is; }
Example #11
Source File: TMap.java From TabooLib with MIT License | 6 votes |
public static ItemStack parseItem(String source) { TMap map = TMap.parse(source); ItemBuilder builder = new ItemBuilder(Items.asMaterial(map.get("material", "m", "type", "t"))) .amount(map.getInt(new String[]{"amount", "a"}, 1)) .damage(map.getInt("damage", "data", "d")) .name(map.get("displayname", "display", "name", "n")); if (map.getBoolean("shiny", "glowing", "glow")) { builder.shiny(); } if (map.get("lore", "l") != null) { builder.lore(map.get("lore", "l").split("\\n")); } if (map.get("flag", "f") != null) { builder.flags(Arrays.stream(map.get("flag", "f").split("\\n")).map(Items::asItemFlag).filter(Objects::nonNull).toArray(ItemFlag[]::new)); } return builder.colored().build(); }
Example #12
Source File: PickerMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
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; }
Example #13
Source File: LugolsIodinePotion.java From CraftserveRadiation with Apache License 2.0 | 6 votes |
public PotionMeta convert(PotionMeta potionMeta) { Objects.requireNonNull(potionMeta, "potionMeta"); Duration duration = this.config.duration(); String formattedDuration = this.formatDuration(this.config.duration()); if (this.config.color != null) { potionMeta.setColor(this.config.color); } potionMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); potionMeta.setDisplayName(ChatColor.AQUA + this.config.name()); potionMeta.setLore(Collections.singletonList(ChatColor.BLUE + MessageFormat.format(this.config.description(), formattedDuration))); PersistentDataContainer container = potionMeta.getPersistentDataContainer(); container.set(this.potionKey, PersistentDataType.BYTE, TRUE); container.set(this.durationSecondsKey, PersistentDataType.INTEGER, (int) duration.getSeconds()); return potionMeta; }
Example #14
Source File: CustomItem.java From AdditionsAPI with MIT License | 5 votes |
/** * Set whether the unbreakable tag in the item lore will be visible or not. If * it is set true, then the tag will be visible. If it is set to be hidden then * the CustomItem includes the ItemFlag HIDE_UNBREAKABLE */ public CustomItem setUnbreakableVisibility(boolean unbreakableVisibility) { if (!unbreakableVisibility) itemFlags.add(ItemFlag.HIDE_UNBREAKABLE); else itemFlags.remove(ItemFlag.HIDE_UNBREAKABLE); return this; }
Example #15
Source File: CustomItem.java From AdditionsAPI with MIT License | 5 votes |
/** * Set whether the text that shows on which blocks this can be placed on in the * item lore is visible or not. If it is true, then the tag is visible. If it is * invisible then the CustomItem includes the ItemFlag HIDE_PLACED_ON */ public CustomItem setCanBePlacedVisibility(boolean canBePlacedVisibility) { if (!canBePlacedVisibility) itemFlags.add(ItemFlag.HIDE_PLACED_ON); else itemFlags.remove(ItemFlag.HIDE_PLACED_ON); return this; }
Example #16
Source File: CustomItem.java From AdditionsAPI with MIT License | 5 votes |
/** * Set whether the text that shows the potion effect this item will include when * consumed in the item lore is visible or not. If it is true, then the tag is * visible. If it is invisible then the CustomItem includes the ItemFlag * HIDE_POTION_EFFECTS */ public CustomItem setPotionEffectsVisibility(boolean potionEffectVisibility) { if (!potionEffectVisibility) itemFlags.add(ItemFlag.HIDE_POTION_EFFECTS); else itemFlags.remove(ItemFlag.HIDE_POTION_EFFECTS); return this; }
Example #17
Source File: ItemBuilder.java From Crazy-Crates with MIT License | 5 votes |
public ItemBuilder addItemFlags(List<String> flagStrings) { for (String flagString : flagStrings) { try { ItemFlag itemFlag = ItemFlag.valueOf(flagString.toUpperCase()); if (itemFlag != null) { addItemFlag(itemFlag); } } catch (Exception e) { } } return this; }
Example #18
Source File: ItemBuilder.java From Crazy-Crates with MIT License | 5 votes |
public ItemBuilder addItemFlag(String flagString) { try { addItemFlag(ItemFlag.valueOf(flagString.toUpperCase())); } catch (Exception e) { } return this; }
Example #19
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
public ItemStack getItemStack(Material material, List<String> lore, String message) { ItemStack addItem = new ItemStack(material, 1); ItemMeta addItemMeta = addItem.getItemMeta(); addItemMeta.setDisplayName(message); addItemMeta.setLore(lore); addItemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); addItemMeta.addItemFlags(ItemFlag.HIDE_DESTROYS); addItemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); addItemMeta.addItemFlags(ItemFlag.HIDE_PLACED_ON); addItemMeta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE); addItemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); addItem.setItemMeta(addItemMeta); return addItem; }
Example #20
Source File: Items.java From CardinalPGM with MIT License | 5 votes |
public static ItemStack createItem(Material material, int amount, short data, String name, List<String> lore) { ItemStack item = new ItemStack(material, amount, data); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(name); meta.setLore(lore); meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_POTION_EFFECTS); item.setItemMeta(meta); return item; }
Example #21
Source File: JsonItemUtils.java From UhcCore with GNU General Public License v3.0 | 5 votes |
private static ItemMeta parseFlags(ItemMeta meta, JsonArray jsonArray){ for (JsonElement jsonElement : jsonArray){ ItemFlag flag = ItemFlag.valueOf(jsonElement.getAsString()); meta.addItemFlags(flag); } return meta; }
Example #22
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getItemStack(ItemStack item, List<String> lore, String message) { ItemStack addItem = item.clone(); ItemMeta addItemMeta = addItem.getItemMeta(); addItemMeta.setDisplayName(message); addItemMeta.setLore(lore); addItemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); addItemMeta.addItemFlags(ItemFlag.HIDE_DESTROYS); addItemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); addItemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); addItemMeta.addItemFlags(ItemFlag.HIDE_PLACED_ON); addItemMeta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE); addItem.setItemMeta(addItemMeta); return addItem; }
Example #23
Source File: ItemService.java From Transport-Pipes with MIT License | 5 votes |
public ItemStack createGlowingItem(Material material) { ItemStack is = new ItemStack(material); ItemMeta im = is.getItemMeta(); im.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, true); im.addItemFlags(ItemFlag.HIDE_ENCHANTS); is.setItemMeta(im); return is; }
Example #24
Source File: NavigatorInterface.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
private ItemStack createOpenButton(Player player) { return buttonManager.createButton(openButtonListener, itemBuilders.create(player, openButtonIcon) .flags(ItemFlag.values()) .name(new Component(title, ChatColor.AQUA, ChatColor.BOLD)) .get()); }
Example #25
Source File: FreezeListener.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler public void giveKit(final ObserverKitApplyEvent event) { if(event.getPlayer().hasPermission(Freeze.PERMISSION)) { ItemStack item = new ItemStack(Material.ICE); ItemMeta meta = item.getItemMeta(); meta.addItemFlags(ItemFlag.values()); meta.setDisplayName(Translations.get().t("freeze.itemName", event.getPlayer())); meta.setLore(Collections.singletonList(Translations.get().t("freeze.itemDescription", event.getPlayer()))); item.setItemMeta(meta); event.getPlayer().getInventory().setItem(6, item); } }
Example #26
Source File: Version_1_8.java From CratesPlus with GNU General Public License v3.0 | 5 votes |
public ItemMeta handleItemFlags(ItemMeta itemMeta, List<String> flags) { if (flags.size() > 0) { for (String flag : flags) { try { ItemFlag itemFlag = ItemFlag.valueOf(flag.toUpperCase()); if (itemFlag != null) { itemMeta.addItemFlags(itemFlag); } } catch (Exception ignored) { } } } return itemMeta; }
Example #27
Source File: PickerMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
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; }
Example #28
Source File: PickerMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
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; }
Example #29
Source File: Utils.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
public static ItemStack makeItemHidden(XMaterial material, int amount, String name, List<String> lore) { ItemStack item = material.parseItem(true); if (item == null) return null; item.setAmount(amount); ItemMeta m = item.getItemMeta(); m.setLore(Utils.color(lore)); m.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_UNBREAKABLE); m.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); item.setItemMeta(m); return item; }
Example #30
Source File: ItemUtils.java From FunnyGuilds with Apache License 2.0 | 5 votes |
private static ItemFlag matchItemFlag(String flagName) { for (ItemFlag flag : ItemFlag.values()) { if (flag.name().equalsIgnoreCase(flagName)) { return flag; } } return null; }