Java Code Examples for net.runelite.api.events.ItemContainerChanged#getItemContainer()
The following examples show how to use
net.runelite.api.events.ItemContainerChanged#getItemContainer() .
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: PrayerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onItemContainerChanged(final ItemContainerChanged event) { final ItemContainer container = event.getItemContainer(); final ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY); final ItemContainer equipment = client.getItemContainer(InventoryID.EQUIPMENT); if (container == inventory || container == equipment) { doseOverlay.setHasHolyWrench(false); doseOverlay.setHasPrayerRestore(false); doseOverlay.setBonusPrayer(0); if (inventory != null) { checkContainerForPrayer(inventory.getItems()); } if (equipment != null) { prayerBonus = checkContainerForPrayer(equipment.getItems()); } } }
Example 2
Source File: FishingPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onItemContainerChanged(ItemContainerChanged event) { if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY) && event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT)) { return; } final boolean showOverlays = session.getLastFishCaught() != null || canPlayerFish(client.getItemContainer(InventoryID.INVENTORY)) || canPlayerFish(client.getItemContainer(InventoryID.EQUIPMENT)); if (!showOverlays) { currentSpot = null; } spotOverlay.setHidden(!showOverlays); fishingSpotMinimapOverlay.setHidden(!showOverlays); }
Example 3
Source File: GraveyardRoom.java From plugins with GNU General Public License v3.0 | 6 votes |
private void onItemContainerChanged(ItemContainerChanged event) { if (!inside()) { return; } ItemContainer container = event.getItemContainer(); if (container == client.getItemContainer(InventoryID.INVENTORY)) { int score = score(container.getItems()); if (counter == null) { BufferedImage image = itemManager.getImage(ANIMALS_BONES); counter = new GraveyardCounter(image, plugin); infoBoxManager.addInfoBox(counter); } counter.setCount(score); } }
Example 4
Source File: ItemDropper.java From ExternalPlugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onItemContainerChanged(ItemContainerChanged event) { if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY)) { return; } int quant = 0; for (Item item : event.getItemContainer().getItems()) { if (ids.contains(item.getId())) { quant++; } } if (iterating && quant == 0) { iterating = false; clearNames(); } }
Example 5
Source File: FishingPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onItemContainerChanged(ItemContainerChanged event) { if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY) && event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT)) { return; } final boolean showOverlays = session.getLastFishCaught() != null || canPlayerFish(client.getItemContainer(InventoryID.INVENTORY)) || canPlayerFish(client.getItemContainer(InventoryID.EQUIPMENT)); if (!showOverlays) { currentSpot = null; } spotOverlay.setHidden(!showOverlays); fishingSpotMinimapOverlay.setHidden(!showOverlays); }
Example 6
Source File: MotherlodePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe void onItemContainerChanged(ItemContainerChanged event) { final ItemContainer container = event.getItemContainer(); if (!inMlm || !shouldUpdateOres || inventorySnapshot == null || container != client.getItemContainer(InventoryID.INVENTORY)) { return; } // Build set of current inventory Multiset<Integer> current = HashMultiset.create(); Arrays.stream(container.getItems()) .filter(item -> MLM_ORE_TYPES.contains(item.getId())) .forEach(item -> current.add(item.getId(), item.getQuantity())); // Take the difference Multiset<Integer> delta = Multisets.difference(current, inventorySnapshot); // Update the session delta.forEachEntry(session::updateOreFound); inventorySnapshot = null; shouldUpdateOres = false; }
Example 7
Source File: MotherlodePlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onItemContainerChanged(ItemContainerChanged event) { final ItemContainer container = event.getItemContainer(); if (!inMlm || !shouldUpdateOres || inventorySnapshot == null || container != client.getItemContainer(InventoryID.INVENTORY)) { return; } // Build set of current inventory Multiset<Integer> current = HashMultiset.create(); Arrays.stream(container.getItems()) .filter(item -> MLM_ORE_TYPES.contains(item.getId())) .forEach(item -> current.add(item.getId(), item.getQuantity())); // Take the difference Multiset<Integer> delta = Multisets.difference(current, inventorySnapshot); // Update the session delta.forEachEntry(session::updateOreFound); inventorySnapshot = null; shouldUpdateOres = false; }
Example 8
Source File: WintertodtPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onItemContainerChanged(ItemContainerChanged event) { final ItemContainer container = event.getItemContainer(); if (!isInWintertodt || container != client.getItemContainer(InventoryID.INVENTORY)) { return; } final Item[] inv = container.getItems(); numRoots = 0; numKindling = 0; for (Item item : inv) { switch (item.getId()) { case BRUMA_ROOT: ++numRoots; break; case BRUMA_KINDLING: ++numKindling; break; } } //If we're currently fletching but there are no more roots, go ahead and abort fletching immediately if (numRoots == 0 && currentActivity == WintertodtActivity.FLETCHING) { currentActivity = WintertodtActivity.IDLE; } //Otherwise, if we're currently feeding the brazier but we've run out of both roots and kindling, abort the feeding activity else if (numRoots == 0 && numKindling == 0 && currentActivity == WintertodtActivity.FEEDING_BRAZIER) { currentActivity = WintertodtActivity.IDLE; } }
Example 9
Source File: RoguesDenPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onItemContainerChanged(ItemContainerChanged event) { if (event.getContainerId() != InventoryID.INVENTORY.getId()) { return; } ItemContainer itemContainer = event.getItemContainer(); hasGem = itemContainer.contains(ItemID.MYSTIC_JEWEL); }
Example 10
Source File: AmmoPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onItemContainerChanged(ItemContainerChanged event) { if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT)) { return; } checkInventory(event.getItemContainer().getItems()); }
Example 11
Source File: DriftNetPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Subscribe public void onItemContainerChanged(final ItemContainerChanged event) { final ItemContainer itemContainer = event.getItemContainer(); if (itemContainer != client.getItemContainer(InventoryID.INVENTORY)) { return; } driftNetsInInventory = itemContainer.contains(ItemID.DRIFT_NET); }
Example 12
Source File: CannonPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onItemContainerChanged(ItemContainerChanged event) { if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY)) { return; } cannonSpotOverlay.setHidden(!ItemUtil.containsAllItemIds(event.getItemContainer().getItems(), CANNON_PARTS)); }
Example 13
Source File: AmmoPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onItemContainerChanged(ItemContainerChanged event) { if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT)) { return; } checkInventory(event.getItemContainer().getItems()); }
Example 14
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 15
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 16
Source File: ItemChargePlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onItemContainerChanged(ItemContainerChanged event) { if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT) || !config.showInfoboxes()) { return; } final Item[] items = event.getItemContainer().getItems(); if (config.showTeleportCharges()) { updateJewelleryInfobox(ItemWithSlot.TELEPORT, items); } if (config.showDodgyCount()) { updateJewelleryInfobox(ItemWithSlot.DODGY_NECKLACE, items); } if (config.showAbyssalBraceletCharges()) { updateJewelleryInfobox(ItemWithSlot.ABYSSAL_BRACELET, items); } if (config.showSlayerBracelets()) { updateJewelleryInfobox(ItemWithSlot.BRACELET_OF_SLAUGHTER, items); updateJewelleryInfobox(ItemWithSlot.EXPEDITIOUS_BRACELET, items); } if (config.showBindingNecklaceCharges()) { updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, items); } if (config.showExplorerRingCharges()) { updateJewelleryInfobox(ItemWithSlot.EXPLORER_RING, items); } if (config.showRingOfForgingCount()) { updateJewelleryInfobox(ItemWithSlot.RING_OF_FORGING, items); } if (config.showAmuletOfChemistryCharges()) { updateJewelleryInfobox(ItemWithSlot.AMULET_OF_CHEMISTY, items); } if (config.showAmuletOfBountyCharges()) { updateJewelleryInfobox(ItemWithSlot.AMULET_OF_BOUNTY, items); } }
Example 17
Source File: ClueScrollPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe public void onItemContainerChanged(final ItemContainerChanged event) { if (event.getItemContainer() == client.getItemContainer(InventoryID.EQUIPMENT)) { equippedItems = event.getItemContainer().getItems(); return; } if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY)) { return; } inventoryItems = event.getItemContainer().getItems(); // Check if item was removed from inventory if (clue != null && clueItemId != null) { ItemContainer itemContainer = event.getItemContainer(); // Check if clue was removed from inventory if (!itemContainer.contains(clueItemId)) { resetClue(true); } } // if three step clue check for clue scroll pieces if (clue instanceof ThreeStepCrypticClue) { if (((ThreeStepCrypticClue) clue).update(event.getContainerId(), event.getItemContainer())) { worldMapPointsSet = false; npcsToMark.clear(); if (config.displayHintArrows()) { client.clearHintArrow(); } checkClueNPCs(clue, client.getCachedNPCs()); } } }
Example 18
Source File: TimersPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
/** * Remove SOTD timer and update stamina timer when equipment is changed. */ @Subscribe 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 19
Source File: ItemChargePlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Subscribe public void onItemContainerChanged(ItemContainerChanged event) { if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT) || !config.showInfoboxes()) { return; } final Item[] items = event.getItemContainer().getItems(); if (config.showTeleportCharges()) { updateJewelleryInfobox(ItemWithSlot.TELEPORT, items); } if (config.showDodgyCount()) { updateJewelleryInfobox(ItemWithSlot.DODGY_NECKLACE, items); } if (config.showAbyssalBraceletCharges()) { updateJewelleryInfobox(ItemWithSlot.ABYSSAL_BRACELET, items); } if (config.showBindingNecklaceCharges()) { updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, items); } if (config.showExplorerRingCharges()) { updateJewelleryInfobox(ItemWithSlot.EXPLORER_RING, items); } if (config.showRingOfForgingCount()) { updateJewelleryInfobox(ItemWithSlot.RING_OF_FORGING, items); } if (config.showAmuletOfChemistryCharges()) { updateJewelleryInfobox(ItemWithSlot.AMULET_OF_CHEMISTY, items); } if (config.showAmuletOfBountyCharges()) { updateJewelleryInfobox(ItemWithSlot.AMULET_OF_BOUNTY, items); } }
Example 20
Source File: IdleNotifierPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Subscribe private void onItemContainerChanged(ItemContainerChanged event) { ItemContainer itemContainer = event.getItemContainer(); if (itemContainer != client.getItemContainer(InventoryID.INVENTORY) || !config.outOfItemsIdle()) { return; } Item[] items = itemContainer.getItems(); ArrayList<Integer> itemQuantities = new ArrayList<>(); ArrayList<Integer> itemIds = new ArrayList<>(); // Populate list of items in inventory without duplicates for (Item value : items) { int itemId = OutOfItemsMapping.mapFirst(value.getId()); if (itemIds.indexOf(itemId) == -1) // -1 if item not yet in list { itemIds.add(itemId); } } // Populate quantity of each item in inventory for (int j = 0; j < itemIds.size(); j++) { itemQuantities.add(0); for (Item item : items) { if (itemIds.get(j) == OutOfItemsMapping.mapFirst(item.getId())) { itemQuantities.set(j, itemQuantities.get(j) + item.getQuantity()); } } } itemQuantitiesChange.clear(); // Calculate the quantity of each item consumed by the last action if (!itemIdsPrevious.isEmpty()) { for (int i = 0; i < itemIdsPrevious.size(); i++) { int id = itemIdsPrevious.get(i); int currentIndex = itemIds.indexOf(id); int currentQuantity; if (currentIndex != -1) // -1 if item is no longer in inventory { currentQuantity = itemQuantities.get(currentIndex); } else { currentQuantity = 0; } itemQuantitiesChange.add(currentQuantity - itemQuantitiesPrevious.get(i)); } } else { itemIdsPrevious = itemIds; itemQuantitiesPrevious = itemQuantities; return; } // Check we have enough items left for another action. for (int i = 0; i < itemQuantitiesPrevious.size(); i++) { if (-itemQuantitiesChange.get(i) * 2 > itemQuantitiesPrevious.get(i)) { lastTimeItemsUsedUp = Instant.now(); return; } } itemIdsPrevious = itemIds; itemQuantitiesPrevious = itemQuantities; }