Merge remote-tracking branch 'runelite/master'
This commit is contained in:
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Jeremy Plsek <https://github.com/jplsek>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.bank;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.ItemID;
|
||||
import static net.runelite.api.ItemID.COINS_995;
|
||||
import static net.runelite.api.ItemID.PLATINUM_TOKEN;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
|
||||
@Slf4j
|
||||
class BankCalculation
|
||||
{
|
||||
private static final ImmutableList<Varbits> TAB_VARBITS = ImmutableList.of(
|
||||
Varbits.BANK_TAB_ONE_COUNT,
|
||||
Varbits.BANK_TAB_TWO_COUNT,
|
||||
Varbits.BANK_TAB_THREE_COUNT,
|
||||
Varbits.BANK_TAB_FOUR_COUNT,
|
||||
Varbits.BANK_TAB_FIVE_COUNT,
|
||||
Varbits.BANK_TAB_SIX_COUNT,
|
||||
Varbits.BANK_TAB_SEVEN_COUNT,
|
||||
Varbits.BANK_TAB_EIGHT_COUNT,
|
||||
Varbits.BANK_TAB_NINE_COUNT
|
||||
);
|
||||
|
||||
private final BankPlugin plugin;
|
||||
private final ItemManager itemManager;
|
||||
private final Client client;
|
||||
|
||||
// Used to avoid extra calculation if the bank has not changed
|
||||
private int itemsHash;
|
||||
|
||||
@Getter
|
||||
private long gePrice;
|
||||
|
||||
@Getter
|
||||
private long haPrice;
|
||||
|
||||
@Inject
|
||||
BankCalculation(ItemManager itemManager, BankPlugin plugin, Client client)
|
||||
{
|
||||
this.itemManager = itemManager;
|
||||
this.plugin = plugin;
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the bank based on the cache, price can be 0 if bank not active, or cache not set
|
||||
*/
|
||||
void calculate()
|
||||
{
|
||||
ItemContainer bankInventory = client.getItemContainer(InventoryID.BANK);
|
||||
|
||||
if (bankInventory == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Item[] items = bankInventory.getItems();
|
||||
int currentTab = client.getVar(Varbits.CURRENT_BANK_TAB);
|
||||
|
||||
if (currentTab > 0)
|
||||
{
|
||||
int startIndex = 0;
|
||||
|
||||
for (int i = currentTab - 1; i > 0; i--)
|
||||
{
|
||||
startIndex += client.getVar(TAB_VARBITS.get(i - 1));
|
||||
}
|
||||
|
||||
int itemCount = client.getVar(TAB_VARBITS.get(currentTab - 1));
|
||||
items = Arrays.copyOfRange(items, startIndex, startIndex + itemCount);
|
||||
}
|
||||
|
||||
if (items.length == 0 || !isBankDifferent(items))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
log.debug("Calculating new bank value...");
|
||||
|
||||
gePrice = haPrice = 0;
|
||||
|
||||
List<Integer> itemIds = new ArrayList<>();
|
||||
|
||||
// Generate our lists (and do some quick price additions)
|
||||
for (Item item : items)
|
||||
{
|
||||
int quantity = item.getQuantity();
|
||||
|
||||
if (item.getId() <= 0 || quantity == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getId() == COINS_995)
|
||||
{
|
||||
gePrice += quantity;
|
||||
haPrice += quantity;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getId() == PLATINUM_TOKEN)
|
||||
{
|
||||
gePrice += quantity * 1000L;
|
||||
haPrice += quantity * 1000L;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (plugin.isShowGE())
|
||||
{
|
||||
itemIds.add(item.getId());
|
||||
}
|
||||
|
||||
if (plugin.isShowHA())
|
||||
{
|
||||
long alchValue = itemManager.getAlchValue(item.getId());
|
||||
|
||||
if (alchValue > 0)
|
||||
{
|
||||
haPrice += alchValue * quantity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now do the calculations
|
||||
if (plugin.isShowGE() && !itemIds.isEmpty())
|
||||
{
|
||||
for (Item item : items)
|
||||
{
|
||||
int itemId = item.getId();
|
||||
int quantity = item.getQuantity();
|
||||
|
||||
if (itemId <= 0 || quantity == 0
|
||||
|| itemId == ItemID.COINS_995 || itemId == ItemID.PLATINUM_TOKEN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
gePrice += (long) itemManager.getItemPrice(itemId) * quantity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBankDifferent(Item[] items)
|
||||
{
|
||||
Map<Integer, Integer> mapCheck = new HashMap<>();
|
||||
|
||||
for (Item item : items)
|
||||
{
|
||||
mapCheck.put(item.getId(), item.getQuantity());
|
||||
}
|
||||
|
||||
int curHash = mapCheck.hashCode();
|
||||
|
||||
if (curHash != itemsHash)
|
||||
{
|
||||
itemsHash = curHash;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -97,4 +97,15 @@ public interface BankConfig extends Config
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "seedVaultValue",
|
||||
name = "Show seed vault value",
|
||||
description = "Adds the total value of all seeds inside the seed vault to the title",
|
||||
position = 7
|
||||
)
|
||||
default boolean seedVaultValue()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,17 +26,29 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.bank;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.inject.Provides;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.api.events.MenuShouldLeftClick;
|
||||
import net.runelite.api.events.ScriptCallbackEvent;
|
||||
import net.runelite.api.events.WidgetLoaded;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
@@ -53,9 +65,22 @@ import net.runelite.client.util.StackFormatter;
|
||||
@Singleton
|
||||
public class BankPlugin extends Plugin
|
||||
{
|
||||
private static final List<Varbits> TAB_VARBITS = ImmutableList.of(
|
||||
Varbits.BANK_TAB_ONE_COUNT,
|
||||
Varbits.BANK_TAB_TWO_COUNT,
|
||||
Varbits.BANK_TAB_THREE_COUNT,
|
||||
Varbits.BANK_TAB_FOUR_COUNT,
|
||||
Varbits.BANK_TAB_FIVE_COUNT,
|
||||
Varbits.BANK_TAB_SIX_COUNT,
|
||||
Varbits.BANK_TAB_SEVEN_COUNT,
|
||||
Varbits.BANK_TAB_EIGHT_COUNT,
|
||||
Varbits.BANK_TAB_NINE_COUNT
|
||||
);
|
||||
|
||||
private static final String DEPOSIT_WORN = "Deposit worn items";
|
||||
private static final String DEPOSIT_INVENTORY = "Deposit inventory";
|
||||
private static final String DEPOSIT_LOOT = "Deposit loot";
|
||||
private static final String SEED_VAULT_TITLE = "Seed Vault";
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
@@ -63,9 +88,6 @@ public class BankPlugin extends Plugin
|
||||
@Inject
|
||||
private ClientThread clientThread;
|
||||
|
||||
@Inject
|
||||
private BankCalculation bankCalculation;
|
||||
|
||||
@Inject
|
||||
private BankConfig config;
|
||||
|
||||
@@ -75,6 +97,12 @@ public class BankPlugin extends Plugin
|
||||
@Inject
|
||||
private EventBus eventBus;
|
||||
|
||||
@Inject
|
||||
private ContainerCalculation bankCalculation;
|
||||
|
||||
@Inject
|
||||
private ContainerCalculation seedVaultCalculation;
|
||||
|
||||
private boolean forceRightClickFlag;
|
||||
|
||||
@Provides
|
||||
@@ -113,6 +141,8 @@ public class BankPlugin extends Plugin
|
||||
eventBus.subscribe(MenuShouldLeftClick.class, this, this::onMenuShouldLeftClick);
|
||||
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
|
||||
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
|
||||
eventBus.subscribe(WidgetLoaded.class, this, this::onWidgetLoaded);
|
||||
eventBus.subscribe(ItemContainerChanged.class, this, this::onItemContainerChanged);
|
||||
}
|
||||
|
||||
private void onMenuShouldLeftClick(MenuShouldLeftClick event)
|
||||
@@ -153,12 +183,47 @@ public class BankPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
String strCurrentTab = "";
|
||||
bankCalculation.calculate();
|
||||
long gePrice = bankCalculation.getGePrice();
|
||||
long haPrice = bankCalculation.getHaPrice();
|
||||
final ContainerPrices prices = bankCalculation.calculate(getBankTabItems());
|
||||
if (prices == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.showGE && gePrice != 0)
|
||||
final String strCurrentTab = createValueText(prices);
|
||||
|
||||
String[] stringStack = client.getStringStack();
|
||||
int stringStackSize = client.getStringStackSize();
|
||||
|
||||
stringStack[stringStackSize - 1] += strCurrentTab;
|
||||
}
|
||||
|
||||
private void onWidgetLoaded(WidgetLoaded event)
|
||||
{
|
||||
if (event.getGroupId() != WidgetID.SEED_VAULT_GROUP_ID || !config.seedVaultValue())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
updateSeedVaultTotal();
|
||||
}
|
||||
|
||||
private void onItemContainerChanged(ItemContainerChanged event)
|
||||
{
|
||||
if (event.getContainerId() != InventoryID.SEED_VAULT.getId() || !config.seedVaultValue())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
updateSeedVaultTotal();
|
||||
}
|
||||
|
||||
private String createValueText(final ContainerPrices prices)
|
||||
{
|
||||
final long gePrice = prices.getGePrice();
|
||||
final long haPrice = prices.getHighAlchPrice();
|
||||
|
||||
String strCurrentTab = "";
|
||||
if (config.showGE() && gePrice != 0)
|
||||
{
|
||||
strCurrentTab += " (";
|
||||
|
||||
@@ -196,10 +261,71 @@ public class BankPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
String[] stringStack = client.getStringStack();
|
||||
int stringStackSize = client.getStringStackSize();
|
||||
return strCurrentTab;
|
||||
}
|
||||
|
||||
stringStack[stringStackSize - 1] += strCurrentTab;
|
||||
private Item[] getBankTabItems()
|
||||
{
|
||||
final ItemContainer container = client.getItemContainer(InventoryID.BANK);
|
||||
if (container == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final Item[] items = container.getItems();
|
||||
int currentTab = client.getVar(Varbits.CURRENT_BANK_TAB);
|
||||
|
||||
if (currentTab > 0)
|
||||
{
|
||||
int startIndex = 0;
|
||||
|
||||
for (int i = currentTab - 1; i > 0; i--)
|
||||
{
|
||||
startIndex += client.getVar(TAB_VARBITS.get(i - 1));
|
||||
}
|
||||
|
||||
int itemCount = client.getVar(TAB_VARBITS.get(currentTab - 1));
|
||||
return Arrays.copyOfRange(items, startIndex, startIndex + itemCount);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
private void updateSeedVaultTotal()
|
||||
{
|
||||
final Widget titleContainer = client.getWidget(WidgetInfo.SEED_VAULT_TITLE_CONTAINER);
|
||||
if (titleContainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Widget[] children = titleContainer.getDynamicChildren();
|
||||
if (children == null || children.length < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final ContainerPrices prices = seedVaultCalculation.calculate(getSeedVaultItems());
|
||||
if (prices == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final String titleText = createValueText(prices);
|
||||
|
||||
final Widget title = children[1];
|
||||
title.setText(SEED_VAULT_TITLE + titleText);
|
||||
}
|
||||
|
||||
private Item[] getSeedVaultItems()
|
||||
{
|
||||
final ItemContainer itemContainer = client.getItemContainer(InventoryID.SEED_VAULT);
|
||||
if (itemContainer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return itemContainer.getItems();
|
||||
}
|
||||
|
||||
private void onConfigChanged(ConfigChanged event)
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2019, TheStonedTurtle <https://github.com/TheStonedTurtle>
|
||||
* Copyright (c) 2019, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.bank;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Constants;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
|
||||
class ContainerCalculation
|
||||
{
|
||||
private final ItemManager itemManager;
|
||||
|
||||
private int hash;
|
||||
private ContainerPrices containerPrices;
|
||||
|
||||
@Inject
|
||||
private ContainerCalculation(ItemManager itemManager)
|
||||
{
|
||||
this.itemManager = itemManager;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
ContainerPrices calculate(Item[] items)
|
||||
{
|
||||
// Returns last calculation if inventory hasn't changed
|
||||
final int newHash = hashItems(items);
|
||||
if (containerPrices != null && hash == newHash)
|
||||
{
|
||||
return containerPrices;
|
||||
}
|
||||
|
||||
hash = newHash;
|
||||
|
||||
long ge = 0;
|
||||
long alch = 0;
|
||||
|
||||
for (final Item item : items)
|
||||
{
|
||||
final int qty = item.getQuantity();
|
||||
final int id = item.getId();
|
||||
|
||||
if (id <= 0 || qty == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case ItemID.COINS_995:
|
||||
ge += qty;
|
||||
alch += qty;
|
||||
break;
|
||||
case ItemID.PLATINUM_TOKEN:
|
||||
ge += qty * 1000L;
|
||||
alch += qty * 1000L;
|
||||
break;
|
||||
default:
|
||||
final long storePrice = itemManager.getItemDefinition(id).getPrice();
|
||||
final long alchPrice = (long) (storePrice * Constants.HIGH_ALCHEMY_MULTIPLIER);
|
||||
alch += alchPrice * qty;
|
||||
ge += itemManager.getItemPrice(id) * qty;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ContainerPrices prices = new ContainerPrices(ge, alch);
|
||||
containerPrices = prices;
|
||||
|
||||
return prices;
|
||||
}
|
||||
|
||||
private int hashItems(final Item[] items)
|
||||
{
|
||||
final Map<Integer, Integer> mapCheck = new HashMap<>(items.length);
|
||||
for (Item item : items)
|
||||
{
|
||||
mapCheck.put(item.getId(), item.getQuantity());
|
||||
}
|
||||
|
||||
return mapCheck.hashCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2019, TheStonedTurtle <https://github.com/TheStonedTurtle>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.bank;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
class ContainerPrices
|
||||
{
|
||||
private long gePrice;
|
||||
private long highAlchPrice;
|
||||
}
|
||||
@@ -130,7 +130,11 @@
|
||||
169,
|
||||
171,
|
||||
173,
|
||||
2444
|
||||
2444,
|
||||
23551,
|
||||
23553,
|
||||
23555,
|
||||
23557
|
||||
],
|
||||
"antipoison": [
|
||||
175,
|
||||
@@ -3059,7 +3063,11 @@
|
||||
3024,
|
||||
3026,
|
||||
3028,
|
||||
3030
|
||||
3030,
|
||||
23567,
|
||||
23569,
|
||||
23571,
|
||||
23573
|
||||
],
|
||||
"agility potion": [
|
||||
3032,
|
||||
@@ -3123,7 +3131,8 @@
|
||||
],
|
||||
"cooked karambwan": [
|
||||
3144,
|
||||
3147
|
||||
3147,
|
||||
23533
|
||||
],
|
||||
"karambwan paste": [
|
||||
3152,
|
||||
@@ -3951,7 +3960,8 @@
|
||||
4863,
|
||||
4864,
|
||||
4865,
|
||||
4866
|
||||
4866,
|
||||
23653
|
||||
],
|
||||
"ahrims robetop": [
|
||||
4712,
|
||||
@@ -3977,7 +3987,8 @@
|
||||
4881,
|
||||
4882,
|
||||
4883,
|
||||
4884
|
||||
4884,
|
||||
23639
|
||||
],
|
||||
"dharoks greataxe": [
|
||||
4718,
|
||||
@@ -4001,7 +4012,8 @@
|
||||
4899,
|
||||
4900,
|
||||
4901,
|
||||
4902
|
||||
4902,
|
||||
23633
|
||||
],
|
||||
"guthans helm": [
|
||||
4724,
|
||||
@@ -4009,7 +4021,8 @@
|
||||
4905,
|
||||
4906,
|
||||
4907,
|
||||
4908
|
||||
4908,
|
||||
23638
|
||||
],
|
||||
"guthans warspear": [
|
||||
4726,
|
||||
@@ -4057,7 +4070,8 @@
|
||||
4941,
|
||||
4942,
|
||||
4943,
|
||||
4944
|
||||
4944,
|
||||
23632
|
||||
],
|
||||
"karils leatherskirt": [
|
||||
4738,
|
||||
@@ -4073,7 +4087,8 @@
|
||||
4953,
|
||||
4954,
|
||||
4955,
|
||||
4956
|
||||
4956,
|
||||
23637
|
||||
],
|
||||
"torags hammers": [
|
||||
4747,
|
||||
@@ -4097,7 +4112,8 @@
|
||||
4971,
|
||||
4972,
|
||||
4973,
|
||||
4974
|
||||
4974,
|
||||
23634
|
||||
],
|
||||
"veracs helm": [
|
||||
4753,
|
||||
@@ -4105,7 +4121,8 @@
|
||||
4977,
|
||||
4978,
|
||||
4979,
|
||||
4980
|
||||
4980,
|
||||
23636
|
||||
],
|
||||
"veracs flail": [
|
||||
4755,
|
||||
@@ -4129,7 +4146,8 @@
|
||||
4995,
|
||||
4996,
|
||||
4997,
|
||||
4998
|
||||
4998,
|
||||
23635
|
||||
],
|
||||
"sithik portrait": [
|
||||
4814,
|
||||
@@ -4812,7 +4830,8 @@
|
||||
],
|
||||
"amulet of fury": [
|
||||
6585,
|
||||
12436
|
||||
12436,
|
||||
23640
|
||||
],
|
||||
"white dagger": [
|
||||
6591,
|
||||
@@ -4872,7 +4891,11 @@
|
||||
6685,
|
||||
6687,
|
||||
6689,
|
||||
6691
|
||||
6691,
|
||||
23575,
|
||||
23577,
|
||||
23579,
|
||||
23581
|
||||
],
|
||||
"slayer gloves": [
|
||||
6708,
|
||||
@@ -4889,7 +4912,8 @@
|
||||
],
|
||||
"seers ring": [
|
||||
6731,
|
||||
11770
|
||||
11770,
|
||||
23624
|
||||
],
|
||||
"archers ring": [
|
||||
6733,
|
||||
@@ -4901,7 +4925,8 @@
|
||||
],
|
||||
"berserker ring": [
|
||||
6737,
|
||||
11773
|
||||
11773,
|
||||
23595
|
||||
],
|
||||
"darklight": [
|
||||
6746,
|
||||
@@ -5021,6 +5046,10 @@
|
||||
6886,
|
||||
6887
|
||||
],
|
||||
"mages book": [
|
||||
6889,
|
||||
23652
|
||||
],
|
||||
"animals bones": [
|
||||
6904,
|
||||
6905,
|
||||
@@ -5240,6 +5269,10 @@
|
||||
7460,
|
||||
20583
|
||||
],
|
||||
"barrows gloves": [
|
||||
7462,
|
||||
23593
|
||||
],
|
||||
"cornflour": [
|
||||
7463,
|
||||
7466
|
||||
@@ -6359,6 +6392,10 @@
|
||||
9183,
|
||||
9463
|
||||
],
|
||||
"rune crossbow": [
|
||||
9185,
|
||||
23601
|
||||
],
|
||||
"jade bolts": [
|
||||
9237,
|
||||
9335
|
||||
@@ -6381,7 +6418,8 @@
|
||||
],
|
||||
"diamond bolts": [
|
||||
9243,
|
||||
9340
|
||||
9340,
|
||||
23649
|
||||
],
|
||||
"dragonstone bolts": [
|
||||
9244,
|
||||
@@ -6854,6 +6892,10 @@
|
||||
10462,
|
||||
10788
|
||||
],
|
||||
"avas accumulator": [
|
||||
10499,
|
||||
23609
|
||||
],
|
||||
"reindeer hat": [
|
||||
10507,
|
||||
10722
|
||||
@@ -7022,6 +7064,10 @@
|
||||
10822,
|
||||
10824
|
||||
],
|
||||
"helm of neitiznot": [
|
||||
10828,
|
||||
23591
|
||||
],
|
||||
"hard hat": [
|
||||
10862,
|
||||
10883
|
||||
@@ -7052,7 +7098,11 @@
|
||||
10925,
|
||||
10927,
|
||||
10929,
|
||||
10931
|
||||
10931,
|
||||
23559,
|
||||
23561,
|
||||
23563,
|
||||
23565
|
||||
],
|
||||
"lumberjack top": [
|
||||
10939,
|
||||
@@ -7464,6 +7514,10 @@
|
||||
11736,
|
||||
11737
|
||||
],
|
||||
"armadyl crossbow": [
|
||||
11785,
|
||||
23611
|
||||
],
|
||||
"steam battlestaff": [
|
||||
11787,
|
||||
12795
|
||||
@@ -7472,6 +7526,10 @@
|
||||
11789,
|
||||
12796
|
||||
],
|
||||
"staff of the dead": [
|
||||
11791,
|
||||
23613
|
||||
],
|
||||
"godsword shards": [
|
||||
11794,
|
||||
11796,
|
||||
@@ -7502,6 +7560,10 @@
|
||||
11820,
|
||||
11822
|
||||
],
|
||||
"bandos tassets": [
|
||||
11834,
|
||||
23646
|
||||
],
|
||||
"dragon boots": [
|
||||
11840,
|
||||
22234
|
||||
@@ -7694,7 +7756,8 @@
|
||||
],
|
||||
"occult necklace": [
|
||||
12002,
|
||||
19720
|
||||
19720,
|
||||
23654
|
||||
],
|
||||
"soft clay pack": [
|
||||
12009,
|
||||
@@ -7736,7 +7799,11 @@
|
||||
12625,
|
||||
12627,
|
||||
12629,
|
||||
12631
|
||||
12631,
|
||||
23583,
|
||||
23585,
|
||||
23587,
|
||||
23589
|
||||
],
|
||||
"stamina mix": [
|
||||
12633,
|
||||
@@ -7836,7 +7903,11 @@
|
||||
12695,
|
||||
12697,
|
||||
12699,
|
||||
12701
|
||||
12701,
|
||||
23543,
|
||||
23545,
|
||||
23547,
|
||||
23549
|
||||
],
|
||||
"menagerie": [
|
||||
12725,
|
||||
@@ -7854,6 +7925,10 @@
|
||||
12755,
|
||||
12756
|
||||
],
|
||||
"rune pouch": [
|
||||
12791,
|
||||
23650
|
||||
],
|
||||
"nest box": [
|
||||
12792,
|
||||
12793,
|
||||
@@ -7865,6 +7940,14 @@
|
||||
12817,
|
||||
19559
|
||||
],
|
||||
"spirit shield": [
|
||||
12829,
|
||||
23599
|
||||
],
|
||||
"blessed spirit shield": [
|
||||
12831,
|
||||
23642
|
||||
],
|
||||
"amulet of the damned": [
|
||||
12851,
|
||||
12853
|
||||
@@ -7917,7 +8000,8 @@
|
||||
"dragon defender": [
|
||||
12954,
|
||||
19722,
|
||||
20463
|
||||
20463,
|
||||
23597
|
||||
],
|
||||
"bronze set": [
|
||||
12960,
|
||||
@@ -8072,6 +8156,10 @@
|
||||
13222,
|
||||
13224
|
||||
],
|
||||
"eternal boots": [
|
||||
13235,
|
||||
23644
|
||||
],
|
||||
"infernal axe": [
|
||||
13241,
|
||||
13242
|
||||
@@ -8348,11 +8436,16 @@
|
||||
13652,
|
||||
20784
|
||||
],
|
||||
"heavy ballista": [
|
||||
19481,
|
||||
23630
|
||||
],
|
||||
"dragon javelin": [
|
||||
19484,
|
||||
19486,
|
||||
19488,
|
||||
19490
|
||||
19490,
|
||||
23648
|
||||
],
|
||||
"zenyte bracelet": [
|
||||
19492,
|
||||
@@ -8606,6 +8699,10 @@
|
||||
21003,
|
||||
21205
|
||||
],
|
||||
"kodai wand": [
|
||||
21006,
|
||||
23626
|
||||
],
|
||||
"dragon sword": [
|
||||
21009,
|
||||
21206
|
||||
@@ -8668,7 +8765,8 @@
|
||||
"infernal cape": [
|
||||
21287,
|
||||
21295,
|
||||
21297
|
||||
21297,
|
||||
23622
|
||||
],
|
||||
"amethyst javelin": [
|
||||
21318,
|
||||
@@ -8730,6 +8828,18 @@
|
||||
21739,
|
||||
21752
|
||||
],
|
||||
"imbued saradomin cape": [
|
||||
21791,
|
||||
23607
|
||||
],
|
||||
"imbued guthix cape": [
|
||||
21793,
|
||||
23603
|
||||
],
|
||||
"imbued zamorak cape": [
|
||||
21795,
|
||||
23605
|
||||
],
|
||||
"bracelet of ethereum": [
|
||||
21816,
|
||||
21817
|
||||
@@ -8953,6 +9063,10 @@
|
||||
22323,
|
||||
22481
|
||||
],
|
||||
"ghrazi rapier": [
|
||||
22324,
|
||||
23628
|
||||
],
|
||||
"scythe of vitur": [
|
||||
22325,
|
||||
22486,
|
||||
@@ -9017,6 +9131,22 @@
|
||||
22552,
|
||||
22555
|
||||
],
|
||||
"vestas longsword": [
|
||||
22613,
|
||||
23615
|
||||
],
|
||||
"statiuss warhammer": [
|
||||
22622,
|
||||
23620
|
||||
],
|
||||
"morrigans javelin": [
|
||||
22636,
|
||||
23619
|
||||
],
|
||||
"zuriels staff": [
|
||||
22647,
|
||||
23617
|
||||
],
|
||||
"dragon hasta": [
|
||||
22731,
|
||||
22734,
|
||||
|
||||
@@ -404,7 +404,6 @@ R 42 159 43 159
|
||||
R 43 58 45 61
|
||||
r 24 60
|
||||
r 29 60
|
||||
r 32 75
|
||||
r 44 155
|
||||
r 47 158
|
||||
r 53 76
|
||||
@@ -946,3 +945,7 @@ c 7 4
|
||||
// Cerberus
|
||||
#100
|
||||
R 19 19 21 20
|
||||
|
||||
// Cosmic entity's plane
|
||||
#040404
|
||||
r 32 75
|
||||
@@ -1 +1 @@
|
||||
A6B3A7BFE7B688A08F69B91A7FD5C7184D71147D3DAF74B1262369D85DBB3A03
|
||||
4D9A96A7D57F6B9661273FB645A0510DD0F02C8A9C2E133772065F8AB588614D
|
||||
@@ -77,14 +77,14 @@ LABEL60:
|
||||
iload 5
|
||||
iload 6
|
||||
if_icmplt LABEL64
|
||||
jump LABEL108
|
||||
jump LABEL119
|
||||
LABEL64:
|
||||
iload 1
|
||||
iload 5
|
||||
cc_find
|
||||
iconst 1
|
||||
if_icmpeq LABEL70
|
||||
jump LABEL103
|
||||
jump LABEL114
|
||||
LABEL70:
|
||||
iload 5
|
||||
invoke 1358
|
||||
@@ -96,7 +96,7 @@ LABEL70:
|
||||
LABEL77:
|
||||
iconst 901389
|
||||
istore 4
|
||||
jump LABEL89
|
||||
jump LABEL100
|
||||
LABEL80:
|
||||
iload 3
|
||||
iconst 0
|
||||
@@ -105,11 +105,24 @@ LABEL80:
|
||||
LABEL84:
|
||||
iconst 16776960
|
||||
istore 4
|
||||
jump LABEL89
|
||||
jump LABEL100
|
||||
LABEL87:
|
||||
iconst 105
|
||||
iconst 74
|
||||
iconst 2099
|
||||
iload 5
|
||||
enum
|
||||
iconst 603
|
||||
if_icmpeq LABEL95
|
||||
jump LABEL98
|
||||
LABEL95:
|
||||
iconst 10461087
|
||||
istore 4
|
||||
jump LABEL100
|
||||
LABEL98:
|
||||
iconst 16711680
|
||||
istore 4
|
||||
LABEL89:
|
||||
LABEL100:
|
||||
iload 4
|
||||
cc_setcolour
|
||||
iconst 85
|
||||
@@ -124,54 +137,54 @@ LABEL89:
|
||||
iload 4
|
||||
sconst "Iii"
|
||||
cc_setonmouseleave
|
||||
LABEL103:
|
||||
LABEL114:
|
||||
iload 5
|
||||
iconst 1
|
||||
add
|
||||
istore 5
|
||||
jump LABEL60
|
||||
LABEL108:
|
||||
LABEL119:
|
||||
iconst 0
|
||||
invoke 2265
|
||||
istore 6
|
||||
istore 5
|
||||
LABEL112:
|
||||
LABEL123:
|
||||
iload 5
|
||||
iload 6
|
||||
if_icmplt LABEL116
|
||||
jump LABEL160
|
||||
LABEL116:
|
||||
if_icmplt LABEL127
|
||||
jump LABEL171
|
||||
LABEL127:
|
||||
iload 2
|
||||
iload 5
|
||||
cc_find
|
||||
iconst 1
|
||||
if_icmpeq LABEL122
|
||||
jump LABEL155
|
||||
LABEL122:
|
||||
if_icmpeq LABEL133
|
||||
jump LABEL166
|
||||
LABEL133:
|
||||
iload 5
|
||||
invoke 1359
|
||||
istore 3
|
||||
iload 3
|
||||
iconst 2
|
||||
if_icmpeq LABEL129
|
||||
jump LABEL132
|
||||
LABEL129:
|
||||
if_icmpeq LABEL140
|
||||
jump LABEL143
|
||||
LABEL140:
|
||||
iconst 901389
|
||||
istore 4
|
||||
jump LABEL141
|
||||
LABEL132:
|
||||
jump LABEL152
|
||||
LABEL143:
|
||||
iload 3
|
||||
iconst 0
|
||||
if_icmpeq LABEL136
|
||||
jump LABEL139
|
||||
LABEL136:
|
||||
if_icmpeq LABEL147
|
||||
jump LABEL150
|
||||
LABEL147:
|
||||
iconst 16776960
|
||||
istore 4
|
||||
jump LABEL141
|
||||
LABEL139:
|
||||
jump LABEL152
|
||||
LABEL150:
|
||||
iconst 16711680
|
||||
istore 4
|
||||
LABEL141:
|
||||
LABEL152:
|
||||
iload 4
|
||||
cc_setcolour
|
||||
iconst 85
|
||||
@@ -186,13 +199,13 @@ LABEL141:
|
||||
iload 4
|
||||
sconst "Iii"
|
||||
cc_setonmouseleave
|
||||
LABEL155:
|
||||
LABEL166:
|
||||
iload 5
|
||||
iconst 1
|
||||
add
|
||||
istore 5
|
||||
jump LABEL112
|
||||
LABEL160:
|
||||
jump LABEL123
|
||||
LABEL171:
|
||||
sconst "questProgressUpdated"
|
||||
runelite_callback
|
||||
runelite_callback
|
||||
return
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* Copyright (c) 2019, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -30,13 +30,12 @@ import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemDefinition;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -46,7 +45,7 @@ import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class BankCalculationTest
|
||||
public class ContainerCalculationTest
|
||||
{
|
||||
@Mock
|
||||
@Bind
|
||||
@@ -56,12 +55,8 @@ public class BankCalculationTest
|
||||
@Bind
|
||||
private ItemManager itemManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private BankConfig bankConfig;
|
||||
|
||||
@Inject
|
||||
private BankPlugin bankplugin;
|
||||
private ContainerCalculation containerCalculation;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
@@ -72,9 +67,6 @@ public class BankCalculationTest
|
||||
@Test
|
||||
public void testCalculate()
|
||||
{
|
||||
when(bankConfig.showHA())
|
||||
.thenReturn(true);
|
||||
|
||||
Item coins = mock(Item.class);
|
||||
when(coins.getId())
|
||||
.thenReturn(ItemID.COINS_995);
|
||||
@@ -92,13 +84,6 @@ public class BankCalculationTest
|
||||
whip
|
||||
).toArray(new Item[0]);
|
||||
|
||||
ItemContainer bankContainer = mock(ItemContainer.class);
|
||||
when(bankContainer.getItems())
|
||||
.thenReturn(items);
|
||||
|
||||
when(client.getItemContainer(InventoryID.BANK))
|
||||
.thenReturn(bankContainer);
|
||||
|
||||
ItemDefinition whipComp = mock(ItemDefinition.class);
|
||||
when(whipComp.getId())
|
||||
.thenReturn(ItemID.ABYSSAL_WHIP);
|
||||
@@ -107,10 +92,10 @@ public class BankCalculationTest
|
||||
when(itemManager.getItemDefinition(ItemID.ABYSSAL_WHIP))
|
||||
.thenReturn(whipComp);
|
||||
|
||||
BankCalculation bankCalculation = new BankCalculation(itemManager, bankplugin, client);
|
||||
bankCalculation.calculate();
|
||||
final ContainerPrices prices = containerCalculation.calculate(items);
|
||||
assertNotNull(prices);
|
||||
|
||||
long value = bankCalculation.getHaPrice();
|
||||
assertTrue(value == Integer.MAX_VALUE);
|
||||
long value = prices.getHighAlchPrice();
|
||||
assertTrue(value > Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user