From 28e736a9aa73ea5cf23c597ac9f72c76089327f7 Mon Sep 17 00:00:00 2001 From: Nabil Zaman Date: Thu, 12 Mar 2026 15:47:55 -0700 Subject: [PATCH 1/2] Implemented primary functionality Still validating via playtesting. --- .../duckblade/osrs/sailing/SailingConfig.java | 12 +++++ .../features/facilities/CargoHoldTracker.java | 53 ++++++++++++++++--- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/duckblade/osrs/sailing/SailingConfig.java b/src/main/java/com/duckblade/osrs/sailing/SailingConfig.java index 25968c9f..ca73fe80 100644 --- a/src/main/java/com/duckblade/osrs/sailing/SailingConfig.java +++ b/src/main/java/com/duckblade/osrs/sailing/SailingConfig.java @@ -865,6 +865,18 @@ default Color cargoHoldColourFull() return Color.RED; } + @ConfigItem( + keyName = "cargoHoldFullNotification", + name = "Notify when full", + description = "Notify when your cargo hold becomes full.", + section = SECTION_CARGO_HOLD_TRACKING, + position = 2 + ) + default Notification cargoHoldFullNotification() + { + return Notification.OFF; + } + @ConfigItem( keyName = "notifyGiantClamSpawn", name = "Notify on Giant clam", diff --git a/src/main/java/com/duckblade/osrs/sailing/features/facilities/CargoHoldTracker.java b/src/main/java/com/duckblade/osrs/sailing/features/facilities/CargoHoldTracker.java index 923ee1dc..33b7cd01 100644 --- a/src/main/java/com/duckblade/osrs/sailing/features/facilities/CargoHoldTracker.java +++ b/src/main/java/com/duckblade/osrs/sailing/features/facilities/CargoHoldTracker.java @@ -43,7 +43,9 @@ import net.runelite.api.gameval.ItemID; import net.runelite.api.gameval.VarbitID; import net.runelite.api.widgets.Widget; +import net.runelite.client.Notifier; import net.runelite.client.config.ConfigManager; +import net.runelite.client.config.Notification; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.RuneScapeProfileChanged; import net.runelite.client.ui.overlay.Overlay; @@ -101,6 +103,7 @@ public class CargoHoldTracker private final ConfigManager configManager; private final BoatTracker boatTracker; private final CourierTaskTracker courierTaskTracker; + private final Notifier notifier; // boat slot -> item id+count private final Map> cargoHoldItems = new HashMap<>(); @@ -119,13 +122,18 @@ public class CargoHoldTracker private int lastXp; private boolean pendingJenkinsAction; + private Notification fullNotification; + private boolean wasFull; + private int lastCheckedBoatSlot = -1; + @Inject - public CargoHoldTracker(Client client, ConfigManager configManager, BoatTracker boatTracker, CourierTaskTracker courierTaskTracker) + public CargoHoldTracker(Client client, ConfigManager configManager, BoatTracker boatTracker, CourierTaskTracker courierTaskTracker, Notifier notifier) { this.client = client; this.configManager = configManager; this.boatTracker = boatTracker; this.courierTaskTracker = courierTaskTracker; + this.notifier = notifier; setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); @@ -138,6 +146,7 @@ public boolean isEnabled(SailingConfig config) overlayEnabled = config.cargoHoldShowCounts(); colourEmpty = config.cargoHoldColourEmpty(); colourFull = config.cargoHoldColourFull(); + fullNotification = config.cargoHoldFullNotification(); return true; } @@ -158,6 +167,8 @@ public void shutDown() cargoHoldItems.clear(); memoizedInventory = null; pendingJenkinsAction = false; + wasFull = false; + lastCheckedBoatSlot = -1; } @Override @@ -210,14 +221,14 @@ public void onOverheadTextChanged(OverheadTextChanged e) // todo different ones? doesn't matter now since it's count only but will matter later log.trace("crewmate salvage"); add(ItemID.SAILING_SMALL_SHIPWRECK_SALVAGE, 1); - writeToConfig(); + onCargoStateUpdated(); return; } if (MSG_CREWMATE_SALVAGE_FULL.equals(e.getOverheadText())) { set(UNKNOWN_ITEM, maxCapacity() - usedCapacity()); - writeToConfig(); + onCargoStateUpdated(); return; } @@ -236,7 +247,7 @@ public void onStatChanged(StatChanged e) { log.trace("jenkins salvage"); add(ItemID.SAILING_SMALL_SHIPWRECK_SALVAGE, 1); - writeToConfig(); + onCargoStateUpdated(); } } @@ -275,7 +286,7 @@ public void onItemContainerChanged(ItemContainerChanged e) } log.debug("read cargo hold inventory from event {}", trackedInv); - writeToConfig(); + onCargoStateUpdated(); } @Subscribe @@ -320,7 +331,7 @@ public void onGameTick(GameTick e) deposited.entrySet().forEach(entry -> cargoHoldToUpdate.add(entry.getElement(), entry.getCount())); log.debug("updated cargo hold from inventory delta {}", cargoHoldToUpdate); - writeToConfig(); + onCargoStateUpdated(); } @Subscribe @@ -464,6 +475,10 @@ private void loadAllFromConfig() loadFromConfig(boatSlot); } } + + int max = maxCapacity(); + wasFull = max > 0 && usedCapacity() >= max; + lastCheckedBoatSlot = currentBoatSlot(); } private void loadFromConfig(int boatSlot) @@ -479,6 +494,32 @@ private void loadFromConfig(int boatSlot) } } + private void onCargoStateUpdated() + { + writeToConfig(); + checkFull(); + } + + private void checkFull() + { + int max = maxCapacity(); + int boatSlot = currentBoatSlot(); + boolean isFull = max > 0 && usedCapacity() >= max; + + if (boatSlot != lastCheckedBoatSlot) + { + lastCheckedBoatSlot = boatSlot; + wasFull = isFull; + return; + } + + if (isFull && !wasFull) + { + notifier.notify(fullNotification, "Your cargo hold is full!"); + } + wasFull = isFull; + } + private void writeToConfig() { writeToConfig(currentBoatSlot()); From ae9618db8f96bd65fe84e6e79770882b15c49434 Mon Sep 17 00:00:00 2001 From: Nabil Zaman Date: Thu, 12 Mar 2026 18:20:02 -0700 Subject: [PATCH 2/2] Remove startup changes causing crash. --- .../osrs/sailing/features/facilities/CargoHoldTracker.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/duckblade/osrs/sailing/features/facilities/CargoHoldTracker.java b/src/main/java/com/duckblade/osrs/sailing/features/facilities/CargoHoldTracker.java index 33b7cd01..aef6ea77 100644 --- a/src/main/java/com/duckblade/osrs/sailing/features/facilities/CargoHoldTracker.java +++ b/src/main/java/com/duckblade/osrs/sailing/features/facilities/CargoHoldTracker.java @@ -475,10 +475,6 @@ private void loadAllFromConfig() loadFromConfig(boatSlot); } } - - int max = maxCapacity(); - wasFull = max > 0 && usedCapacity() >= max; - lastCheckedBoatSlot = currentBoatSlot(); } private void loadFromConfig(int boatSlot)