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), INVENTORY(WidgetID.INVENTORY_GROUP_ID, 0),
EQUIPMENT(WidgetID.EQUIPMENT_GROUP_ID, 0),
EQUIPMENT_HELMET(WidgetID.EQUIPMENT_GROUP_ID, WidgetID.Equipment.HELMET), EQUIPMENT_HELMET(WidgetID.EQUIPMENT_GROUP_ID, WidgetID.Equipment.HELMET),
EQUIPMENT_CAPE(WidgetID.EQUIPMENT_GROUP_ID, WidgetID.Equipment.CAPE), EQUIPMENT_CAPE(WidgetID.EQUIPMENT_GROUP_ID, WidgetID.Equipment.CAPE),
EQUIPMENT_AMULET(WidgetID.EQUIPMENT_GROUP_ID, WidgetID.Equipment.AMULET), EQUIPMENT_AMULET(WidgetID.EQUIPMENT_GROUP_ID, WidgetID.Equipment.AMULET),

View File

@@ -81,18 +81,17 @@ class JewelryCountOverlay extends Overlay
} }
} }
Widget[] equipment = Widget equipment = client.getWidget(WidgetInfo.EQUIPMENT);
if (equipment != null)
{
Widget[] equipmentSlots =
{ {
client.getWidget(WidgetInfo.EQUIPMENT_AMULET).getChild(1), client.getWidget(WidgetInfo.EQUIPMENT_RING).getChild(1), client.getWidget(WidgetInfo.EQUIPMENT_AMULET).getChild(1), client.getWidget(WidgetInfo.EQUIPMENT_RING).getChild(1),
client.getWidget(WidgetInfo.EQUIPMENT_GLOVES).getChild(1) client.getWidget(WidgetInfo.EQUIPMENT_GLOVES).getChild(1)
}; };
if (equipment == null) for (Widget widget : equipmentSlots)
{
return null;
}
for (Widget widget : equipment)
{ {
JewelryCharges charges = JewelryCharges.getCharges(widget.getItemId()); JewelryCharges charges = JewelryCharges.getCharges(widget.getItemId());
@@ -110,6 +109,7 @@ class JewelryCountOverlay extends Overlay
renderWidgetText(graphics, widgetBounds, charges.getCharges(), Color.white); renderWidgetText(graphics, widgetBounds, charges.getCharges(), Color.white);
} }
}
return null; return null;
} }