Add option for displaying only last fished fish
Add option for displaying only last fished fish's fishing spot. Closes #5488 Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -31,6 +31,17 @@ import net.runelite.client.config.ConfigItem;
|
||||
@ConfigGroup("fishing")
|
||||
public interface FishingConfig extends Config
|
||||
{
|
||||
@ConfigItem(
|
||||
position = 0,
|
||||
keyName = "onlyCurrent",
|
||||
name = "Display only currently fished fish",
|
||||
description = "Configures whether only current fished fish's fishing spots are displayed"
|
||||
)
|
||||
default boolean onlyCurrentSpot()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
keyName = "showIcons",
|
||||
|
||||
@@ -27,8 +27,6 @@ package net.runelite.client.plugins.fishing;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Skill;
|
||||
@@ -63,27 +61,11 @@ class FishingOverlay extends Overlay
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!config.showFishingStats())
|
||||
if (!config.showFishingStats() || plugin.getSession().getLastFishCaught() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
FishingSession session = plugin.getSession();
|
||||
|
||||
if (session.getLastFishCaught() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Duration statTimeout = Duration.ofMinutes(config.statTimeout());
|
||||
Duration sinceCaught = Duration.between(session.getLastFishCaught(), Instant.now());
|
||||
|
||||
if (sinceCaught.compareTo(statTimeout) >= 0)
|
||||
{
|
||||
session.setLastFishCaught(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
panelComponent.getChildren().clear();
|
||||
if (client.getLocalPlayer().getInteracting() != null && client.getLocalPlayer().getInteracting().getName()
|
||||
.contains(FISHING_SPOT))
|
||||
|
||||
@@ -28,6 +28,7 @@ package net.runelite.client.plugins.fishing;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.inject.Provides;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
@@ -38,6 +39,7 @@ import javax.inject.Singleton;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
@@ -50,6 +52,7 @@ import net.runelite.api.Varbits;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.InteractingChanged;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.NpcDespawned;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
@@ -87,6 +90,9 @@ public class FishingPlugin extends Plugin
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private NPC[] fishingSpots;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private FishingSpot currentSpot;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@@ -137,6 +143,7 @@ public class FishingPlugin extends Plugin
|
||||
overlayManager.remove(fishingSpotMinimapOverlay);
|
||||
minnowSpots.clear();
|
||||
trawlerNotificationSent = false;
|
||||
currentSpot = null;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -152,6 +159,11 @@ public class FishingPlugin extends Plugin
|
||||
|| canPlayerFish(client.getItemContainer(InventoryID.INVENTORY))
|
||||
|| canPlayerFish(client.getItemContainer(InventoryID.EQUIPMENT));
|
||||
|
||||
if (!showOverlays)
|
||||
{
|
||||
currentSpot = null;
|
||||
}
|
||||
|
||||
spotOverlay.setHidden(!showOverlays);
|
||||
fishingSpotMinimapOverlay.setHidden(!showOverlays);
|
||||
}
|
||||
@@ -172,6 +184,32 @@ public class FishingPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onInteractingChanged(InteractingChanged event)
|
||||
{
|
||||
if (event.getSource() != client.getLocalPlayer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Actor target = event.getTarget();
|
||||
|
||||
if (!(target instanceof NPC))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final NPC npc = (NPC) target;
|
||||
FishingSpot spot = FishingSpot.getSPOTS().get(npc.getId());
|
||||
|
||||
if (spot == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
currentSpot = spot;
|
||||
}
|
||||
|
||||
private boolean canPlayerFish(final ItemContainer itemContainer)
|
||||
{
|
||||
if (itemContainer == null)
|
||||
@@ -212,6 +250,19 @@ public class FishingPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
// Reset fishing session
|
||||
if (session.getLastFishCaught() != null)
|
||||
{
|
||||
final Duration statTimeout = Duration.ofMinutes(config.statTimeout());
|
||||
final Duration sinceCaught = Duration.between(session.getLastFishCaught(), Instant.now());
|
||||
|
||||
if (sinceCaught.compareTo(statTimeout) >= 0)
|
||||
{
|
||||
currentSpot = null;
|
||||
session.setLastFishCaught(null);
|
||||
}
|
||||
}
|
||||
|
||||
final LocalPoint cameraPoint = new LocalPoint(client.getCameraX(), client.getCameraY());
|
||||
|
||||
final NPCQuery query = new NPCQuery()
|
||||
|
||||
@@ -40,16 +40,18 @@ import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
class FishingSpotMinimapOverlay extends Overlay
|
||||
{
|
||||
private final FishingPlugin plugin;
|
||||
private final FishingConfig config;
|
||||
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private boolean hidden;
|
||||
|
||||
@Inject
|
||||
public FishingSpotMinimapOverlay(FishingPlugin plugin)
|
||||
public FishingSpotMinimapOverlay(FishingPlugin plugin, FishingConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,6 +77,11 @@ class FishingSpotMinimapOverlay extends Overlay
|
||||
continue;
|
||||
}
|
||||
|
||||
if (config.onlyCurrentSpot() && plugin.getCurrentSpot() != null && plugin.getCurrentSpot() != spot)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Color color = npc.getGraphic() == GraphicID.FLYING_FISH ? Color.RED : Color.CYAN;
|
||||
|
||||
net.runelite.api.Point minimapLocation = npc.getMinimapLocation();
|
||||
|
||||
@@ -93,6 +93,11 @@ class FishingSpotOverlay extends Overlay
|
||||
continue;
|
||||
}
|
||||
|
||||
if (config.onlyCurrentSpot() && plugin.getCurrentSpot() != null && plugin.getCurrentSpot() != spot)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Color color = npc.getGraphic() == GraphicID.FLYING_FISH ? Color.RED : Color.CYAN;
|
||||
|
||||
if (spot == FishingSpot.MINNOW && config.showMinnowOverlay())
|
||||
|
||||
Reference in New Issue
Block a user