client: add option to use wiki traded prices

This commit is contained in:
Adam
2021-03-09 14:19:49 -05:00
parent 48352f11c9
commit 9e20540214
2 changed files with 31 additions and 22 deletions

View File

@@ -381,17 +381,6 @@ public interface RuneLiteConfig extends Config
return ComponentConstants.STANDARD_BACKGROUND_COLOR;
}
@ConfigItem(
keyName = "blockExtraMouseButtons",
name = "Block Extra Mouse Buttons",
description = "Blocks extra mouse buttons (4 and above)",
position = 44
)
default boolean blockExtraMouseButtons()
{
return true;
}
@ConfigItem(
keyName = "sidebarToggleKey",
name = "Sidebar Toggle Key",
@@ -415,4 +404,26 @@ public interface RuneLiteConfig extends Config
{
return new Keybind(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK);
}
@ConfigItem(
keyName = "blockExtraMouseButtons",
name = "Block extra mouse buttons",
description = "Blocks extra mouse buttons (4 and above)",
position = 50
)
default boolean blockExtraMouseButtons()
{
return true;
}
@ConfigItem(
keyName = "useWikiItemPrices",
name = "Use actively traded price",
description = "Use actively traded prices, sourced from the RuneScape wiki, for item prices",
position = 51
)
default boolean useWikiItemPrices()
{
return true;
}
}

View File

@@ -55,6 +55,7 @@ import net.runelite.api.SpritePixels;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.PostItemComposition;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.util.AsyncBufferedImage;
@@ -86,6 +87,7 @@ public class ItemManager
private final Client client;
private final ClientThread clientThread;
private final ItemClient itemClient;
private final RuneLiteConfig runeLiteConfig;
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
@@ -170,11 +172,12 @@ public class ItemManager
@Inject
public ItemManager(Client client, ScheduledExecutorService scheduledExecutorService, ClientThread clientThread,
OkHttpClient okHttpClient, EventBus eventBus)
OkHttpClient okHttpClient, EventBus eventBus, RuneLiteConfig runeLiteConfig)
{
this.client = client;
this.clientThread = clientThread;
this.itemClient = new ItemClient(okHttpClient);
this.runeLiteConfig = runeLiteConfig;
scheduledExecutorService.scheduleWithFixedDelay(this::loadPrices, 0, 30, TimeUnit.MINUTES);
scheduledExecutorService.submit(this::loadStats);
@@ -292,17 +295,17 @@ public class ItemManager
*/
public int getItemPrice(int itemID)
{
return getItemPrice(itemID, false);
return getItemPriceWithSource(itemID, runeLiteConfig.useWikiItemPrices());
}
/**
* Look up an item's price
*
* @param itemID item id
* @param ignoreUntradeableMap should the price returned ignore items that are not tradeable for coins in regular way
* @param useWikiPrice use the actively traded/wiki price
* @return item price
*/
public int getItemPrice(int itemID, boolean ignoreUntradeableMap)
public int getItemPriceWithSource(int itemID, boolean useWikiPrice)
{
if (itemID == COINS_995)
{
@@ -330,19 +333,14 @@ public class ItemManager
if (ip != null)
{
price += ip.getPrice();
price = useWikiPrice && ip.getWikiPrice() > 0 ? ip.getWikiPrice() : ip.getPrice();
}
}
else
{
for (final ItemMapping mappedItem : mappedItems)
{
if (ignoreUntradeableMap && mappedItem.isUntradeable())
{
continue;
}
price += getItemPrice(mappedItem.getTradeableItem(), ignoreUntradeableMap) * mappedItem.getQuantity();
price += getItemPriceWithSource(mappedItem.getTradeableItem(), useWikiPrice) * mappedItem.getQuantity();
}
}