/** * Gets the item representation of this block type, if it exists. * * @return The item representation */ @Nullable public ItemType getItemType() { return ItemTypes.get(this.id); }
/** * Set the tool. * * @param item the item type * @param tool the tool to set, which can be {@code null} * @throws InvalidToolBindException if the item can't be bound to that item */ public void setTool(ItemType item, @Nullable Tool tool) throws InvalidToolBindException { if (item.hasBlockType()) { throw new InvalidToolBindException(item, "Blocks can't be used"); } else if (item == ItemTypes.get(config.wandItem)) { throw new InvalidToolBindException(item, "Already used for the wand"); } else if (item == ItemTypes.get(config.navigationWand)) { throw new InvalidToolBindException(item, "Already used for the navigation wand"); } this.tools.put(item, tool); }
@Override public BaseItemStack getItemInHand(HandSide handSide) { Optional<ItemStack> is = this.player.getItemInHand(handSide == HandSide.MAIN_HAND ? HandTypes.MAIN_HAND : HandTypes.OFF_HAND); return is.map(itemStack -> new BaseItemStack(ItemTypes.get(itemStack.getType().getId()))).orElse(null); }
/** * Converts a Material to a ItemType * * @param material The material * @return The itemtype */ public static ItemType asItemType(Material material) { checkNotNull(material); if (!material.isItem()) { throw new IllegalArgumentException(material.getKey().toString() + " is not an item!"); } return ItemTypes.get(material.getKey().toString()); }
try { String id = itemEntry.getKey(); ItemType type = ItemTypes.get(itemEntry.getValue()); itemToStringMap.put(type, id); stringToItemMap.put(id, type);
/** * Create a WorldEdit BaseItemStack from a Bukkit ItemStack * * @param itemStack The Bukkit ItemStack * @return The WorldEdit BaseItemStack */ public static BaseItemStack adapt(ItemStack itemStack) { checkNotNull(itemStack); return new BaseItemStack(ItemTypes.get(itemStack.getType().getKey().toString()), itemStack.getAmount()); }
@Override public BaseItem parseFromInput(String input, ParserContext context) throws InputParseException { BaseItem item = null; // Legacy matcher if (context.isTryingLegacy()) { try { String[] split = input.split(":"); ItemType type; if (split.length == 1) { type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0])); } else { type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]), Integer.parseInt(split[1])); } item = new BaseItem(type); } catch (NumberFormatException e) { } } if (item == null) { ItemType type = ItemTypes.get(input.toLowerCase()); if (type != null) { item = new BaseItem(type); } } if (item == null) { throw new InputParseException("'" + input + "' did not match any item"); } else { return item; } }
@Override public BaseItemStack getItemInHand(HandSide handSide) { ItemStack is = this.player.getHeldItem(handSide == HandSide.MAIN_HAND ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND); return new BaseItemStack(ItemTypes.get(ForgeRegistries.ITEMS.getKey(is.getItem()).toString())); }
@Command( aliases = { "/wand" }, usage = "", desc = "Get the wand object", min = 0, max = 0 ) @CommandPermissions("worldedit.wand") public void wand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { player.giveItem(new BaseItemStack(ItemTypes.get(we.getConfiguration().wandItem), 1)); player.print("Left click: select pos #1; Right click: select pos #2"); }
boolean itemsOnly = args.hasFlag('i'); ItemType type = ItemTypes.get(query);
public TargetMatcher fromInput(String input) throws TargetMatcherParseException { input = input.toLowerCase().trim(); BlockType blockType = BlockTypes.get(input); if (blockType != null) { if (blockType.hasItemType()) { return new ItemBlockMatcher(blockType); } else { return new BlockMatcher(blockType); } } else { ItemType itemType = ItemTypes.get(input); if (itemType == null) { throw new TargetMatcherParseException("Unknown block or item name: " + input); } return new ItemMatcher(itemType); } } }