client: Remove OSB prices from examing and from the GE JPanel
This commit is contained in:
@@ -26,7 +26,6 @@ package net.runelite.client.plugins.examine;
|
|||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
@@ -50,7 +49,6 @@ import static net.runelite.api.widgets.WidgetInfo.SEED_VAULT_ITEM_CONTAINER;
|
|||||||
import static net.runelite.api.widgets.WidgetInfo.TO_CHILD;
|
import static net.runelite.api.widgets.WidgetInfo.TO_CHILD;
|
||||||
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
|
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.callback.ClientThread;
|
|
||||||
import net.runelite.client.chat.ChatColorType;
|
import net.runelite.client.chat.ChatColorType;
|
||||||
import net.runelite.client.chat.ChatMessageBuilder;
|
import net.runelite.client.chat.ChatMessageBuilder;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
@@ -62,7 +60,6 @@ import net.runelite.client.plugins.PluginDescriptor;
|
|||||||
import net.runelite.client.plugins.PluginType;
|
import net.runelite.client.plugins.PluginType;
|
||||||
import net.runelite.client.util.QuantityFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
import net.runelite.http.api.examine.ExamineClient;
|
import net.runelite.http.api.examine.ExamineClient;
|
||||||
import net.runelite.http.api.osbuddy.OSBGrandExchangeClient;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submits examine info to the api
|
* Submits examine info to the api
|
||||||
@@ -82,7 +79,6 @@ public class ExaminePlugin extends Plugin
|
|||||||
private static final Pattern X_PATTERN = Pattern.compile("^\\d+ x ");
|
private static final Pattern X_PATTERN = Pattern.compile("^\\d+ x ");
|
||||||
|
|
||||||
private final Deque<PendingExamine> pending = new ArrayDeque<>();
|
private final Deque<PendingExamine> pending = new ArrayDeque<>();
|
||||||
private final OSBGrandExchangeClient CLIENT = new OSBGrandExchangeClient();
|
|
||||||
private final Cache<CacheKey, Boolean> cache = CacheBuilder.newBuilder()
|
private final Cache<CacheKey, Boolean> cache = CacheBuilder.newBuilder()
|
||||||
.maximumSize(128L)
|
.maximumSize(128L)
|
||||||
.build();
|
.build();
|
||||||
@@ -93,9 +89,6 @@ public class ExaminePlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ClientThread clientThread;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ItemManager itemManager;
|
private ItemManager itemManager;
|
||||||
|
|
||||||
@@ -363,62 +356,44 @@ public class ExaminePlugin extends Plugin
|
|||||||
if (gePrice > 0)
|
if (gePrice > 0)
|
||||||
{
|
{
|
||||||
int finalQuantity = quantity;
|
int finalQuantity = quantity;
|
||||||
CLIENT.lookupItem(id)
|
message
|
||||||
.subscribeOn(Schedulers.io())
|
.append(ChatColorType.NORMAL)
|
||||||
.observeOn(Schedulers.single())
|
.append(" GE ")
|
||||||
.subscribe(
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
(osbresult) ->
|
.append(QuantityFormatter.formatNumber(gePrice * finalQuantity));
|
||||||
{
|
|
||||||
message
|
|
||||||
.append(ChatColorType.NORMAL)
|
|
||||||
.append(" GE ")
|
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
|
||||||
.append(QuantityFormatter.formatNumber(gePrice * finalQuantity));
|
|
||||||
|
|
||||||
if (osbresult != null)
|
if (finalQuantity > 1)
|
||||||
{
|
{
|
||||||
message
|
message
|
||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.NORMAL)
|
||||||
.append(" OSB ")
|
.append(" (")
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append(QuantityFormatter.formatNumber(osbresult.getOverall_average() * finalQuantity));
|
.append(QuantityFormatter.formatNumber(gePrice))
|
||||||
}
|
.append(ChatColorType.NORMAL)
|
||||||
|
.append("ea)");
|
||||||
|
}
|
||||||
|
|
||||||
if (finalQuantity > 1)
|
message
|
||||||
{
|
.append(ChatColorType.NORMAL)
|
||||||
message
|
.append(" HA value ")
|
||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append(" (")
|
.append(QuantityFormatter.formatNumber(alchPrice * finalQuantity));
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
|
||||||
.append(QuantityFormatter.formatNumber(gePrice))
|
|
||||||
.append(ChatColorType.NORMAL)
|
|
||||||
.append("ea)");
|
|
||||||
}
|
|
||||||
|
|
||||||
message
|
if (finalQuantity > 1)
|
||||||
.append(ChatColorType.NORMAL)
|
{
|
||||||
.append(" HA value ")
|
message
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.NORMAL)
|
||||||
.append(QuantityFormatter.formatNumber(alchPrice * finalQuantity));
|
.append(" (")
|
||||||
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
|
.append(QuantityFormatter.formatNumber(alchPrice))
|
||||||
|
.append(ChatColorType.NORMAL)
|
||||||
|
.append("ea)");
|
||||||
|
}
|
||||||
|
|
||||||
if (finalQuantity > 1)
|
chatMessageManager.queue(QueuedMessage.builder()
|
||||||
{
|
.type(ChatMessageType.ITEM_EXAMINE)
|
||||||
message
|
.runeLiteFormattedMessage(message.build())
|
||||||
.append(ChatColorType.NORMAL)
|
.build());
|
||||||
.append(" (")
|
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
|
||||||
.append(QuantityFormatter.formatNumber(alchPrice))
|
|
||||||
.append(ChatColorType.NORMAL)
|
|
||||||
.append("ea)");
|
|
||||||
}
|
|
||||||
|
|
||||||
chatMessageManager.queue(QueuedMessage.builder()
|
|
||||||
.type(ChatMessageType.ITEM_EXAMINE)
|
|
||||||
.runeLiteFormattedMessage(message.build())
|
|
||||||
.build());
|
|
||||||
},
|
|
||||||
(e) -> log.error(e.toString())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,17 +55,6 @@ public interface GrandExchangeConfig extends Config
|
|||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 3,
|
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",
|
keyName = "enableGeLimits",
|
||||||
name = "Enable GE Limits on GE",
|
name = "Enable GE Limits on GE",
|
||||||
description = "Shows the GE Limits on the GE"
|
description = "Shows the GE Limits on the GE"
|
||||||
@@ -76,7 +65,7 @@ public interface GrandExchangeConfig extends Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 5,
|
position = 4,
|
||||||
keyName = "showTotal",
|
keyName = "showTotal",
|
||||||
name = "Show grand exchange total",
|
name = "Show grand exchange total",
|
||||||
description = "Show grand exchange total"
|
description = "Show grand exchange total"
|
||||||
@@ -87,7 +76,7 @@ public interface GrandExchangeConfig extends Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 6,
|
position = 5,
|
||||||
keyName = "showExact",
|
keyName = "showExact",
|
||||||
name = "Show exact total value",
|
name = "Show exact total value",
|
||||||
description = "Show exact total value"
|
description = "Show exact total value"
|
||||||
@@ -98,7 +87,7 @@ public interface GrandExchangeConfig extends Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 7,
|
position = 6,
|
||||||
keyName = "enableAfford",
|
keyName = "enableAfford",
|
||||||
name = "Enable Afford quantity on GE",
|
name = "Enable Afford quantity on GE",
|
||||||
description = "Shows the quantity you can buy on the GE"
|
description = "Shows the quantity you can buy on the GE"
|
||||||
|
|||||||
@@ -54,8 +54,7 @@ class GrandExchangeItemPanel extends JPanel
|
|||||||
{
|
{
|
||||||
private static final Dimension ICON_SIZE = new Dimension(32, 32);
|
private static final Dimension ICON_SIZE = new Dimension(32, 32);
|
||||||
|
|
||||||
GrandExchangeItemPanel(AsyncBufferedImage icon, String name, int itemID, int gePrice, int osbPrice, int
|
GrandExchangeItemPanel(AsyncBufferedImage icon, String name, int itemID, int gePrice, int haPrice, int geItemLimit)
|
||||||
haPrice, int geItemLimit)
|
|
||||||
{
|
{
|
||||||
BorderLayout layout = new BorderLayout();
|
BorderLayout layout = new BorderLayout();
|
||||||
layout.setHgap(5);
|
layout.setHgap(5);
|
||||||
@@ -110,7 +109,7 @@ class GrandExchangeItemPanel extends JPanel
|
|||||||
add(itemIcon, BorderLayout.LINE_START);
|
add(itemIcon, BorderLayout.LINE_START);
|
||||||
|
|
||||||
// Item details panel
|
// Item details panel
|
||||||
JPanel rightPanel = new JPanel(new GridLayout((osbPrice > 0) ? 5 : 4, 1));
|
JPanel rightPanel = new JPanel(new GridLayout(4, 1));
|
||||||
panels.add(rightPanel);
|
panels.add(rightPanel);
|
||||||
rightPanel.setBackground(background);
|
rightPanel.setBackground(background);
|
||||||
|
|
||||||
@@ -135,15 +134,6 @@ class GrandExchangeItemPanel extends JPanel
|
|||||||
gePriceLabel.setForeground(ColorScheme.GRAND_EXCHANGE_PRICE);
|
gePriceLabel.setForeground(ColorScheme.GRAND_EXCHANGE_PRICE);
|
||||||
rightPanel.add(gePriceLabel);
|
rightPanel.add(gePriceLabel);
|
||||||
|
|
||||||
// OSB Price
|
|
||||||
if (osbPrice > 0)
|
|
||||||
{
|
|
||||||
JLabel osbPricelabel = new JLabel();
|
|
||||||
osbPricelabel.setText("OSB Price: " + QuantityFormatter.formatNumber(osbPrice) + " gp");
|
|
||||||
osbPricelabel.setForeground(ColorScheme.GRAND_EXCHANGE_PRICE);
|
|
||||||
rightPanel.add(osbPricelabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Alch price
|
// Alch price
|
||||||
JLabel haPriceLabel = new JLabel();
|
JLabel haPriceLabel = new JLabel();
|
||||||
haPriceLabel.setText("Alch Price: " + QuantityFormatter.formatNumber(haPrice) + " gp");
|
haPriceLabel.setText("Alch Price: " + QuantityFormatter.formatNumber(haPrice) + " gp");
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class GrandExchangePanel extends PluginPanel
|
|||||||
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||||
|
|
||||||
// Search Panel
|
// Search Panel
|
||||||
searchPanel = new GrandExchangeSearchPanel(clientThread, itemManager, executor, config);
|
searchPanel = new GrandExchangeSearchPanel(clientThread, itemManager, executor);
|
||||||
|
|
||||||
//Offers Panel
|
//Offers Panel
|
||||||
offersPanel = new GrandExchangeOffersPanel();
|
offersPanel = new GrandExchangeOffersPanel();
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ package net.runelite.client.plugins.grandexchange;
|
|||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@@ -170,7 +169,6 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
|
|
||||||
private boolean quickLookup;
|
private boolean quickLookup;
|
||||||
private boolean enableNotifications;
|
private boolean enableNotifications;
|
||||||
private boolean enableOsbPrices;
|
|
||||||
private boolean enableGELimits;
|
private boolean enableGELimits;
|
||||||
private boolean enableAfford;
|
private boolean enableAfford;
|
||||||
|
|
||||||
@@ -277,7 +275,6 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
{
|
{
|
||||||
this.quickLookup = config.quickLookup();
|
this.quickLookup = config.quickLookup();
|
||||||
this.enableNotifications = config.enableNotifications();
|
this.enableNotifications = config.enableNotifications();
|
||||||
this.enableOsbPrices = config.enableOsbPrices();
|
|
||||||
this.enableGELimits = config.enableGELimits();
|
this.enableGELimits = config.enableGELimits();
|
||||||
this.enableAfford = config.enableAfford();
|
this.enableAfford = config.enableAfford();
|
||||||
}
|
}
|
||||||
@@ -580,43 +577,5 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
geText.setText(text);
|
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)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
@@ -53,7 +52,6 @@ import net.runelite.client.ui.components.IconTextField;
|
|||||||
import net.runelite.client.ui.components.PluginErrorPanel;
|
import net.runelite.client.ui.components.PluginErrorPanel;
|
||||||
import net.runelite.client.util.AsyncBufferedImage;
|
import net.runelite.client.util.AsyncBufferedImage;
|
||||||
import net.runelite.http.api.item.ItemPrice;
|
import net.runelite.http.api.item.ItemPrice;
|
||||||
import net.runelite.http.api.osbuddy.OSBGrandExchangeClient;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This panel holds the search section of the Grand Exchange Plugin.
|
* This panel holds the search section of the Grand Exchange Plugin.
|
||||||
@@ -63,8 +61,6 @@ import net.runelite.http.api.osbuddy.OSBGrandExchangeClient;
|
|||||||
@Singleton
|
@Singleton
|
||||||
class GrandExchangeSearchPanel extends JPanel
|
class GrandExchangeSearchPanel extends JPanel
|
||||||
{
|
{
|
||||||
@Inject
|
|
||||||
private static final OSBGrandExchangeClient OSBCLIENT = new OSBGrandExchangeClient();
|
|
||||||
private static final String ERROR_PANEL = "ERROR_PANEL";
|
private static final String ERROR_PANEL = "ERROR_PANEL";
|
||||||
private static final String RESULTS_PANEL = "RESULTS_PANEL";
|
private static final String RESULTS_PANEL = "RESULTS_PANEL";
|
||||||
private static final int MAX_SEARCH_ITEMS = 100;
|
private static final int MAX_SEARCH_ITEMS = 100;
|
||||||
@@ -78,9 +74,6 @@ class GrandExchangeSearchPanel extends JPanel
|
|||||||
|
|
||||||
private final IconTextField searchBar = new IconTextField();
|
private final IconTextField searchBar = new IconTextField();
|
||||||
|
|
||||||
private final GrandExchangeConfig config;
|
|
||||||
|
|
||||||
|
|
||||||
/* The results container, this will hold all the individual ge item panels */
|
/* The results container, this will hold all the individual ge item panels */
|
||||||
private final JPanel searchItemsPanel = new JPanel();
|
private final JPanel searchItemsPanel = new JPanel();
|
||||||
|
|
||||||
@@ -95,12 +88,11 @@ class GrandExchangeSearchPanel extends JPanel
|
|||||||
@Setter(AccessLevel.PACKAGE)
|
@Setter(AccessLevel.PACKAGE)
|
||||||
private Map<Integer, Integer> itemGELimits = Collections.emptyMap();
|
private Map<Integer, Integer> itemGELimits = Collections.emptyMap();
|
||||||
|
|
||||||
GrandExchangeSearchPanel(final ClientThread clientThread, final ItemManager itemManager, final ScheduledExecutorService executor, final GrandExchangeConfig config)
|
GrandExchangeSearchPanel(final ClientThread clientThread, final ItemManager itemManager, final ScheduledExecutorService executor)
|
||||||
{
|
{
|
||||||
this.clientThread = clientThread;
|
this.clientThread = clientThread;
|
||||||
this.itemManager = itemManager;
|
this.itemManager = itemManager;
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.config = config;
|
|
||||||
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||||
@@ -245,20 +237,9 @@ class GrandExchangeSearchPanel extends JPanel
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (GrandExchangeItems item : itemsList)
|
for (GrandExchangeItems item : itemsList)
|
||||||
{
|
{
|
||||||
final int[] osbPrice = {0};
|
|
||||||
if (config.enableOsbPrices())
|
|
||||||
{
|
|
||||||
OSBCLIENT.lookupItem(item.getItemId())
|
|
||||||
.subscribe(
|
|
||||||
(osbresult) -> {
|
|
||||||
osbPrice[0] = osbresult.getOverall_average();
|
|
||||||
},
|
|
||||||
(e) -> log.debug("GE : Error getting price of item {}", item.getItemId(), e)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
GrandExchangeItemPanel panel = new GrandExchangeItemPanel(item.getIcon(), item.getName(),
|
GrandExchangeItemPanel panel = new GrandExchangeItemPanel(item.getIcon(), item.getName(),
|
||||||
item.getItemId(), item.getGePrice(), osbPrice[0], item.getHaPrice(), item.getGeItemLimit());
|
item.getItemId(), item.getGePrice(), item.getHaPrice(), item.getGeItemLimit());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Add the first item directly, wrap the rest with margin. This margin hack is because
|
Add the first item directly, wrap the rest with margin. This margin hack is because
|
||||||
|
|||||||
Reference in New Issue
Block a user