Inverse collapse menu entry loop

This makes sure that menu collapses to first entry because menu is built
in inverse. Before setting the entries, inverse them back to original
order.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2019-01-17 18:31:08 +01:00
parent 0d2c32c093
commit 814277eb36

View File

@@ -35,6 +35,7 @@ import java.awt.Rectangle;
import static java.lang.Boolean.TRUE;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -308,8 +309,10 @@ public class GroundItemsPlugin extends Plugin
final List<MenuEntryWithCount> newEntries = new ArrayList<>(menuEntries.length);
outer:
for (MenuEntry menuEntry : menuEntries)
for (int i = menuEntries.length - 1; i >= 0; i--)
{
MenuEntry menuEntry = menuEntries[i];
int menuType = menuEntry.getType();
if (menuType == FIRST_OPTION || menuType == SECOND_OPTION || menuType == THIRD_OPTION
|| menuType == FOURTH_OPTION || menuType == FIFTH_OPTION || menuType == EXAMINE_ITEM)
@@ -327,6 +330,8 @@ public class GroundItemsPlugin extends Plugin
newEntries.add(new MenuEntryWithCount(menuEntry));
}
Collections.reverse(newEntries);
client.setMenuEntries(newEntries.stream().map(e ->
{
final MenuEntry entry = e.getEntry();