Fix pest control shield state checks (#4977)
Closes #4974. An update for mobile broke checking the shield widgets for hidden. They never technically hide until the game is over.
This commit is contained in:
@@ -46,6 +46,26 @@ public class Game
|
|||||||
private final PortalContext yellow = new PortalContext(YELLOW);
|
private final PortalContext yellow = new PortalContext(YELLOW);
|
||||||
private final PortalContext red = new PortalContext(RED);
|
private final PortalContext red = new PortalContext(RED);
|
||||||
|
|
||||||
|
public void fall(String color)
|
||||||
|
{
|
||||||
|
if (color.equalsIgnoreCase("purple"))
|
||||||
|
{
|
||||||
|
fall(purple);
|
||||||
|
}
|
||||||
|
else if (color.equalsIgnoreCase("red"))
|
||||||
|
{
|
||||||
|
fall(red);
|
||||||
|
}
|
||||||
|
else if (color.equalsIgnoreCase("yellow"))
|
||||||
|
{
|
||||||
|
fall(yellow);
|
||||||
|
}
|
||||||
|
else if (color.equalsIgnoreCase("blue"))
|
||||||
|
{
|
||||||
|
fall(blue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void fall(PortalContext portal)
|
public void fall(PortalContext portal)
|
||||||
{
|
{
|
||||||
if (!portal.isShielded())
|
if (!portal.isShielded())
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
@@ -55,6 +57,7 @@ public class PestControlOverlay extends Overlay
|
|||||||
private final Client client;
|
private final Client client;
|
||||||
|
|
||||||
// Pest control game
|
// Pest control game
|
||||||
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private Game game;
|
private Game game;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -121,24 +124,6 @@ public class PestControlOverlay extends Overlay
|
|||||||
assert yellowShield != null;
|
assert yellowShield != null;
|
||||||
assert redShield != null;
|
assert redShield != null;
|
||||||
|
|
||||||
// Check for fallen portals
|
|
||||||
if (purpleShield.isHidden())
|
|
||||||
{
|
|
||||||
game.fall(purple);
|
|
||||||
}
|
|
||||||
if (blueShield.isHidden())
|
|
||||||
{
|
|
||||||
game.fall(blue);
|
|
||||||
}
|
|
||||||
if (yellowShield.isHidden())
|
|
||||||
{
|
|
||||||
game.fall(yellow);
|
|
||||||
}
|
|
||||||
if (redShield.isHidden())
|
|
||||||
{
|
|
||||||
game.fall(red);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for dead portals
|
// Check for dead portals
|
||||||
if (isZero(purpleHealth))
|
if (isZero(purpleHealth))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,7 +24,14 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.pestcontrol;
|
package net.runelite.client.plugins.pestcontrol;
|
||||||
|
|
||||||
|
import com.google.common.eventbus.Subscribe;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import net.runelite.api.ChatMessageType;
|
||||||
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.GameState;
|
||||||
|
import net.runelite.api.events.SetMessage;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
@@ -39,9 +46,14 @@ public class PestControlPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PestControlOverlay overlay;
|
private PestControlOverlay overlay;
|
||||||
|
|
||||||
|
private Pattern pattern = Pattern.compile("The ([a-z]+), [^ ]+ portal shield has dropped!", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startUp() throws Exception
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
@@ -53,4 +65,23 @@ public class PestControlPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
overlayManager.remove(overlay);
|
overlayManager.remove(overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
private void onSetMessage(SetMessage setMessage)
|
||||||
|
{
|
||||||
|
if (client.getGameState() != GameState.LOADING && client.getGameState() != GameState.LOGGED_IN)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overlay.getGame() != null && setMessage.getType() == ChatMessageType.SERVER)
|
||||||
|
{
|
||||||
|
Matcher matcher = pattern.matcher(setMessage.getValue());
|
||||||
|
if (matcher.lookingAt())
|
||||||
|
{
|
||||||
|
overlay.getGame().fall(matcher.group(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user