Remove unnecessary fishing spot configuration

As now the fishing spots get hidden automatically and shown
automatically it is no longer necessary to have per-spot configuration.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-09-12 00:48:45 +02:00
parent 1a14aa295e
commit 0754a7e090
5 changed files with 15 additions and 274 deletions

View File

@@ -53,176 +53,11 @@ public interface FishingConfig extends Config
return 5; return 5;
} }
@ConfigItem(
keyName = "showShrimp",
name = "Show Shrimp/Anchovies",
description = "Configures whether shrimp/anchovies is displayed",
position = 3
)
default boolean showShrimp()
{
return true;
}
@ConfigItem(
keyName = "showLobster",
name = "Show Lobster/Swordfish/Tuna",
description = "Configures whether lobster/swordfish/tuna is displayed",
position = 4
)
default boolean showLobster()
{
return true;
}
@ConfigItem(
keyName = "showShark",
name = "Show Shark",
description = "Configures whether shark is displayed",
position = 5
)
default boolean showShark()
{
return true;
}
@ConfigItem(
keyName = "showMonkfish",
name = "Show Monkfish",
description = "Configures whether monkfish displayed",
position = 6
)
default boolean showMonkfish()
{
return true;
}
@ConfigItem(
keyName = "showSalmon",
name = "Show Salmon/Trout",
description = "Configures whether salmon/trout is displayed",
position = 7
)
default boolean showSalmon()
{
return true;
}
@ConfigItem(
keyName = "showBarb",
name = "Show Barbarian fish",
description = "Configures whether barbarian fish is displayed",
position = 8
)
default boolean showBarb()
{
return true;
}
@ConfigItem(
keyName = "showAngler",
name = "Show Anglerfish",
description = "Configures whether anglerfish is displayed",
position = 9
)
default boolean showAngler()
{
return true;
}
@ConfigItem(
keyName = "showMinnow",
name = "Show Minnow fish",
description = "Configures whether minnow fish is displayed",
position = 10
)
default boolean showMinnow()
{
return true;
}
@ConfigItem(
keyName = "showInfernalEel",
name = "Show Infernal Eel",
description = "Configures whether infernal eel is displayed",
position = 11
)
default boolean showInfernalEel()
{
return true;
}
@ConfigItem(
keyName = "showSacredEel",
name = "Show Sacred Eel",
description = "Configures whether sacred eel is displayed",
position = 12
)
default boolean showSacredEel()
{
return true;
}
@ConfigItem(
keyName = "showCaveEel",
name = "Show Cave Eel",
description = "Configures whether cave eel is displayed",
position = 13
)
default boolean showCaveEel()
{
return true;
}
@ConfigItem(
keyName = "showSlimyEel",
name = "Show Slimy Eel",
description = "Configures whether slimy eel is displayed",
position = 14
)
default boolean showSlimyEel()
{
return true;
}
@ConfigItem(
keyName = "showKarambwanji",
name = "Show Karambwanji",
description = "Configures whether karambwanji is displayed",
position = 15
)
default boolean showKarambwanji()
{
return true;
}
@ConfigItem(
keyName = "showKarambwan",
name = "Show Karambwan",
description = "Configures whether karambwan is displayed",
position = 16
)
default boolean showKarambwan()
{
return true;
}
@ConfigItem(
keyName = "showDarkCrab",
name = "Show Dark Crab",
description = "Configures whether dark crab is displayed",
position = 17
)
default boolean showDarkCrab()
{
return true;
}
@ConfigItem( @ConfigItem(
keyName = "showFishingStats", keyName = "showFishingStats",
name = "Show Fishing session stats", name = "Show Fishing session stats",
description = "Configures whether to display the fishing session stats", description = "Configures whether to display the fishing session stats",
position = 18 position = 3
) )
default boolean showFishingStats() default boolean showFishingStats()
{ {
@@ -233,7 +68,7 @@ public interface FishingConfig extends Config
keyName = "showMinnowOverlay", keyName = "showMinnowOverlay",
name = "Show Minnow Movement overlay", name = "Show Minnow Movement overlay",
description = "Configures whether to display the minnow progress pie overlay", description = "Configures whether to display the minnow progress pie overlay",
position = 19 position = 4
) )
default boolean showMinnowOverlay() default boolean showMinnowOverlay()
{ {

View File

@@ -29,11 +29,9 @@ 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.Instant; import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
@@ -49,7 +47,6 @@ import net.runelite.api.ItemID;
import net.runelite.api.NPC; import net.runelite.api.NPC;
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.ConfigChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcDespawned;
@@ -72,8 +69,6 @@ import net.runelite.client.util.QueryRunner;
@Slf4j @Slf4j
public class FishingPlugin extends Plugin public class FishingPlugin extends Plugin
{ {
private final List<Integer> spotIds = new ArrayList<>();
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private final FishingSession session = new FishingSession(); private final FishingSession session = new FishingSession();
@@ -116,7 +111,6 @@ public class FishingPlugin extends Plugin
overlayManager.add(overlay); overlayManager.add(overlay);
overlayManager.add(spotOverlay); overlayManager.add(spotOverlay);
overlayManager.add(fishingSpotMinimapOverlay); overlayManager.add(fishingSpotMinimapOverlay);
updateConfig();
} }
@Override @Override
@@ -163,12 +157,6 @@ public class FishingPlugin extends Plugin
} }
} }
@Subscribe
public void updateConfig(ConfigChanged event)
{
updateConfig();
}
private boolean canPlayerFish(final ItemContainer itemContainer) private boolean canPlayerFish(final ItemContainer itemContainer)
{ {
if (itemContainer == null) if (itemContainer == null)
@@ -206,78 +194,13 @@ public class FishingPlugin extends Plugin
return false; return false;
} }
private void updateConfig()
{
spotIds.clear();
if (config.showShrimp())
{
spotIds.addAll(Ints.asList(FishingSpot.SHRIMP.getIds()));
}
if (config.showLobster())
{
spotIds.addAll(Ints.asList(FishingSpot.LOBSTER.getIds()));
}
if (config.showShark())
{
spotIds.addAll(Ints.asList(FishingSpot.SHARK.getIds()));
}
if (config.showMonkfish())
{
spotIds.addAll(Ints.asList(FishingSpot.MONKFISH.getIds()));
}
if (config.showSalmon())
{
spotIds.addAll(Ints.asList(FishingSpot.SALMON.getIds()));
}
if (config.showBarb())
{
spotIds.addAll(Ints.asList(FishingSpot.BARB_FISH.getIds()));
}
if (config.showAngler())
{
spotIds.addAll(Ints.asList(FishingSpot.ANGLERFISH.getIds()));
}
if (config.showMinnow())
{
spotIds.addAll(Ints.asList(FishingSpot.MINNOW.getIds()));
}
if (config.showInfernalEel())
{
spotIds.addAll(Ints.asList(FishingSpot.INFERNAL_EEL.getIds()));
}
if (config.showSacredEel())
{
spotIds.addAll(Ints.asList(FishingSpot.SACRED_EEL.getIds()));
}
if (config.showCaveEel())
{
spotIds.addAll(Ints.asList(FishingSpot.CAVE_EEL.getIds()));
}
if (config.showSlimyEel())
{
spotIds.addAll(Ints.asList(FishingSpot.SLIMY_EEL.getIds()));
}
if (config.showKarambwanji())
{
spotIds.addAll(Ints.asList(FishingSpot.KARAMBWANJI.getIds()));
}
if (config.showKarambwan())
{
spotIds.addAll(Ints.asList(FishingSpot.KARAMBWAN.getIds()));
}
if (config.showDarkCrab())
{
spotIds.addAll(Ints.asList(FishingSpot.DARK_CRAB.getIds()));
}
}
@Subscribe @Subscribe
public void onGameTick(GameTick event) public void onGameTick(GameTick event)
{ {
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()
.idEquals(Ints.toArray(spotIds)); .idEquals(Ints.toArray(FishingSpot.getSPOTS().keySet()));
NPC[] spots = queryRunner.runQuery(query); NPC[] spots = queryRunner.runQuery(query);
// -1 to make closer things draw last (on top of farther things) // -1 to make closer things draw last (on top of farther things)
Arrays.sort(spots, Comparator.comparing(npc -> -1 * npc.getLocalLocation().distanceTo(cameraPoint))); Arrays.sort(spots, Comparator.comparing(npc -> -1 * npc.getLocalLocation().distanceTo(cameraPoint)));
@@ -286,7 +209,7 @@ public class FishingPlugin extends Plugin
// process minnows // process minnows
for (NPC npc : spots) for (NPC npc : spots)
{ {
FishingSpot spot = FishingSpot.getSpot(npc.getId()); FishingSpot spot = FishingSpot.getSPOTS().get(npc.getId());
if (spot == null) if (spot == null)
{ {

View File

@@ -26,6 +26,7 @@ package net.runelite.client.plugins.fishing;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import lombok.Getter;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
import static net.runelite.api.NpcID.FISHING_SPOT_1497; import static net.runelite.api.NpcID.FISHING_SPOT_1497;
import static net.runelite.api.NpcID.FISHING_SPOT_1498; import static net.runelite.api.NpcID.FISHING_SPOT_1498;
@@ -93,7 +94,8 @@ import static net.runelite.api.NpcID.ROD_FISHING_SPOT_7464;
import static net.runelite.api.NpcID.ROD_FISHING_SPOT_7468; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_7468;
import static net.runelite.api.NpcID.ROD_FISHING_SPOT_7676; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_7676;
public enum FishingSpot @Getter
enum FishingSpot
{ {
SHRIMP("Shrimp, Anchovies", ItemID.RAW_SHRIMPS, SHRIMP("Shrimp, Anchovies", ItemID.RAW_SHRIMPS,
FISHING_SPOT_1518, FISHING_SPOT_1521, FISHING_SPOT_1523, FISHING_SPOT_1518, FISHING_SPOT_1521, FISHING_SPOT_1523,
@@ -154,11 +156,12 @@ public enum FishingSpot
FISHING_SPOT_1536 FISHING_SPOT_1536
); );
private static final Map<Integer, FishingSpot> fishingSpots = new HashMap<>(); @Getter
private static final Map<Integer, FishingSpot> SPOTS = new HashMap<>();
private final String name; private final String name;
private final int fishSpriteId; private final int fishSpriteId;
private final int[] spots; private final int[] ids;
static static
{ {
@@ -168,35 +171,15 @@ public enum FishingSpot
{ {
for (int spotId : spot.getIds()) for (int spotId : spot.getIds())
{ {
fishingSpots.put(spotId, spot); SPOTS.put(spotId, spot);
} }
} }
} }
FishingSpot(String spot, int fishSpriteId, int... spots) FishingSpot(String spot, int fishSpriteId, int... ids)
{ {
this.name = spot; this.name = spot;
this.fishSpriteId = fishSpriteId; this.fishSpriteId = fishSpriteId;
this.spots = spots; this.ids = ids;
}
public String getName()
{
return name;
}
public int getFishSpriteId()
{
return fishSpriteId;
}
public int[] getIds()
{
return spots;
}
public static FishingSpot getSpot(int npcId)
{
return fishingSpots.get(npcId);
} }
} }

View File

@@ -68,7 +68,7 @@ class FishingSpotMinimapOverlay extends Overlay
for (NPC npc : fishingSpots) for (NPC npc : fishingSpots)
{ {
FishingSpot spot = FishingSpot.getSpot(npc.getId()); FishingSpot spot = FishingSpot.getSPOTS().get(npc.getId());
if (spot == null) if (spot == null)
{ {

View File

@@ -86,7 +86,7 @@ class FishingSpotOverlay extends Overlay
for (NPC npc : fishingSpots) for (NPC npc : fishingSpots)
{ {
FishingSpot spot = FishingSpot.getSpot(npc.getId()); FishingSpot spot = FishingSpot.getSPOTS().get(npc.getId());
if (spot == null) if (spot == null)
{ {