Make cannon plugin use hidden instead of manager

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-09-07 08:03:58 +02:00
parent f1ddb50c7e
commit f96941fa4f
2 changed files with 9 additions and 9 deletions

View File

@@ -128,11 +128,13 @@ public class CannonPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
overlayManager.add(cannonOverlay); overlayManager.add(cannonOverlay);
overlayManager.add(cannonSpotOverlay);
} }
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
cannonSpotOverlay.setHidden(true);
overlayManager.remove(cannonOverlay); overlayManager.remove(cannonOverlay);
overlayManager.remove(cannonSpotOverlay); overlayManager.remove(cannonSpotOverlay);
cannonPlaced = false; cannonPlaced = false;
@@ -190,14 +192,7 @@ public class CannonPlugin extends Plugin
} }
} }
if (hasAll) cannonSpotOverlay.setHidden(!hasAll);
{
overlayManager.add(cannonSpotOverlay);
}
else
{
overlayManager.remove(cannonSpotOverlay);
}
} }
@Subscribe @Subscribe

View File

@@ -30,6 +30,8 @@ import java.awt.Graphics2D;
import java.awt.Polygon; import java.awt.Polygon;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Setter;
import net.runelite.api.Client; import net.runelite.api.Client;
import static net.runelite.api.ItemID.CANNONBALL; import static net.runelite.api.ItemID.CANNONBALL;
import net.runelite.api.Perspective; import net.runelite.api.Perspective;
@@ -52,6 +54,9 @@ public class CannonSpotOverlay extends Overlay
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@Setter(AccessLevel.PACKAGE)
private boolean hidden;
@Inject @Inject
CannonSpotOverlay(Client client, CannonPlugin plugin, CannonConfig config) CannonSpotOverlay(Client client, CannonPlugin plugin, CannonConfig config)
{ {
@@ -64,7 +69,7 @@ public class CannonSpotOverlay extends Overlay
@Override @Override
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
if (!config.showCannonSpots() || plugin.isCannonPlaced()) if (hidden || !config.showCannonSpots() || plugin.isCannonPlaced())
{ {
return null; return null;
} }