Skip to content

Commit

Permalink
Merge pull request #65 from adamk33n3r/64-inventory-fullempty-not-wor…
Browse files Browse the repository at this point in the history
…king-properly

fix: Filter out the items with -1 id when checking for amount
  • Loading branch information
adamk33n3r authored May 5, 2023
2 parents 51f7b27 + 22645cc commit 383675b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions src/main/java/com/adamk33n3r/runelite/watchdog/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemComposition;
import net.runelite.api.ObjectComposition;
import net.runelite.api.Skill;
Expand Down Expand Up @@ -259,17 +260,19 @@ private void onItemContainerChanged(ItemContainerChanged itemContainerChanged) {
.filter(alert -> alert instanceof InventoryAlert)
.map(alert -> (InventoryAlert) alert)
.forEach(inventoryAlert -> {
if (inventoryAlert.getInventoryAlertType() == InventoryAlert.InventoryAlertType.FULL && itemContainerChanged.getItemContainer().getItems().length == 28) {
Item[] items = itemContainerChanged.getItemContainer().getItems();
long itemCount = Arrays.stream(items).filter(item -> item.getId() > -1).count();
if (inventoryAlert.getInventoryAlertType() == InventoryAlert.InventoryAlertType.FULL && itemCount == 28) {
this.fireAlert(inventoryAlert, inventoryAlert.getInventoryAlertType().getName());
} else if (inventoryAlert.getInventoryAlertType() == InventoryAlert.InventoryAlertType.EMPTY && itemContainerChanged.getItemContainer().getItems().length == 0) {
} else if (inventoryAlert.getInventoryAlertType() == InventoryAlert.InventoryAlertType.EMPTY && itemCount == 0) {
this.fireAlert(inventoryAlert, inventoryAlert.getInventoryAlertType().getName());
} else if (inventoryAlert.getInventoryAlertType() == InventoryAlert.InventoryAlertType.ITEM) {
Map<Integer, Integer> allItems = new HashMap<>();
Arrays.stream(itemContainerChanged.getItemContainer().getItems())
Arrays.stream(items)
.forEach(item -> allItems.merge(item.getId(), item.getQuantity(), Integer::sum));
allItems.entrySet().stream()
.filter(itemCount -> inventoryAlert.getItemQuantity() == 0 || itemCount.getValue() == inventoryAlert.getItemQuantity())
.map(itemCount -> this.matchPattern(inventoryAlert, this.itemManager.getItemComposition(itemCount.getKey()).getName()))
.filter(itemWithCount -> inventoryAlert.getItemQuantity() == 0 || itemWithCount.getValue() == inventoryAlert.getItemQuantity())
.map(itemWithCount -> this.matchPattern(inventoryAlert, this.itemManager.getItemComposition(itemWithCount.getKey()).getName()))
.filter(Objects::nonNull)
.findFirst()
.ifPresent(groups -> this.fireAlert(inventoryAlert, groups));
Expand Down Expand Up @@ -332,7 +335,6 @@ private void onDecorativeObjectDespawned(DecorativeObjectDespawned decorativeObj

@Subscribe
private void onGameObjectSpawned(GameObjectSpawned gameObjectSpawned) {
System.out.println(this.client.getObjectDefinition(gameObjectSpawned.getGameObject().getId()).getName());
this.onTileObjectSpawned(gameObjectSpawned.getGameObject(), SPAWNED, GAME_OBJECT);
}
@Subscribe
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Apr 27 04:00:59 EDT 2023
VERSION_BUILD=2082
#Fri May 05 17:14:20 EDT 2023
VERSION_BUILD=2088
VERSION_PHASE=release
VERSION_MAJOR=2
VERSION_MINOR=10
VERSION_PATCH=0
VERSION_PATCH=1

0 comments on commit 383675b

Please sign in to comment.