menuentryswapper: remove early return (#797)

This commit is contained in:
se7enAte9
2019-06-28 15:07:07 -04:00
committed by Kyleeld
parent e7af9222fb
commit 8b3a70d115

View File

@@ -907,33 +907,27 @@ public class MenuEntrySwapperPlugin extends Plugin
} }
} }
Player[] players = client.getCachedPlayers();
Player player = null;
int identifier = event.getIdentifier();
if (identifier >= 0 && identifier < players.length)
{
player = players[identifier];
}
if (player == null)
{
return;
}
//If the option is already to walk there, or cancel we don't need to swap it with anything //If the option is already to walk there, or cancel we don't need to swap it with anything
if (pOptionToReplace.equals(CANCEL) || pOptionToReplace.equals(WALK_HERE)) if (!pOptionToReplace.equals(CANCEL) && !pOptionToReplace.equals(WALK_HERE))
{ {
return; Player[] players = client.getCachedPlayers();
} int identifier = event.getIdentifier();
if (((config.getRemoveFreezePlayerCoX() && client.getVar(Varbits.IN_RAID) == 1) if (identifier >= 0 && identifier < players.length)
|| (config.getRemoveFreezePlayerToB() && client.getVar(Varbits.THEATRE_OF_BLOOD) == 2))
&& (player.isFriend() || player.isClanMember())
&& CAST_OPTIONS_KEYWORDS.contains(pOptionToReplace))
{ {
addswap(pOptionToReplace); Player player = players[identifier];
if (player != null)
{
if (((config.getRemoveFreezePlayerCoX() && client.getVar(Varbits.IN_RAID) == 1)
|| (config.getRemoveFreezePlayerToB() && client.getVar(Varbits.THEATRE_OF_BLOOD) == 2))
&& (player.isFriend() || player.isClanMember())
&& CAST_OPTIONS_KEYWORDS.contains(pOptionToReplace))
{
addswap(pOptionToReplace);
}
}
} }
}
if (option.equals("talk-to")) if (option.equals("talk-to"))
{ {