bank: Fix NPE in PostScriptFired subscriber (#12342)

The bank widget can become null before the bank build script finishes by
holding the bank close key as the bank is opened. This commit adds a
null check to avoid this possible NPE.
This commit is contained in:
honeyhoney
2020-08-24 22:05:56 +01:00
committed by GitHub
parent e1ef747ed9
commit 7efd8d18d1

View File

@@ -232,6 +232,8 @@ public class BankPlugin extends Plugin
final Widget[] children = bankItemContainer.getChildren(); final Widget[] children = bankItemContainer.getChildren();
long geTotal = 0, haTotal = 0; long geTotal = 0, haTotal = 0;
if (children != null)
{
log.debug("Computing bank price of {} items", bankContainer.size()); log.debug("Computing bank price of {} items", bankContainer.size());
// The first components are the bank items, followed by tabs etc. There are always 816 components regardless // The first components are the bank items, followed by tabs etc. There are always 816 components regardless
@@ -250,6 +252,7 @@ public class BankPlugin extends Plugin
Widget bankTitle = client.getWidget(WidgetInfo.BANK_TITLE_BAR); Widget bankTitle = client.getWidget(WidgetInfo.BANK_TITLE_BAR);
bankTitle.setText(bankTitle.getText() + createValueText(geTotal, haTotal)); bankTitle.setText(bankTitle.getText() + createValueText(geTotal, haTotal));
} }
}
else if (event.getScriptId() == ScriptID.BANKMAIN_SEARCH_REFRESH) else if (event.getScriptId() == ScriptID.BANKMAIN_SEARCH_REFRESH)
{ {
// vanilla only lays out the bank every 40 client ticks, so if the search input has changed, // vanilla only lays out the bank every 40 client ticks, so if the search input has changed,