Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Commit

Permalink
graceful: Add array length checks (#2236)
Browse files Browse the repository at this point in the history
* graceful: Add array length checks

* Update StatusOrbsOverlay.java

Co-authored-by: Kyle <48519776+xKylee@users.noreply.github.com>
  • Loading branch information
Owain94 and xKylee committed Jan 14, 2020
1 parent 4f7eeb3 commit c7c75e1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.awt.geom.Arc2D;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.InventoryID;
import net.runelite.api.Point;
import net.runelite.api.Skill;
import net.runelite.api.VarPlayer;
Expand All @@ -46,7 +45,6 @@
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.tooltip.Tooltip;
import net.runelite.client.ui.overlay.tooltip.TooltipManager;
import net.runelite.client.util.Graceful;
import org.apache.commons.lang3.StringUtils;

public class StatusOrbsOverlay extends Overlay
Expand Down Expand Up @@ -187,7 +185,7 @@ public Dimension render(Graphics2D g)
{
double recoverRate = (48 + client.getBoostedSkillLevel(Skill.AGILITY)) / 360000.0;

recoverRate *= Graceful.calculateRecoveryRate(client.getItemContainer(InventoryID.EQUIPMENT));
recoverRate *= plugin.getRecoverRate();

percentRun += ms * recoverRate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public class StatusOrbsPlugin extends Plugin
private int lastEnergy = 0;
private boolean localPlayerRunningToDestination;
private WorldPoint prevLocalPlayerLocation;
@Getter(AccessLevel.PACKAGE)
private double recoverRate = 1;

private BufferedImage heart;

Expand Down Expand Up @@ -289,6 +291,8 @@ else if (currentHP > maxHP)

prevLocalPlayerLocation = client.getLocalPlayer().getWorldLocation();

recoverRate = Graceful.calculateRecoveryRate(client.getItemContainer(InventoryID.EQUIPMENT));

if (this.replaceOrbText)
{
setRunOrbText(getEstimatedRunTimeRemaining(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,36 +129,71 @@ public static double calculateRecoveryRate(final ItemContainer equipment)

public static boolean hasHood(final Item[] items)
{
if (items.length < EquipmentInventorySlot.HEAD.getSlotIdx())
{
return false;
}

return HOOD.ids.contains(items[EquipmentInventorySlot.HEAD.getSlotIdx()].getId());
}

public static boolean hasTop(final Item[] items)
{
if (items.length < EquipmentInventorySlot.BODY.getSlotIdx())
{
return false;
}

return TOP.ids.contains(items[EquipmentInventorySlot.BODY.getSlotIdx()].getId());
}

public static boolean hasLegs(final Item[] items)
{
if (items.length < EquipmentInventorySlot.LEGS.getSlotIdx())
{
return false;
}

return LEGS.ids.contains(items[EquipmentInventorySlot.LEGS.getSlotIdx()].getId());
}

public static boolean hasGloves(final Item[] items)
{
if (items.length < EquipmentInventorySlot.GLOVES.getSlotIdx())
{
return false;
}

return GLOVES.ids.contains(items[EquipmentInventorySlot.GLOVES.getSlotIdx()].getId());
}

public static boolean hasBoots(final Item[] items)
{
if (items.length < EquipmentInventorySlot.BOOTS.getSlotIdx())
{
return false;
}

return BOOTS.ids.contains(items[EquipmentInventorySlot.BOOTS.getSlotIdx()].getId());
}

public static boolean hasCape(final Item[] items)
{
if (items.length < EquipmentInventorySlot.CAPE.getSlotIdx())
{
return false;
}

return CAPE.ids.contains(items[EquipmentInventorySlot.CAPE.getSlotIdx()].getId());
}

public static boolean hasFullSet(final Item[] items)
{
if (items.length < EquipmentInventorySlot.BOOTS.getSlotIdx())
{
return false;
}

return HOOD.ids.contains(items[EquipmentInventorySlot.HEAD.getSlotIdx()].getId())
&& TOP.ids.contains(items[EquipmentInventorySlot.BODY.getSlotIdx()].getId())
&& LEGS.ids.contains(items[EquipmentInventorySlot.LEGS.getSlotIdx()].getId())
Expand Down

0 comments on commit c7c75e1

Please sign in to comment.