Java Code Examples for net.runelite.api.Item#getId()
The following examples show how to use
net.runelite.api.Item#getId() .
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: BankPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private Multiset<Integer> getBankItemSet() { ItemContainer itemContainer = client.getItemContainer(InventoryID.BANK); if (itemContainer == null) { return HashMultiset.create(); } Multiset<Integer> set = HashMultiset.create(); for (Item item : itemContainer.getItems()) { if (item.getId() != ItemID.BANK_FILLER) { set.add(item.getId(), item.getQuantity()); } } return set; }
Example 2
Source File: ZalcanoUtil.java From plugins with GNU General Public License v3.0 | 6 votes |
/** * Courtesy of OP * * @param itemId * @return */ int countStackInInventory(int itemId) { ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY); if (inventory != null) { Item[] items = inventory.getItems(); for (int i = 0; i < 28; ++i) { if (i < items.length) { Item item = items[i]; if (item.getId() >= 0 && item.getId() == itemId) { return item.getQuantity(); } } } } return 0; }
Example 3
Source File: SingleItemRequirement.java From plugins with GNU General Public License v3.0 | 5 votes |
@Override public boolean fulfilledBy(Item[] items) { for (Item item : items) { if (item.getId() == itemId) { return true; } } return false; }
Example 4
Source File: SingleItemRequirement.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean fulfilledBy(Item[] items) { for (Item item : items) { if (item.getId() == itemId) { return true; } } return false; }
Example 5
Source File: CustomSwapper.java From ExternalPlugins with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onCommandExecuted(CommandExecuted event) { if (event.getCommand().equalsIgnoreCase("copycs")) { final ItemContainer e = client.getItemContainer(InventoryID.EQUIPMENT); if (e == null) { log.error("CopyCS: Can't find equipment container."); return; } final StringBuilder sb = new StringBuilder(); for (Item item : e.getItems()) { if (item.getId() == -1 || item.getId() == 0) { continue; } sb.append(item.getId()); sb.append(":"); sb.append("Equip"); sb.append("\n"); } final String string = sb.toString(); Clipboard.store(string); } }
Example 6
Source File: SuppliesTrackerPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
/** * Checks for changes between the provided inventories in runes specifically to add those runes * to the supply tracker * <p> * we can't in general just check for when inventory slots change but this method is only run * immediately after the player performs a cast animation or cast menu click/entry * * @param itemContainer the new inventory * @param oldInv the old inventory */ private void checkUsedRunes(ItemContainer itemContainer, Item[] oldInv) { try { for (int i = 0; i < itemContainer.getItems().length; i++) { Item newItem = itemContainer.getItems()[i]; Item oldItem = oldInv[i]; boolean isRune = false; for (int runeId : RUNE_IDS) { if (oldItem.getId() == runeId) { isRune = true; break; } } if (isRune && (newItem.getId() != oldItem.getId() || newItem.getQuantity() != oldItem.getQuantity())) { int quantity = oldItem.getQuantity(); if (newItem.getId() == oldItem.getId()) { quantity -= newItem.getQuantity(); } // ensure that only positive quantities are added since it is reported // that sometimes checkUsedRunes is called on the same tick that a player // gains runes in their inventory if (quantity > 0 && quantity < 35) { buildEntries(oldItem.getId(), quantity); } } } } catch (IndexOutOfBoundsException ignored) { } }
Example 7
Source File: AmmoPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void updateInfobox(final Item item, final ItemDefinition comp) { if (counterBox != null && counterBox.getItemID() == item.getId()) { counterBox.setCount(item.getQuantity()); return; } removeInfobox(); final BufferedImage image = itemManager.getImage(item.getId(), 5, false); counterBox = new AmmoCounter(this, item.getId(), item.getQuantity(), comp.getName(), image); infoBoxManager.addInfoBox(counterBox); }
Example 8
Source File: BronzeManPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
/** * Unlocks all new items that are currently not unlocked **/ @Subscribe public void onItemContainerChanged(ItemContainerChanged e) { if (config.progressionPaused() && config.hardcoreBronzeMan()) { sendMessage("Your unlocks are still paused due to your dying as a hardcore bronzeman. Type !continue to unpause"); return; } for (Item i : e.getItemContainer().getItems()) { if (i == null) { continue; } if (e.getContainerId() != 93 && e.getContainerId() != 95) { return; //if the inventory or bank is not updated then exit } if (i.getId() <= 1) { continue; } if (i.getQuantity() <= 0) { continue; } if (!unlockedItems.contains(i.getId())) { queueItemUnlock(i.getId()); } } }
Example 9
Source File: RangeItemRequirement.java From plugins with GNU General Public License v3.0 | 5 votes |
@Override public boolean fulfilledBy(Item[] items) { for (Item item : items) { if (item.getId() >= startItemId && item.getId() <= endItemId) { return true; } } return false; }
Example 10
Source File: BankTagsPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onItemContainerChanged(ItemContainerChanged event) { if (event.getContainerId() == InventoryID.BANK.getId()) { itemQuantities.clear(); for (Item item : event.getItemContainer().getItems()) { if (item.getId() != ItemID.BANK_FILLER) { itemQuantities.add(item.getId(), item.getQuantity()); } } } }
Example 11
Source File: FishingPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private boolean canPlayerFish(final ItemContainer itemContainer) { if (itemContainer == null) { return false; } for (Item item : itemContainer.getItems()) { switch (item.getId()) { case ItemID.DRAGON_HARPOON: case ItemID.INFERNAL_HARPOON: case ItemID.INFERNAL_HARPOON_UNCHARGED: case ItemID.HARPOON: case ItemID.BARBTAIL_HARPOON: case ItemID.BIG_FISHING_NET: case ItemID.SMALL_FISHING_NET: case ItemID.SMALL_FISHING_NET_6209: case ItemID.FISHING_ROD: case ItemID.FLY_FISHING_ROD: case ItemID.PEARL_BARBARIAN_ROD: case ItemID.PEARL_FISHING_ROD: case ItemID.PEARL_FLY_FISHING_ROD: case ItemID.BARBARIAN_ROD: case ItemID.OILY_FISHING_ROD: case ItemID.LOBSTER_POT: case ItemID.KARAMBWAN_VESSEL: case ItemID.KARAMBWAN_VESSEL_3159: case ItemID.CORMORANTS_GLOVE: case ItemID.CORMORANTS_GLOVE_22817: return true; } } return false; }
Example 12
Source File: RangeItemRequirement.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean fulfilledBy(Item[] items) { for (Item item : items) { if (item.getId() >= startItemId && item.getId() <= endItemId) { return true; } } return false; }
Example 13
Source File: AmmoPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private void updateInfobox(final Item item, final ItemComposition comp) { if (counterBox != null && counterBox.getItemID() == item.getId()) { counterBox.setCount(item.getQuantity()); return; } removeInfobox(); final BufferedImage image = itemManager.getImage(item.getId(), 5, false); counterBox = new AmmoCounter(this, item.getId(), item.getQuantity(), comp.getName(), image); infoBoxManager.addInfoBox(counterBox); }
Example 14
Source File: TimersPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
/** * Remove SOTD timer and update stamina timer when equipment is changed. */ @Subscribe public void onItemContainerChanged(ItemContainerChanged itemContainerChanged) { if (itemContainerChanged.getContainerId() != InventoryID.EQUIPMENT.getId()) { return; } ItemContainer container = itemContainerChanged.getItemContainer(); Item weapon = container.getItem(EquipmentInventorySlot.WEAPON.getSlotIdx()); if (weapon == null || (weapon.getId() != ItemID.STAFF_OF_THE_DEAD && weapon.getId() != ItemID.TOXIC_STAFF_OF_THE_DEAD && weapon.getId() != ItemID.STAFF_OF_LIGHT && weapon.getId() != ItemID.TOXIC_STAFF_UNCHARGED)) { // remove sotd timer if the staff has been unwielded removeGameTimer(STAFF_OF_THE_DEAD); } if (wasWearingEndurance) { Item ring = container.getItem(EquipmentInventorySlot.RING.getSlotIdx()); // when using the last ring charge the ring changes to the uncharged version, ignore that and don't // halve the timer if (ring == null || (ring.getId() != ItemID.RING_OF_ENDURANCE && ring.getId() != ItemID.RING_OF_ENDURANCE_UNCHARGED_24844)) { wasWearingEndurance = false; if (staminaTimer != null) { // Remaining duration gets divided by 2 Duration remainingDuration = Duration.between(Instant.now(), staminaTimer.getEndTime()).dividedBy(2); // This relies on the chat message to be removed, which could be after the timer has been culled; // so check there is still remaining time if (!remainingDuration.isNegative() && !remainingDuration.isZero()) { log.debug("Halving stamina timer"); staminaTimer.setDuration(remainingDuration); } } } } }
Example 15
Source File: WintertodtPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onItemContainerChanged(ItemContainerChanged event) { final ItemContainer container = event.getItemContainer(); if (!isInWintertodt || container != client.getItemContainer(InventoryID.INVENTORY)) { return; } final Item[] inv = container.getItems(); inventoryScore = 0; totalPotentialinventoryScore = 0; numLogs = 0; numKindling = 0; for (Item item : inv) { inventoryScore += getPoints(item.getId()); totalPotentialinventoryScore += getPotentialPoints(item.getId()); switch (item.getId()) { case BRUMA_ROOT: ++numLogs; break; case BRUMA_KINDLING: ++numKindling; break; } } //If we're currently fletching but there are no more logs, go ahead and abort fletching immediately if (numLogs == 0 && currentActivity == WintertodtActivity.FLETCHING) { currentActivity = WintertodtActivity.IDLE; } //Otherwise, if we're currently feeding the brazier but we've run out of both logs and kindling, abort the feeding activity else if (numLogs == 0 && numKindling == 0 && currentActivity == WintertodtActivity.FEEDING_BRAZIER) { currentActivity = WintertodtActivity.IDLE; } }
Example 16
Source File: RunecraftPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onItemContainerChanged(ItemContainerChanged event) { final ItemContainer container = event.getItemContainer(); if (container == client.getItemContainer(InventoryID.INVENTORY)) { degradedPouchInInventory = false; for (Item item : container.getItems()) { if (!medDegrade && item.getId() == ItemID.MEDIUM_POUCH_5511) { medDegrade = true; mediumCharges = 0; degradedPouchInInventory = true; } else if (!largeDegrade && item.getId() == ItemID.LARGE_POUCH_5513) { largeDegrade = true; largeCharges = 0; degradedPouchInInventory = true; } else if (!giantDegrade && item.getId() == ItemID.GIANT_POUCH_5515) { giantDegrade = true; giantCharges = 0; degradedPouchInInventory = true; } else if (medDegrade && item.getId() == ItemID.MEDIUM_POUCH) { medDegrade = false; mediumCharges = MEDIUM_DEGRADE; } else if (largeDegrade && item.getId() == ItemID.LARGE_POUCH) { largeDegrade = false; largeCharges = LARGE_DEGRADE; } else if (giantDegrade && item.getId() == ItemID.GIANT_POUCH) { giantDegrade = false; giantCharges = GIANT_DEGRADE; } } } }
Example 17
Source File: BankPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Nullable public ContainerPrices calculate(@Nullable Item[] items) { if (items == null) { return null; } long ge = 0; long alch = 0; for (final Item item : items) { final int qty = item.getQuantity(); final int id = item.getId(); if (id <= 0 || qty == 0) { continue; } switch (id) { case ItemID.COINS_995: ge += qty; alch += qty; break; case ItemID.PLATINUM_TOKEN: ge += qty * 1000L; alch += qty * 1000L; break; default: final long storePrice = itemManager.getItemDefinition(id).getPrice(); final long alchPrice = (long) (storePrice * Constants.HIGH_ALCHEMY_MULTIPLIER); alch += alchPrice * qty; ge += (long) itemManager.getItemPrice(id) * qty; break; } } return new ContainerPrices(ge, alch); }
Example 18
Source File: CannonPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onItemContainerChanged(ItemContainerChanged event) { if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY)) { return; } boolean hasBase = false; boolean hasStand = false; boolean hasBarrels = false; boolean hasFurnace = false; boolean hasAll = false; if (!cannonPlaced) { for (Item item : event.getItemContainer().getItems()) { if (item == null) { continue; } switch (item.getId()) { case ItemID.CANNON_BASE: hasBase = true; break; case ItemID.CANNON_STAND: hasStand = true; break; case ItemID.CANNON_BARRELS: hasBarrels = true; break; case ItemID.CANNON_FURNACE: hasFurnace = true; break; } if (hasBase && hasStand && hasBarrels && hasFurnace) { hasAll = true; break; } } } cannonSpotOverlay.setHidden(!hasAll); }
Example 19
Source File: BankTagsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { if (event.getWidgetId() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && event.getMenuAction() == MenuAction.RUNELITE && event.getMenuOption().startsWith(EDIT_TAGS_MENU_OPTION)) { event.consume(); int inventoryIndex = event.getActionParam(); ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK); if (bankContainer == null) { return; } Item[] items = bankContainer.getItems(); if (inventoryIndex < 0 || inventoryIndex >= items.length) { return; } Item item = bankContainer.getItems()[inventoryIndex]; if (item == null) { return; } int itemId = item.getId(); ItemComposition itemComposition = itemManager.getItemComposition(itemId); String name = itemComposition.getName(); // Get both tags and vartags and append * to end of vartags name Collection<String> tags = tagManager.getTags(itemId, false); tagManager.getTags(itemId, true).stream() .map(i -> i + "*") .forEach(tags::add); boolean isSearchOpen = client.getVar(VarClientInt.INPUT_TYPE) == InputType.SEARCH.getType(); String searchText = client.getVar(VarClientStr.INPUT_TEXT); String initialValue = Text.toCSV(tags); chatboxPanelManager.openTextInput(name + " tags:<br>(append " + VAR_TAG_SUFFIX + " for variation tag)") .addCharValidator(FILTERED_CHARS) .value(initialValue) .onDone((Consumer<String>) (newValue) -> clientThread.invoke(() -> { // Split inputted tags to vartags (ending with *) and regular tags final Collection<String> newTags = new ArrayList<>(Text.fromCSV(newValue.toLowerCase())); final Collection<String> newVarTags = new ArrayList<>(newTags).stream().filter(s -> s.endsWith(VAR_TAG_SUFFIX)).map(s -> { newTags.remove(s); return s.substring(0, s.length() - VAR_TAG_SUFFIX.length()); }).collect(Collectors.toList()); // And save them tagManager.setTagString(itemId, Text.toCSV(newTags), false); tagManager.setTagString(itemId, Text.toCSV(newVarTags), true); // Check both previous and current tags in case the tag got removed in new tags or in case // the tag got added in new tags tabInterface.updateTabIfActive(Text.fromCSV(initialValue.toLowerCase().replaceAll(Pattern.quote(VAR_TAG_SUFFIX), ""))); tabInterface.updateTabIfActive(Text.fromCSV(newValue.toLowerCase().replaceAll(Pattern.quote(VAR_TAG_SUFFIX), ""))); })) .build(); if (isSearchOpen) { bankSearch.reset(false); bankSearch.search(InputType.SEARCH, searchText, false); } } else { tabInterface.handleClick(event); } }
Example 20
Source File: PrayerPotion.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Override public int heals(Client client) { boolean hasHolyWrench = false; ItemContainer equipContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (equipContainer != null) { Item cape = equipContainer.getItem(CAPE_SLOT); Item ring = equipContainer.getItem(RING_SLOT); hasHolyWrench = ring != null && ring.getId() == ItemID.RING_OF_THE_GODS_I; if (cape != null) { int capeId = cape.getId(); hasHolyWrench |= capeId == ItemID.PRAYER_CAPE; hasHolyWrench |= capeId == ItemID.PRAYER_CAPET; hasHolyWrench |= capeId == ItemID.PRAYER_CAPE_10643; // No idea what this is hasHolyWrench |= capeId == ItemID.MAX_CAPE; hasHolyWrench |= capeId == ItemID.MAX_CAPE_13282; // Or these hasHolyWrench |= capeId == ItemID.MAX_CAPE_13342; } } if (!hasHolyWrench) { ItemContainer invContainer = client.getItemContainer(InventoryID.INVENTORY); if (invContainer != null) { for (Item itemStack : invContainer.getItems()) { int item = itemStack.getId(); hasHolyWrench = item == ItemID.HOLY_WRENCH; hasHolyWrench |= item == ItemID.PRAYER_CAPE; hasHolyWrench |= item == ItemID.PRAYER_CAPET; hasHolyWrench |= item == ItemID.PRAYER_CAPE_10643; hasHolyWrench |= item == ItemID.MAX_CAPE; hasHolyWrench |= item == ItemID.MAX_CAPE_13282; hasHolyWrench |= item == ItemID.MAX_CAPE_13342; if (hasHolyWrench) { break; } } } } double percent = hasHolyWrench ? perc + .02 : perc; int max = getStat().getMaximum(client); return (((int) (max * percent)) * (delta >= 0 ? 1 : -1)) + delta; }