diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeConfig.java index 4766a0c149..b2ca3c22de 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeConfig.java @@ -55,6 +55,17 @@ public interface GrandExchangeConfig extends Config @ConfigItem( position = 3, + keyName = "enableOsbPrices", + name = "Enable OSB actively traded prices", + description = "Shows the OSBuddy actively traded price at the GE" + ) + default boolean enableOsbPrices() + { + return false; + } + + @ConfigItem( + position = 4, keyName = "enableGeLimits", name = "Enable GE Limits on GE", description = "Shows the GE Limits on the GE" @@ -65,7 +76,7 @@ public interface GrandExchangeConfig extends Config } @ConfigItem( - position = 4, + position = 5, keyName = "showTotal", name = "Show grand exchange total", description = "Show grand exchange total" @@ -76,7 +87,7 @@ public interface GrandExchangeConfig extends Config } @ConfigItem( - position = 5, + position = 6, keyName = "showExact", name = "Show exact total value", description = "Show exact total value" @@ -87,7 +98,7 @@ public interface GrandExchangeConfig extends Config } @ConfigItem( - position = 6, + position = 7, keyName = "enableAfford", name = "Enable Afford quantity on GE", description = "Shows the quantity you can buy on the GE" diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java index c75fcc794c..4c958d6179 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java @@ -30,6 +30,7 @@ package net.runelite.client.plugins.grandexchange; import com.google.common.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.inject.Provides; +import io.reactivex.schedulers.Schedulers; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStreamReader; @@ -169,6 +170,7 @@ public class GrandExchangePlugin extends Plugin private boolean quickLookup; private boolean enableNotifications; + private boolean enableOsbPrices; private boolean enableGELimits; private boolean enableAfford; @@ -275,6 +277,7 @@ public class GrandExchangePlugin extends Plugin { this.quickLookup = config.quickLookup(); this.enableNotifications = config.enableNotifications(); + this.enableOsbPrices = config.enableOsbPrices(); this.enableGELimits = config.enableGELimits(); this.enableAfford = config.enableAfford(); } @@ -577,5 +580,43 @@ public class GrandExchangePlugin extends Plugin } geText.setText(text); + + if (!this.enableOsbPrices) + { + return; + } + + // If we already have the result, use it + if (osbGrandExchangeResult != null && osbGrandExchangeResult.getItem_id() == itemId && osbGrandExchangeResult.getOverall_average() > 0) + { + geText.setText(text + OSB_GE_TEXT + QuantityFormatter.formatNumber(osbGrandExchangeResult.getOverall_average())); + } + + if (osbItem == itemId) + { + // avoid starting duplicate lookups + return; + } + + osbItem = itemId; + + log.debug("Looking up OSB item price {}", itemId); + + final String start = text; + executorService.submit(() -> + { + CLIENT.lookupItem(itemId) + .subscribeOn(Schedulers.io()) + .observeOn(Schedulers.single()) + .subscribe( + (osbresult) -> + { + osbGrandExchangeResult = osbresult; + // Update the text on the widget too + geText.setText(start + OSB_GE_TEXT + QuantityFormatter.formatNumber(osbresult.getOverall_average())); + }, + (e) -> log.debug("Error getting price of item {}", itemId, e) + ); + }); } } \ No newline at end of file