From ffa85cbc791c13a979efa00c5c45f5b38eb71701 Mon Sep 17 00:00:00 2001 From: gazivodag Date: Mon, 24 Jun 2019 18:36:58 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=94=E2=9C=94=E2=9C=94=20TODO:=20Make=20if?= =?UTF-8?q?=20check=20for=20empty=20looting=20bag=20so=20it=20doesn't=20th?= =?UTF-8?q?row=20any=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LootingBagViewerPlugin.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerPlugin.java index 0a7ed4ba03..3124d0fe51 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerPlugin.java @@ -31,6 +31,7 @@ import com.google.inject.Provides; import javax.inject.Inject; import lombok.Getter; import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.WidgetHiddenChanged; @@ -54,8 +55,8 @@ import net.runelite.client.ui.overlay.OverlayManager; * TODO: Remember current looting bag value when client restarts * TODO: Write an event for picking up an item (with opened looting bag) and add its price to the current looting bag value * TODO: Write something to capture adding items to a looting bag and add its price to the current looting bag value - * TODO: Make if check for empty looting bag so it doesn't throw any errors */ +@Slf4j public class LootingBagViewerPlugin extends Plugin { @Inject @@ -112,7 +113,7 @@ public class LootingBagViewerPlugin extends Plugin { if (configChanged.getKey().equals("renderViewer")) { - if (Boolean.parseBoolean(configChanged.getNewValue()) == true) + if (Boolean.parseBoolean(configChanged.getNewValue())) { overlayManager.add(overlay); } @@ -123,7 +124,7 @@ public class LootingBagViewerPlugin extends Plugin } if (configChanged.getKey().equals("renderLootingBag")) { - if (Boolean.parseBoolean(configChanged.getNewValue()) == true) + if (Boolean.parseBoolean(configChanged.getNewValue())) { overlayManager.add(widgetOverlay); } @@ -147,16 +148,22 @@ public class LootingBagViewerPlugin extends Plugin clientThread.invokeLater(() -> { Widget value = client.getWidget(81, 6); + log.debug("val: {}", value.getText()); + if (!Strings.isNullOrEmpty(value.getText())) { - String str = value.getText(); - str = str.replace("Bag value: ", "") - .replace("Value: ", "") - .replace(" coins", "") - .replace(",", ""); + if (value.getText().equals("Value: -")) { + setValueToShow(-1); + } else { + String str = value.getText(); + str = str.replace("Bag value: ", "") + .replace("Value: ", "") + .replace(" coins", "") + .replace(",", ""); - int val = Integer.parseInt(str); - setValueToShow(Math.round(val) / 1000); + int val = Integer.parseInt(str); + setValueToShow(Math.round(val) / 1000); + } } }); }