runelite-client: fix jewelery plugin npe when eqipment tab is not visable

This commit is contained in:
sethtroll
2017-07-16 13:57:38 -04:00
committed by Adam
parent 33bcfc52a9
commit ad14d0152b
2 changed files with 26 additions and 24 deletions

View File

@@ -28,6 +28,8 @@ public enum WidgetInfo
{
INVENTORY(WidgetID.INVENTORY_GROUP_ID, 0),
EQUIPMENT(WidgetID.EQUIPMENT_GROUP_ID, 0),
EQUIPMENT_HELMET(WidgetID.EQUIPMENT_GROUP_ID, WidgetID.Equipment.HELMET),
EQUIPMENT_CAPE(WidgetID.EQUIPMENT_GROUP_ID, WidgetID.Equipment.CAPE),
EQUIPMENT_AMULET(WidgetID.EQUIPMENT_GROUP_ID, WidgetID.Equipment.AMULET),

View File

@@ -81,34 +81,34 @@ class JewelryCountOverlay extends Overlay
}
}
Widget[] equipment =
{
client.getWidget(WidgetInfo.EQUIPMENT_AMULET).getChild(1), client.getWidget(WidgetInfo.EQUIPMENT_RING).getChild(1),
client.getWidget(WidgetInfo.EQUIPMENT_GLOVES).getChild(1)
};
Widget equipment = client.getWidget(WidgetInfo.EQUIPMENT);
if (equipment == null)
if (equipment != null)
{
return null;
}
for (Widget widget : equipment)
{
JewelryCharges charges = JewelryCharges.getCharges(widget.getItemId());
if (charges == null || widget.isHidden())
Widget[] equipmentSlots =
{
continue;
client.getWidget(WidgetInfo.EQUIPMENT_AMULET).getChild(1), client.getWidget(WidgetInfo.EQUIPMENT_RING).getChild(1),
client.getWidget(WidgetInfo.EQUIPMENT_GLOVES).getChild(1)
};
for (Widget widget : equipmentSlots)
{
JewelryCharges charges = JewelryCharges.getCharges(widget.getItemId());
if (charges == null || widget.isHidden())
{
continue;
}
Rectangle widgetBounds = widget.getBounds();
//to match inventory text
widgetBounds.x -= 5;
widgetBounds.y -= 1;
renderWidgetText(graphics, widgetBounds, charges.getCharges(), Color.white);
}
Rectangle widgetBounds = widget.getBounds();
//to match inventory text
widgetBounds.x -= 5;
widgetBounds.y -= 1;
renderWidgetText(graphics, widgetBounds, charges.getCharges(), Color.white);
}
return null;