From 818dc8f0d7711a4036d83db1304f7f776ce47f39 Mon Sep 17 00:00:00 2001 From: Lulonaut Date: Wed, 8 Sep 2021 14:17:55 +0200 Subject: make sure there are autocompleted items --- .../overlays/AuctionSearchOverlay.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java index 641f8a93..8b3b21f0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java @@ -335,15 +335,17 @@ public class AuctionSearchOverlay { searchStringExtra = ""; close(); } else if(Keyboard.getEventKey() == Keyboard.KEY_TAB){ - searchString = autocompletedItems.iterator().next(); - JsonObject repoObject = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(autocompletedItems.iterator().next()); - String displayname = repoObject.get("displayname").getAsString(); - if (displayname.contains("Enchanted Book")){ - String lore = repoObject.get("lore").getAsJsonArray().iterator().next().getAsString(); - String name = lore.substring(0, lore.lastIndexOf(" ")); - searchString = Utils.cleanColour(name); - } else { - searchString = Utils.cleanColour(displayname); + if (!autocompletedItems.isEmpty()) { + searchString = autocompletedItems.iterator().next(); + JsonObject repoObject = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(autocompletedItems.iterator().next()); + String displayname = repoObject.get("displayname").getAsString(); + if (displayname.contains("Enchanted Book")){ + String lore = repoObject.get("lore").getAsJsonArray().iterator().next().getAsString(); + String name = lore.substring(0, lore.lastIndexOf(" ")); + searchString = Utils.cleanColour(name); + } else { + searchString = Utils.cleanColour(displayname); + } } } else if(Keyboard.getEventKeyState()) { textField.setFocus(true); -- cgit