banlistplugin: combine nested if statements

This commit is contained in:
sdburns1998
2019-07-07 02:14:42 +02:00
parent d2a90b7303
commit b5cbb48575

View File

@@ -122,9 +122,7 @@ public class BanListPlugin extends Plugin
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (event.getGroup().equals("banlist"))
{
if (event.getKey().equals("bannedPlayers"))
if (event.getGroup().equals("banlist")&& event.getKey().equals("bannedPlayers"))
{
for (String manual : Text.fromCSV(config.getBannedPlayers()))
{
@@ -135,7 +133,6 @@ public class BanListPlugin extends Plugin
}
}
}
}
public void updateConfig()
{
@@ -202,9 +199,7 @@ public class BanListPlugin extends Plugin
@Subscribe
public void onWidgetLoaded(WidgetLoaded widgetLoaded)
{
if (this.highlightInTrade)
{
if (widgetLoaded.getGroupId() == 335)
if (this.highlightInTrade && widgetLoaded.getGroupId() == 335)
{ //if trading window was loaded
clientThread.invokeLater(() ->
{
@@ -221,36 +216,26 @@ public class BanListPlugin extends Plugin
});
}
}
}
/**
* Compares player name to everything in the ban lists
*/
private ListType checkScamList(String nameToBeChecked)
{
if (wdrScamArrayList.size() > 0 && this.enableWDR)
{
if (wdrScamArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
if (wdrScamArrayList.size() > 0 && this.enableWDR && wdrScamArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{
return ListType.WEDORAIDSSCAM_LIST;
}
}
if (runeWatchArrayList.size() > 0 && this.enableRuneWatch)
{
if (runeWatchArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
if (runeWatchArrayList.size() > 0 && this.enableRuneWatch && runeWatchArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{
return ListType.RUNEWATCH_LIST;
}
}
if (manualBans.size() > 0)
{
if (manualBans.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
if (manualBans.size() > 0 && manualBans.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{
return ListType.MANUAL_LIST;
}
}
return null;
}
@@ -258,13 +243,10 @@ public class BanListPlugin extends Plugin
private ListType checkToxicList(String nameToBeChecked)
{
if (wdrToxicArrayList.size() > 0 && this.enableWDR)
{
if (wdrToxicArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
if (wdrToxicArrayList.size() > 0 && this.enableWDR && wdrToxicArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{
return ListType.WEDORAIDSTOXIC_LIST;
}
}
return null;
}