Merge pull request #1110 from deathbeam/fix-menu-manager
Add null-check for Client to MenuManager
This commit is contained in:
@@ -84,6 +84,12 @@ public class MenuManager
|
|||||||
|
|
||||||
// add to surrounding npcs
|
// add to surrounding npcs
|
||||||
Client client = clientProvider.get();
|
Client client = clientProvider.get();
|
||||||
|
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (NPC npc : client.getNpcs())
|
for (NPC npc : client.getNpcs())
|
||||||
{
|
{
|
||||||
NPCComposition composition = npc.getComposition();
|
NPCComposition composition = npc.getComposition();
|
||||||
@@ -97,6 +103,12 @@ public class MenuManager
|
|||||||
|
|
||||||
// remove this option from all npc compositions
|
// remove this option from all npc compositions
|
||||||
Client client = clientProvider.get();
|
Client client = clientProvider.get();
|
||||||
|
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (NPC npc : client.getNpcs())
|
for (NPC npc : client.getNpcs())
|
||||||
{
|
{
|
||||||
NPCComposition composition = npc.getComposition();
|
NPCComposition composition = npc.getComposition();
|
||||||
@@ -129,6 +141,12 @@ public class MenuManager
|
|||||||
private boolean menuContainsCustomMenu(WidgetMenuOption customMenuOption)
|
private boolean menuContainsCustomMenu(WidgetMenuOption customMenuOption)
|
||||||
{
|
{
|
||||||
Client client = clientProvider.get();
|
Client client = clientProvider.get();
|
||||||
|
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (MenuEntry menuEntry : client.getMenuEntries())
|
for (MenuEntry menuEntry : client.getMenuEntries())
|
||||||
{
|
{
|
||||||
String option = menuEntry.getOption();
|
String option = menuEntry.getOption();
|
||||||
@@ -147,10 +165,15 @@ public class MenuManager
|
|||||||
{
|
{
|
||||||
int widgetId = event.getActionParam1();
|
int widgetId = event.getActionParam1();
|
||||||
Collection<WidgetMenuOption> options = managedMenuOptions.get(widgetId);
|
Collection<WidgetMenuOption> options = managedMenuOptions.get(widgetId);
|
||||||
|
Client client = clientProvider.get();
|
||||||
|
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (WidgetMenuOption currentMenu : options)
|
for (WidgetMenuOption currentMenu : options)
|
||||||
{
|
{
|
||||||
Client client = clientProvider.get();
|
|
||||||
|
|
||||||
if (!menuContainsCustomMenu(currentMenu))//Don't add if we have already added it to this widget
|
if (!menuContainsCustomMenu(currentMenu))//Don't add if we have already added it to this widget
|
||||||
{
|
{
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||||
@@ -307,6 +330,11 @@ public class MenuManager
|
|||||||
{
|
{
|
||||||
Client client = clientProvider.get();
|
Client client = clientProvider.get();
|
||||||
|
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
client.getPlayerOptions()[playerOptionIndex] = menuText;
|
client.getPlayerOptions()[playerOptionIndex] = menuText;
|
||||||
client.getPlayerOptionsPriorities()[playerOptionIndex] = true;
|
client.getPlayerOptionsPriorities()[playerOptionIndex] = true;
|
||||||
client.getPlayerMenuTypes()[playerOptionIndex] = MenuAction.RUNELITE.getId();
|
client.getPlayerMenuTypes()[playerOptionIndex] = MenuAction.RUNELITE.getId();
|
||||||
@@ -318,8 +346,12 @@ public class MenuManager
|
|||||||
{
|
{
|
||||||
Client client = clientProvider.get();
|
Client client = clientProvider.get();
|
||||||
|
|
||||||
client.getPlayerOptions()[playerOptionIndex] = null;
|
if (client == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
client.getPlayerOptions()[playerOptionIndex] = null;
|
||||||
playerMenuIndexMap.remove(playerOptionIndex);
|
playerMenuIndexMap.remove(playerOptionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,8 +363,8 @@ public class MenuManager
|
|||||||
private int findEmptyPlayerMenuIndex()
|
private int findEmptyPlayerMenuIndex()
|
||||||
{
|
{
|
||||||
int index = IDX_LOWER;
|
int index = IDX_LOWER;
|
||||||
|
|
||||||
Client client = clientProvider.get();
|
Client client = clientProvider.get();
|
||||||
|
|
||||||
if (client == null)
|
if (client == null)
|
||||||
{
|
{
|
||||||
return IDX_UPPER;
|
return IDX_UPPER;
|
||||||
|
|||||||
Reference in New Issue
Block a user