client: add option to use wiki traded prices
This commit is contained in:
@@ -381,17 +381,6 @@ public interface RuneLiteConfig extends Config
|
|||||||
return ComponentConstants.STANDARD_BACKGROUND_COLOR;
|
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(
|
@ConfigItem(
|
||||||
keyName = "sidebarToggleKey",
|
keyName = "sidebarToggleKey",
|
||||||
name = "Sidebar Toggle Key",
|
name = "Sidebar Toggle Key",
|
||||||
@@ -415,4 +404,26 @@ public interface RuneLiteConfig extends Config
|
|||||||
{
|
{
|
||||||
return new Keybind(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import net.runelite.api.SpritePixels;
|
|||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.PostItemComposition;
|
import net.runelite.api.events.PostItemComposition;
|
||||||
import net.runelite.client.callback.ClientThread;
|
import net.runelite.client.callback.ClientThread;
|
||||||
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
import net.runelite.client.eventbus.EventBus;
|
import net.runelite.client.eventbus.EventBus;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.util.AsyncBufferedImage;
|
import net.runelite.client.util.AsyncBufferedImage;
|
||||||
@@ -86,6 +87,7 @@ public class ItemManager
|
|||||||
private final Client client;
|
private final Client client;
|
||||||
private final ClientThread clientThread;
|
private final ClientThread clientThread;
|
||||||
private final ItemClient itemClient;
|
private final ItemClient itemClient;
|
||||||
|
private final RuneLiteConfig runeLiteConfig;
|
||||||
|
|
||||||
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
|
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
|
||||||
private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
|
private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
|
||||||
@@ -170,11 +172,12 @@ public class ItemManager
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ItemManager(Client client, ScheduledExecutorService scheduledExecutorService, ClientThread clientThread,
|
public ItemManager(Client client, ScheduledExecutorService scheduledExecutorService, ClientThread clientThread,
|
||||||
OkHttpClient okHttpClient, EventBus eventBus)
|
OkHttpClient okHttpClient, EventBus eventBus, RuneLiteConfig runeLiteConfig)
|
||||||
{
|
{
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.clientThread = clientThread;
|
this.clientThread = clientThread;
|
||||||
this.itemClient = new ItemClient(okHttpClient);
|
this.itemClient = new ItemClient(okHttpClient);
|
||||||
|
this.runeLiteConfig = runeLiteConfig;
|
||||||
|
|
||||||
scheduledExecutorService.scheduleWithFixedDelay(this::loadPrices, 0, 30, TimeUnit.MINUTES);
|
scheduledExecutorService.scheduleWithFixedDelay(this::loadPrices, 0, 30, TimeUnit.MINUTES);
|
||||||
scheduledExecutorService.submit(this::loadStats);
|
scheduledExecutorService.submit(this::loadStats);
|
||||||
@@ -292,17 +295,17 @@ public class ItemManager
|
|||||||
*/
|
*/
|
||||||
public int getItemPrice(int itemID)
|
public int getItemPrice(int itemID)
|
||||||
{
|
{
|
||||||
return getItemPrice(itemID, false);
|
return getItemPriceWithSource(itemID, runeLiteConfig.useWikiItemPrices());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look up an item's price
|
* Look up an item's price
|
||||||
*
|
*
|
||||||
* @param itemID item id
|
* @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
|
* @return item price
|
||||||
*/
|
*/
|
||||||
public int getItemPrice(int itemID, boolean ignoreUntradeableMap)
|
public int getItemPriceWithSource(int itemID, boolean useWikiPrice)
|
||||||
{
|
{
|
||||||
if (itemID == COINS_995)
|
if (itemID == COINS_995)
|
||||||
{
|
{
|
||||||
@@ -330,19 +333,14 @@ public class ItemManager
|
|||||||
|
|
||||||
if (ip != null)
|
if (ip != null)
|
||||||
{
|
{
|
||||||
price += ip.getPrice();
|
price = useWikiPrice && ip.getWikiPrice() > 0 ? ip.getWikiPrice() : ip.getPrice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (final ItemMapping mappedItem : mappedItems)
|
for (final ItemMapping mappedItem : mappedItems)
|
||||||
{
|
{
|
||||||
if (ignoreUntradeableMap && mappedItem.isUntradeable())
|
price += getItemPriceWithSource(mappedItem.getTradeableItem(), useWikiPrice) * mappedItem.getQuantity();
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
price += getItemPrice(mappedItem.getTradeableItem(), ignoreUntradeableMap) * mappedItem.getQuantity();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user