diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hunter/CatchrateOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/hunter/CatchrateOverlay.java deleted file mode 100644 index cdf8469a1a..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hunter/CatchrateOverlay.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2017, Robin Weymans - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.hunter; - -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Point; -import java.time.Duration; -import java.time.Instant; -import javax.inject.Inject; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.PanelComponent; - -/** - * Represents the overlay that shows the catch rate (percentage). - */ -public class CatchrateOverlay extends Overlay -{ - /** - * The time after which the catch rate panel disappears, if the player - * stops hunting. - */ - private final Duration catchRatePanelTimeOut = Duration.ofSeconds(30); - private final PanelComponent catchRatePanel = new PanelComponent(); - - private final HunterPlugin plugin; - - @Inject - CatchrateOverlay(HunterPlugin plugin) - { - setPosition(OverlayPosition.BOTTOM_RIGHT); - this.plugin = plugin; - } - - @Override - public Dimension render(Graphics2D graphics, Point parent) - { - if (Duration.between(plugin.getLastActionTime(), Instant.now()).compareTo(catchRatePanelTimeOut) < 0) - { - final String attackStyleString = String.format("%.2f", plugin.getCatchRate() * 100) + " %"; - catchRatePanel.setTitle(attackStyleString); - catchRatePanel.setWidth(80); - return catchRatePanel.render(graphics, parent); - } - - return null; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hunter/HunterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/hunter/HunterPlugin.java index 1c49c8bf8b..cfcb0146d9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hunter/HunterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hunter/HunterPlugin.java @@ -28,7 +28,6 @@ import com.google.common.eventbus.Subscribe; import com.google.inject.Provides; import java.time.Instant; import java.util.Arrays; -import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -50,7 +49,6 @@ import net.runelite.client.Notifier; import net.runelite.client.config.ConfigManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.util.QueryRunner; @Slf4j @@ -66,10 +64,8 @@ public class HunterPlugin extends Plugin private QueryRunner queryRunner; @Inject - private TrapOverlay trapOverlay; - - @Inject - private CatchrateOverlay catchrateOverlay; + @Getter + private TrapOverlay overlay; @Inject private Notifier notifier; @@ -80,9 +76,6 @@ public class HunterPlugin extends Plugin @Getter private final Set traps = new HashSet<>(); - private double catchAtempts = 0; - private double catchSuccess = 0; - @Getter private Instant lastActionTime = Instant.ofEpochMilli(0); @@ -92,23 +85,15 @@ public class HunterPlugin extends Plugin return configManager.getConfig(HunterConfig.class); } - @Override - public Collection getOverlays() - { - return Arrays.asList(trapOverlay, catchrateOverlay); - } - @Override protected void startUp() { - trapOverlay.updateConfig(); + overlay.updateConfig(); } @Override protected void shutDown() throws Exception { - catchAtempts = 0; - catchSuccess = 0; lastActionTime = Instant.ofEpochMilli(0); traps.clear(); } @@ -185,8 +170,6 @@ public class HunterPlugin extends Plugin if (myTrap != null) { myTrap.setState(HunterTrap.State.FULL); - catchAtempts++; - catchSuccess++; lastActionTime = Instant.now(); if (config.maniacalMonkeyNotify() && myTrap.getGameObject().getId() == ObjectID.MONKEY_TRAP) @@ -208,8 +191,6 @@ public class HunterPlugin extends Plugin { myTrap.setState(HunterTrap.State.EMPTY); myTrap.resetTimer(); - catchAtempts++; - lastActionTime = Instant.now(); } @@ -326,7 +307,7 @@ public class HunterPlugin extends Plugin { if (event.getGroup().equals("hunterplugin")) { - trapOverlay.updateConfig(); + overlay.updateConfig(); } } @@ -352,16 +333,4 @@ public class HunterPlugin extends Plugin return null; } - - /** - * Calculates the catch rate, i.e. the attempts to catch something - * compared to the times you succeed. - * - * @return Value between 0 (none) and 1 (all). - */ - public double getCatchRate() - { - return catchAtempts != 0 ? catchSuccess / catchAtempts : 0; - } - }