fishing plugin: add trawler timer
Co-authored-by: Adam <Adam@sigterm.info>
This commit is contained in:
@@ -121,6 +121,7 @@ public class WidgetID
|
||||
public static final int MINIGAME_TAB_ID = 76;
|
||||
public static final int SPELLBOOK_GROUP_ID = 218;
|
||||
public static final int PVP_GROUP_ID = 90;
|
||||
public static final int FISHING_TRAWLER_GROUP_ID = 366;
|
||||
public static final int ZEAH_MESS_HALL_GROUP_ID = 235;
|
||||
public static final int KOUREND_FAVOUR_GROUP_ID = 246;
|
||||
public static final int LOOTING_BAG_GROUP_ID = 81;
|
||||
|
||||
@@ -420,6 +420,8 @@ public enum WidgetInfo
|
||||
EXPERIENCE_TRACKER_WIDGET(WidgetID.EXPERIENCE_TRACKER_GROUP_ID, WidgetID.ExperienceTracker.WIDGET),
|
||||
EXPERIENCE_TRACKER_BOTTOM_BAR(WidgetID.EXPERIENCE_TRACKER_GROUP_ID, WidgetID.ExperienceTracker.BOTTOM_BAR),
|
||||
|
||||
FISHING_TRAWLER_TIMER(WidgetID.FISHING_TRAWLER_GROUP_ID, 37),
|
||||
|
||||
TITHE_FARM(WidgetID.TITHE_FARM_GROUP_ID, 1),
|
||||
|
||||
BARROWS_INFO(WidgetID.BARROWS_GROUP_ID, 0),
|
||||
|
||||
@@ -118,4 +118,15 @@ public interface FishingConfig extends Config
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 8,
|
||||
keyName = "trawlerTimer",
|
||||
name = "Trawler timer in MM:SS",
|
||||
description = "Trawler Timer will display a more accurate timer in MM:SS format."
|
||||
)
|
||||
default boolean trawlerTimer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,10 @@ import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.NpcDespawned;
|
||||
import net.runelite.api.events.NpcSpawned;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.api.events.WidgetLoaded;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
@@ -78,9 +82,11 @@ public class FishingPlugin extends Plugin
|
||||
{
|
||||
private static final int TRAWLER_SHIP_REGION_NORMAL = 7499;
|
||||
private static final int TRAWLER_SHIP_REGION_SINKING = 8011;
|
||||
|
||||
private static final int TRAWLER_TIME_LIMIT_IN_SECONDS = 614;
|
||||
private static final int TRAWLER_ACTIVITY_THRESHOLD = Math.round(0.15f * 255);
|
||||
|
||||
private Instant trawlerStartTime;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final FishingSession session = new FishingSession();
|
||||
|
||||
@@ -142,6 +148,7 @@ public class FishingPlugin extends Plugin
|
||||
minnowSpots.clear();
|
||||
trawlerNotificationSent = false;
|
||||
currentSpot = null;
|
||||
trawlerStartTime = null;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -296,6 +303,11 @@ public class FishingPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.trawlerTimer())
|
||||
{
|
||||
updateTrawlerTimer();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -351,6 +363,66 @@ public class FishingPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onWidgetLoaded(WidgetLoaded event)
|
||||
{
|
||||
if (event.getGroupId() == WidgetID.FISHING_TRAWLER_GROUP_ID)
|
||||
{
|
||||
trawlerStartTime = Instant.now();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the Fishing Trawler timer widget from minutes to minutes and seconds
|
||||
*/
|
||||
private void updateTrawlerTimer()
|
||||
{
|
||||
if (trawlerStartTime == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int regionID = client.getLocalPlayer().getWorldLocation().getRegionID();
|
||||
if (regionID != TRAWLER_SHIP_REGION_NORMAL && regionID != TRAWLER_SHIP_REGION_SINKING)
|
||||
{
|
||||
log.debug("Trawler session ended");
|
||||
return;
|
||||
}
|
||||
|
||||
Widget trawlerTimerWidget = client.getWidget(WidgetInfo.FISHING_TRAWLER_TIMER);
|
||||
if (trawlerTimerWidget == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
long timeLeft = TRAWLER_TIME_LIMIT_IN_SECONDS - Duration.between(trawlerStartTime, Instant.now()).getSeconds();
|
||||
int minutes = (int) timeLeft / 60;
|
||||
int seconds = (int) timeLeft % 60;
|
||||
|
||||
final StringBuilder trawlerText = new StringBuilder();
|
||||
trawlerText.append("Time Left: ");
|
||||
|
||||
if (minutes > 0)
|
||||
{
|
||||
trawlerText.append(minutes);
|
||||
}
|
||||
else
|
||||
{
|
||||
trawlerText.append("00");
|
||||
}
|
||||
|
||||
trawlerText.append(':');
|
||||
|
||||
if (seconds < 10)
|
||||
{
|
||||
trawlerText.append("0");
|
||||
}
|
||||
|
||||
trawlerText.append(seconds);
|
||||
|
||||
trawlerTimerWidget.setText(trawlerText.toString());
|
||||
}
|
||||
|
||||
private void inverseSortSpotDistanceFromPlayer()
|
||||
{
|
||||
final LocalPoint cameraPoint = new LocalPoint(client.getCameraX(), client.getCameraY());
|
||||
|
||||
Reference in New Issue
Block a user