fishing plugin: update for fishing trawler changes

Modify game timer to be 5 minutes.
Add option to replace the fish caught text with contribution amount
Remove activity timer notification as the mechanic has been removed

Co-authored-by: Attrolantra <ebrie3@gmail.com>
This commit is contained in:
Adam
2021-04-21 15:53:54 -04:00
committed by Adam
parent 5bfbff492d
commit 79cba4faa1
3 changed files with 46 additions and 45 deletions

View File

@@ -433,7 +433,8 @@ public enum WidgetInfo
EXPERIENCE_TRACKER_WIDGET(WidgetID.EXPERIENCE_TRACKER_GROUP_ID, WidgetID.ExperienceTracker.WIDGET), EXPERIENCE_TRACKER_WIDGET(WidgetID.EXPERIENCE_TRACKER_GROUP_ID, WidgetID.ExperienceTracker.WIDGET),
EXPERIENCE_TRACKER_BOTTOM_BAR(WidgetID.EXPERIENCE_TRACKER_GROUP_ID, WidgetID.ExperienceTracker.BOTTOM_BAR), EXPERIENCE_TRACKER_BOTTOM_BAR(WidgetID.EXPERIENCE_TRACKER_GROUP_ID, WidgetID.ExperienceTracker.BOTTOM_BAR),
FISHING_TRAWLER_TIMER(WidgetID.FISHING_TRAWLER_GROUP_ID, 14), FISHING_TRAWLER_CONTRIBUTION(WidgetID.FISHING_TRAWLER_GROUP_ID, 14),
FISHING_TRAWLER_TIMER(WidgetID.FISHING_TRAWLER_GROUP_ID, 15),
TITHE_FARM(WidgetID.TITHE_FARM_GROUP_ID, 3), TITHE_FARM(WidgetID.TITHE_FARM_GROUP_ID, 3),

View File

@@ -173,22 +173,22 @@ public interface FishingConfig extends Config
@ConfigItem( @ConfigItem(
position = 11, position = 11,
keyName = "trawlerNotification", keyName = "trawlerTimer",
name = "Trawler activity notification", name = "Trawler timer in M:SS",
description = "Send a notification when fishing trawler activity drops below 15%." description = "Trawler timer will display a more accurate timer in M:SS format."
) )
default boolean trawlerNotification() default boolean trawlerTimer()
{ {
return true; return true;
} }
@ConfigItem( @ConfigItem(
position = 12, position = 12,
keyName = "trawlerTimer", keyName = "trawlerContribution",
name = "Trawler timer in MM:SS", name = "Trawler contribution",
description = "Trawler Timer will display a more accurate timer in MM:SS format." description = "Display the exact number of trawler contribution points gained."
) )
default boolean trawlerTimer() default boolean trawlerContribution()
{ {
return true; return true;
} }

View File

@@ -57,7 +57,6 @@ import net.runelite.api.events.InteractingChanged;
import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.NpcSpawned;
import net.runelite.api.events.VarbitChanged;
import net.runelite.api.events.WidgetLoaded; import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetID; import net.runelite.api.widgets.WidgetID;
@@ -86,8 +85,7 @@ public class FishingPlugin extends Plugin
{ {
private static final int TRAWLER_SHIP_REGION_NORMAL = 7499; private static final int TRAWLER_SHIP_REGION_NORMAL = 7499;
private static final int TRAWLER_SHIP_REGION_SINKING = 8011; private static final int TRAWLER_SHIP_REGION_SINKING = 8011;
private static final int TRAWLER_TIME_LIMIT_IN_SECONDS = 614; private static final int TRAWLER_TIME_LIMIT_IN_SECONDS = 314;
private static final int TRAWLER_ACTIVITY_THRESHOLD = Math.round(0.15f * 255);
private Instant trawlerStartTime; private Instant trawlerStartTime;
@@ -124,8 +122,6 @@ public class FishingPlugin extends Plugin
@Inject @Inject
private FishingSpotMinimapOverlay fishingSpotMinimapOverlay; private FishingSpotMinimapOverlay fishingSpotMinimapOverlay;
private boolean trawlerNotificationSent;
@Provides @Provides
FishingConfig provideConfig(ConfigManager configManager) FishingConfig provideConfig(ConfigManager configManager)
{ {
@@ -150,7 +146,6 @@ public class FishingPlugin extends Plugin
overlayManager.remove(fishingSpotMinimapOverlay); overlayManager.remove(fishingSpotMinimapOverlay);
fishingSpots.clear(); fishingSpots.clear();
minnowSpots.clear(); minnowSpots.clear();
trawlerNotificationSent = false;
currentSpot = null; currentSpot = null;
trawlerStartTime = null; trawlerStartTime = null;
} }
@@ -328,10 +323,8 @@ public class FishingPlugin extends Plugin
} }
} }
if (config.trawlerTimer()) updateTrawlerTimer();
{ updateTrawlerContribution();
updateTrawlerTimer();
}
} }
@Subscribe @Subscribe
@@ -362,40 +355,42 @@ public class FishingPlugin extends Plugin
} }
} }
@Subscribe
public void onVarbitChanged(VarbitChanged event)
{
if (!config.trawlerNotification() || client.getGameState() != GameState.LOGGED_IN)
{
return;
}
int regionID = client.getLocalPlayer().getWorldLocation().getRegionID();
if ((regionID == TRAWLER_SHIP_REGION_NORMAL || regionID == TRAWLER_SHIP_REGION_SINKING)
&& client.getVar(Varbits.FISHING_TRAWLER_ACTIVITY) <= TRAWLER_ACTIVITY_THRESHOLD)
{
if (!trawlerNotificationSent)
{
notifier.notify("You have low Fishing Trawler activity!");
trawlerNotificationSent = true;
}
}
else
{
trawlerNotificationSent = false;
}
}
@Subscribe @Subscribe
public void onWidgetLoaded(WidgetLoaded event) public void onWidgetLoaded(WidgetLoaded event)
{ {
if (event.getGroupId() == WidgetID.FISHING_TRAWLER_GROUP_ID) if (event.getGroupId() == WidgetID.FISHING_TRAWLER_GROUP_ID)
{ {
trawlerStartTime = Instant.now(); trawlerStartTime = Instant.now();
log.debug("Trawler session started");
} }
} }
/**
* Updates the trawler contribution value
*/
private void updateTrawlerContribution()
{
int regionID = client.getLocalPlayer().getWorldLocation().getRegionID();
if (regionID != TRAWLER_SHIP_REGION_NORMAL && regionID != TRAWLER_SHIP_REGION_SINKING)
{
return;
}
if (!config.trawlerContribution())
{
return;
}
Widget trawlerContributionWidget = client.getWidget(WidgetInfo.FISHING_TRAWLER_CONTRIBUTION);
if (trawlerContributionWidget == null)
{
return;
}
int trawlerContribution = client.getVar(Varbits.FISHING_TRAWLER_ACTIVITY);
trawlerContributionWidget.setText("Contribution: " + trawlerContribution);
}
/** /**
* Changes the Fishing Trawler timer widget from minutes to minutes and seconds * Changes the Fishing Trawler timer widget from minutes to minutes and seconds
*/ */
@@ -414,6 +409,11 @@ public class FishingPlugin extends Plugin
return; return;
} }
if (!config.trawlerTimer())
{
return;
}
Widget trawlerTimerWidget = client.getWidget(WidgetInfo.FISHING_TRAWLER_TIMER); Widget trawlerTimerWidget = client.getWidget(WidgetInfo.FISHING_TRAWLER_TIMER);
if (trawlerTimerWidget == null) if (trawlerTimerWidget == null)
{ {
@@ -438,7 +438,7 @@ public class FishingPlugin extends Plugin
} }
else else
{ {
trawlerText.append("00"); trawlerText.append('0');
} }
trawlerText.append(':'); trawlerText.append(':');