Merge pull request #5490 from deathbeam/fishing-current-fish
Add option for displaying only last fished fish
This commit is contained in:
@@ -31,6 +31,17 @@ import net.runelite.client.config.ConfigItem;
|
|||||||
@ConfigGroup("fishing")
|
@ConfigGroup("fishing")
|
||||||
public interface FishingConfig extends Config
|
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(
|
@ConfigItem(
|
||||||
position = 1,
|
position = 1,
|
||||||
keyName = "showIcons",
|
keyName = "showIcons",
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ package net.runelite.client.plugins.fishing;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
@@ -63,27 +61,11 @@ class FishingOverlay extends Overlay
|
|||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics)
|
public Dimension render(Graphics2D graphics)
|
||||||
{
|
{
|
||||||
if (!config.showFishingStats())
|
if (!config.showFishingStats() || plugin.getSession().getLastFishCaught() == null)
|
||||||
{
|
{
|
||||||
return 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();
|
panelComponent.getChildren().clear();
|
||||||
if (client.getLocalPlayer().getInteracting() != null && client.getLocalPlayer().getInteracting().getName()
|
if (client.getLocalPlayer().getInteracting() != null && client.getLocalPlayer().getInteracting().getName()
|
||||||
.contains(FISHING_SPOT))
|
.contains(FISHING_SPOT))
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ package net.runelite.client.plugins.fishing;
|
|||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@@ -38,6 +39,7 @@ import javax.inject.Singleton;
|
|||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.runelite.api.Actor;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
@@ -50,6 +52,7 @@ import net.runelite.api.Varbits;
|
|||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
|
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.VarbitChanged;
|
import net.runelite.api.events.VarbitChanged;
|
||||||
@@ -87,6 +90,9 @@ public class FishingPlugin extends Plugin
|
|||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private NPC[] fishingSpots;
|
private NPC[] fishingSpots;
|
||||||
|
|
||||||
|
@Getter(AccessLevel.PACKAGE)
|
||||||
|
private FishingSpot currentSpot;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@@ -137,6 +143,7 @@ public class FishingPlugin extends Plugin
|
|||||||
overlayManager.remove(fishingSpotMinimapOverlay);
|
overlayManager.remove(fishingSpotMinimapOverlay);
|
||||||
minnowSpots.clear();
|
minnowSpots.clear();
|
||||||
trawlerNotificationSent = false;
|
trawlerNotificationSent = false;
|
||||||
|
currentSpot = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -152,6 +159,11 @@ public class FishingPlugin extends Plugin
|
|||||||
|| canPlayerFish(client.getItemContainer(InventoryID.INVENTORY))
|
|| canPlayerFish(client.getItemContainer(InventoryID.INVENTORY))
|
||||||
|| canPlayerFish(client.getItemContainer(InventoryID.EQUIPMENT));
|
|| canPlayerFish(client.getItemContainer(InventoryID.EQUIPMENT));
|
||||||
|
|
||||||
|
if (!showOverlays)
|
||||||
|
{
|
||||||
|
currentSpot = null;
|
||||||
|
}
|
||||||
|
|
||||||
spotOverlay.setHidden(!showOverlays);
|
spotOverlay.setHidden(!showOverlays);
|
||||||
fishingSpotMinimapOverlay.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)
|
private boolean canPlayerFish(final ItemContainer itemContainer)
|
||||||
{
|
{
|
||||||
if (itemContainer == null)
|
if (itemContainer == null)
|
||||||
@@ -212,6 +250,19 @@ public class FishingPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameTick(GameTick event)
|
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 LocalPoint cameraPoint = new LocalPoint(client.getCameraX(), client.getCameraY());
|
||||||
|
|
||||||
final NPCQuery query = new NPCQuery()
|
final NPCQuery query = new NPCQuery()
|
||||||
|
|||||||
@@ -40,16 +40,18 @@ import net.runelite.client.ui.overlay.OverlayUtil;
|
|||||||
class FishingSpotMinimapOverlay extends Overlay
|
class FishingSpotMinimapOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private final FishingPlugin plugin;
|
private final FishingPlugin plugin;
|
||||||
|
private final FishingConfig config;
|
||||||
|
|
||||||
@Setter(AccessLevel.PACKAGE)
|
@Setter(AccessLevel.PACKAGE)
|
||||||
private boolean hidden;
|
private boolean hidden;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FishingSpotMinimapOverlay(FishingPlugin plugin)
|
public FishingSpotMinimapOverlay(FishingPlugin plugin, FishingConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -75,6 +77,11 @@ class FishingSpotMinimapOverlay extends Overlay
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.onlyCurrentSpot() && plugin.getCurrentSpot() != null && plugin.getCurrentSpot() != spot)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Color color = npc.getGraphic() == GraphicID.FLYING_FISH ? Color.RED : Color.CYAN;
|
Color color = npc.getGraphic() == GraphicID.FLYING_FISH ? Color.RED : Color.CYAN;
|
||||||
|
|
||||||
net.runelite.api.Point minimapLocation = npc.getMinimapLocation();
|
net.runelite.api.Point minimapLocation = npc.getMinimapLocation();
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ class FishingSpotOverlay extends Overlay
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.onlyCurrentSpot() && plugin.getCurrentSpot() != null && plugin.getCurrentSpot() != spot)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Color color = npc.getGraphic() == GraphicID.FLYING_FISH ? Color.RED : Color.CYAN;
|
Color color = npc.getGraphic() == GraphicID.FLYING_FISH ? Color.RED : Color.CYAN;
|
||||||
|
|
||||||
if (spot == FishingSpot.MINNOW && config.showMinnowOverlay())
|
if (spot == FishingSpot.MINNOW && config.showMinnowOverlay())
|
||||||
|
|||||||
Reference in New Issue
Block a user