net.runelite.api.events.ItemContainerChanged Java Examples

The following examples show how to use net.runelite.api.events.ItemContainerChanged. 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: StealingArtefactsPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onItemContainerChanged(ItemContainerChanged event)
{
	if (isConfigSettingEnabled() &&
		!stealingArtefactsHouse.equals(StealingArtefactsHouse.CAPTAIN_KHALED) &&
		event.getContainerId() == InventoryID.INVENTORY.getId() &&
		isPlayerInRegion(REGION_ID_HOUSE) &&
		containsArtefact(event.getItemContainer()))
	{
		resetHouse();
		removeWorldMapPoint();
		removeHintArrow();

		if (displayHintArrow)
		{
			addWorldMapPoint();
			addHintArrow();
		}
	}
}
 
Example #2
Source File: PrayerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 #3
Source File: MotherlodePlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@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 #4
Source File: FishingPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 #5
Source File: LootTrackerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onItemContainerChanged(ItemContainerChanged event)
{
	if (event.getContainerId() != InventoryID.INVENTORY.getId())
	{
		return;
	}

	if (CHEST_EVENT_TYPES.containsValue(eventType)
		|| SHADE_CHEST_OBJECTS.containsValue(eventType)
		|| HALLOWED_SEPULCHRE_COFFIN_EVENT.equals(eventType)
		|| HERBIBOAR_EVENT.equals(eventType)
		|| HESPORI_EVENT.equals(eventType)
		|| SEEDPACK_EVENT.equals(eventType)
		|| CASKET_EVENT.equals(eventType)
		|| lootRecordType == LootRecordType.PICKPOCKET)
	{
		WorldPoint playerLocation = client.getLocalPlayer().getWorldLocation();
		Collection<ItemStack> groundItems = lootManager.getItemSpawns(playerLocation);

		processInventoryLoot(eventType, lootRecordType, event.getItemContainer(), groundItems);
		eventType = null;
		lootRecordType = null;
	}
}
 
Example #6
Source File: MotherlodePlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 #7
Source File: GraveyardRoom.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
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 #8
Source File: ItemDropper.java    From ExternalPlugins with GNU General Public License v3.0 6 votes vote down vote up
@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 #9
Source File: FishingPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@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 #10
Source File: PrayerPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private 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 != null && (container.equals(inventory) || container.equals(equipment)))
	{
		doseOverlay.setHasHolyWrench(false);
		doseOverlay.setHasPrayerRestore(false);
		doseOverlay.setBonusPrayer(0);

		if (inventory != null)
		{
			checkContainerForPrayer(inventory.getItems());
		}

		if (equipment != null)
		{
			prayerBonus = checkContainerForPrayer(equipment.getItems());
		}

	}
}
 
Example #11
Source File: GraveyardRoom.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onItemContainerChanged(ItemContainerChanged event)
{
	if (!inside())
	{
		return;
	}

	ItemContainer container = event.getItemContainer();

	if (container == client.getItemContainer(InventoryID.INVENTORY))
	{
		this.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 #12
Source File: LeftClickCast.java    From ExternalPlugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onItemContainerChanged(ItemContainerChanged event)
{
	final ItemContainer ic = event.getItemContainer();

	if (client.getItemContainer(InventoryID.EQUIPMENT) != ic)
	{
		return;
	}

	isMage = false;

	for (Item item : ic.getItems())
	{
		final String name = client.getItemDefinition(item.getId()).getName().toLowerCase();
		if (name.contains("staff") || name.contains("wand"))
		{
			isMage = true;
			break;
		}
	}

	if (config.disableStaffChecks())
	{
		isMage = true;
	}
}
 
Example #13
Source File: WintertodtPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@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 #14
Source File: AmmoPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onItemContainerChanged(ItemContainerChanged event)
{
	if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT))
	{
		return;
	}

	checkInventory(event.getItemContainer().getItems());
}
 
Example #15
Source File: CustomCursorPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onItemContainerChanged(ItemContainerChanged event)
{
	if (config.selectedCursor() == CustomCursor.EQUIPPED_WEAPON && event.getContainerId() == InventoryID.EQUIPMENT.getId())
	{
		updateCursor();
	}
}
 
Example #16
Source File: DriftNetPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #17
Source File: CustomCursorPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onItemContainerChanged(ItemContainerChanged event)
{
	if (config.selectedCursor() == CustomCursor.EQUIPPED_WEAPON && event.getContainerId() == InventoryID.EQUIPMENT.getId())
	{
		updateCursor();
	}
}
 
Example #18
Source File: BankPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onItemContainerChanged(ItemContainerChanged event)
{
	int containerId = event.getContainerId();

	if (containerId == InventoryID.BANK.getId())
	{
		itemQuantities = null;
	}
	else if (containerId == InventoryID.SEED_VAULT.getId() && config.seedVaultValue())
	{
		updateSeedVaultTotal();
	}
}
 
Example #19
Source File: RoguesDenPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onItemContainerChanged(ItemContainerChanged event)
{
	if (event.getContainerId() != InventoryID.INVENTORY.getId())
	{
		return;
	}

	hasGem = ItemUtil.containsItemId(event.getItemContainer().getItems(), MYSTIC_JEWEL);
}
 
Example #20
Source File: CannonPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onItemContainerChanged(ItemContainerChanged event)
{
	if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY))
	{
		return;
	}

	cannonSpotOverlay.setHidden(!ItemUtil.containsAllItemIds(event.getItemContainer().getItems(), CANNON_PARTS));
}
 
Example #21
Source File: AmmoPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onItemContainerChanged(ItemContainerChanged event)
{
	if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT))
	{
		return;
	}

	checkInventory(event.getItemContainer().getItems());
}
 
Example #22
Source File: RunecraftPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onItemContainerChanged(ItemContainerChanged event)
{
	if (event.getContainerId() != InventoryID.INVENTORY.getId())
	{
		return;
	}

	final Item[] items = event.getItemContainer().getItems();
	degradedPouchInInventory = Stream.of(items).anyMatch(i -> DEGRADED_POUCHES.contains(i.getId()));
}
 
Example #23
Source File: RoguesDenPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onItemContainerChanged(ItemContainerChanged event)
{
	if (event.getContainerId() != InventoryID.INVENTORY.getId())
	{
		return;
	}

	ItemContainer itemContainer = event.getItemContainer();
	hasGem = itemContainer.contains(ItemID.MYSTIC_JEWEL);
}
 
Example #24
Source File: BankTagsPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@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 #25
Source File: BankPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onItemContainerChanged(ItemContainerChanged event)
{
	int containerId = event.getContainerId();

	if (containerId == InventoryID.BANK.getId())
	{
		itemQuantities = null;
	}
	else if (containerId == InventoryID.SEED_VAULT.getId() && config.seedVaultValue())
	{
		updateSeedVaultTotal();
	}
}
 
Example #26
Source File: BronzeManPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #27
Source File: DriftNetPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@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 #28
Source File: CannonPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@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 #29
Source File: WintertodtPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@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 #30
Source File: MotherlodePluginTest.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Test
public void testOreCounter()
{
	// set inMlm
	GameStateChanged gameStateChanged = new GameStateChanged();
	gameStateChanged.setGameState(GameState.LOADING);
	motherlodePlugin.onGameStateChanged(gameStateChanged);

	// Initial sack count
	when(client.getVar(Varbits.SACK_NUMBER)).thenReturn(42);
	motherlodePlugin.onVarbitChanged(new VarbitChanged());

	// Create before inventory
	ItemContainer inventory = mock(ItemContainer.class);
	Item[] items = new Item[]{
		item(ItemID.RUNITE_ORE, 1),
		item(ItemID.GOLDEN_NUGGET, 4),
		item(ItemID.COAL, 1),
		item(ItemID.COAL, 1),
		item(ItemID.COAL, 1),
		item(ItemID.COAL, 1),

	};
	when(inventory.getItems())
		.thenReturn(items);
	when(client.getItemContainer(InventoryID.INVENTORY)).thenReturn(inventory);

	// Withdraw 20
	when(client.getVar(Varbits.SACK_NUMBER)).thenReturn(22);
	motherlodePlugin.onVarbitChanged(new VarbitChanged());

	inventory = mock(ItemContainer.class);
	// +1 rune, +4 nugget, +2 coal, +1 addy
	items = new Item[]{
		item(ItemID.RUNITE_ORE, 1),
		item(ItemID.RUNITE_ORE, 1),
		item(ItemID.GOLDEN_NUGGET, 8),
		item(ItemID.COAL, 1),
		item(ItemID.COAL, 1),
		item(ItemID.COAL, 1),
		item(ItemID.COAL, 1),
		item(ItemID.COAL, 1),
		item(ItemID.COAL, 1),
		item(ItemID.ADAMANTITE_ORE, 1),

	};
	when(inventory.getItems())
		.thenReturn(items);
	when(client.getItemContainer(InventoryID.INVENTORY)).thenReturn(inventory);

	// Trigger comparison
	motherlodePlugin.onItemContainerChanged(new ItemContainerChanged(InventoryID.INVENTORY.getId(), inventory));

	verify(motherlodeSession).updateOreFound(ItemID.RUNITE_ORE, 1);
	verify(motherlodeSession).updateOreFound(ItemID.GOLDEN_NUGGET, 4);
	verify(motherlodeSession).updateOreFound(ItemID.COAL, 2);
	verify(motherlodeSession).updateOreFound(ItemID.ADAMANTITE_ORE, 1);
	verifyNoMoreInteractions(motherlodeSession);
}