graceful: Add array length checks (#2236)
* graceful: Add array length checks * Update StatusOrbsOverlay.java Co-authored-by: Kyle <48519776+xKylee@users.noreply.github.com>
This commit is contained in:
@@ -35,7 +35,6 @@ import java.awt.Stroke;
|
||||
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;
|
||||
@@ -46,7 +45,6 @@ import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
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
|
||||
@@ -187,7 +185,7 @@ public class StatusOrbsOverlay extends Overlay
|
||||
{
|
||||
double recoverRate = (48 + client.getBoostedSkillLevel(Skill.AGILITY)) / 360000.0;
|
||||
|
||||
recoverRate *= Graceful.calculateRecoveryRate(client.getItemContainer(InventoryID.EQUIPMENT));
|
||||
recoverRate *= plugin.getRecoverRate();
|
||||
|
||||
percentRun += ms * recoverRate;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -289,6 +291,8 @@ public class StatusOrbsPlugin extends Plugin
|
||||
|
||||
prevLocalPlayerLocation = client.getLocalPlayer().getWorldLocation();
|
||||
|
||||
recoverRate = Graceful.calculateRecoveryRate(client.getItemContainer(InventoryID.EQUIPMENT));
|
||||
|
||||
if (this.replaceOrbText)
|
||||
{
|
||||
setRunOrbText(getEstimatedRunTimeRemaining(true));
|
||||
|
||||
@@ -129,36 +129,71 @@ public enum Graceful
|
||||
|
||||
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())
|
||||
|
||||
Reference in New Issue
Block a user