Merge pull request #2155 from Dyldozer/Runepouch

Suppliestracker: Rework a bit, added standard cmb spells, rune pouch
This commit is contained in:
ST0NEWALL
2019-12-24 02:53:16 -05:00
committed by GitHub
12 changed files with 593 additions and 176 deletions

View File

@@ -340,7 +340,6 @@ public final class AnimationID
public static final int BARRAGE_ANIMATION = 1979;
public static final int BLITZ_ANIMATION = 1978;
public static final int CHIN_ANIMATION = 7618;
public static final int SCYTHE_OF_VITUR_ANIMATION = 8056;
// Gauntlet Hunleff
public static final int HUNLEFF_TRAMPLE = 8420;
@@ -351,4 +350,14 @@ public final class AnimationID
public static final int ZALCANO_KNOCKED_DOWN = 8437;
public static final int ZALCANO_WAKEUP = 8439;
public static final int ZALCANO_ROCK_GLOWING = 8448;
//Supplies Tracker
public static final int ONEHAND_SLASH_SWORD_ANIMATION = 390;
public static final int ONEHAND_STAB_SWORD_ANIMATION = 386;
public static final int SCYTHE_OF_VITUR_ANIMATION = 8056;
public static final int LOW_LEVEL_STANDARD_SPELLS = 711;
public static final int WAVE_SPELL_ANIMATION = 727;
public static final int SURGE_SPELL_ANIMATION = 7855;
public static final int HIGH_ALCH_ANIMATION = 713;
public static final int LUNAR_HUMIDIFY = 6294;
}

View File

@@ -30,5 +30,7 @@ package net.runelite.client.plugins.suppliestracker;
*/
public enum ActionType
{
CONSUMABLE, TELEPORT, CAST
CONSUMABLE,
TELEPORT,
CAST
}

View File

@@ -41,12 +41,15 @@ import static net.runelite.api.ItemID.STEEL_DART;
@AllArgsConstructor
public enum BlowpipeDartType
{
BRONZE(BRONZE_DART), IRON(IRON_DART),
STEEL(STEEL_DART), MITHRIL(MITHRIL_DART),
ADAMANT(ADAMANT_DART), RUNE(RUNE_DART),
BRONZE(BRONZE_DART),
IRON(IRON_DART),
STEEL(STEEL_DART),
MITHRIL(MITHRIL_DART),
ADAMANT(ADAMANT_DART),
RUNE(RUNE_DART),
DRAGON(DRAGON_DART);
@Getter(AccessLevel.PACKAGE)
@Getter(AccessLevel.MODULE)
private int dartID;
}

View File

@@ -46,7 +46,7 @@ public enum ItemType
JEWELLERY("Jewellery"),
CHARGES("Charges");
@Getter(AccessLevel.PACKAGE)
@Getter(AccessLevel.PUBLIC)
private String label;
/**
@@ -64,9 +64,10 @@ public enum ItemType
return ItemType.POTION;
}
if (item.getName().toLowerCase().contains("bolt") || item.getName().toLowerCase().contains("dart")
|| item.getName().toLowerCase().contains("arrow") || item.getName().toLowerCase().contains("javelin")
|| item.getName().toLowerCase().contains(" arrow") || item.getName().toLowerCase().contains("javelin")
|| item.getName().toLowerCase().contains("knive") || item.getName().toLowerCase().contains("throwing")
|| item.getName().toLowerCase().contains("zulrah's scale") || item.getName().toLowerCase().contains("cannonball"))
|| item.getName().toLowerCase().contains("zulrah's scale") || item.getName().toLowerCase().contains("cannonball")
|| item.getName().toLowerCase().contains("knife") || item.getName().toLowerCase().contains("chinchompa"))
{
return ItemType.AMMO;
}
@@ -88,7 +89,8 @@ public enum ItemType
return ItemType.JEWELLERY;
}
if (item.getId() == SCYTHE_OF_VITUR || item.getId() == SANGUINESTI_STAFF ||
item.getId() == TRIDENT_OF_THE_SEAS || item.getId() == TRIDENT_OF_THE_SWAMP)
item.getId() == TRIDENT_OF_THE_SEAS || item.getId() == TRIDENT_OF_THE_SWAMP ||
item.getId() == BLADE_OF_SAELDOR)
{
return ItemType.CHARGES;
}

View File

@@ -35,17 +35,17 @@ import net.runelite.api.Item;
@AllArgsConstructor
public class MenuAction
{
@Getter(AccessLevel.PACKAGE)
@Getter(AccessLevel.MODULE)
private ActionType type;
@Getter(AccessLevel.PACKAGE)
@Getter(AccessLevel.MODULE)
private Item[] oldInventory;
static class ItemAction extends MenuAction
{
@Getter(AccessLevel.PACKAGE)
@Getter(AccessLevel.MODULE)
private int itemID;
@Getter(AccessLevel.PACKAGE)
@Getter(AccessLevel.MODULE)
private int slot;
ItemAction(final ActionType type, final Item[] oldInventory, final int itemID, final int slot)

View File

@@ -0,0 +1,116 @@
/*
* Copyright (c) 2017, Tyler <https://github.com/tylerthardy>
* 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.suppliestracker;
import com.google.common.collect.ImmutableMap;
import java.awt.image.BufferedImage;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import static net.runelite.api.ItemID.AIR_RUNE;
import static net.runelite.api.ItemID.ASTRAL_RUNE;
import static net.runelite.api.ItemID.BLOOD_RUNE;
import static net.runelite.api.ItemID.BODY_RUNE;
import static net.runelite.api.ItemID.CHAOS_RUNE;
import static net.runelite.api.ItemID.COSMIC_RUNE;
import static net.runelite.api.ItemID.DEATH_RUNE;
import static net.runelite.api.ItemID.DUST_RUNE;
import static net.runelite.api.ItemID.EARTH_RUNE;
import static net.runelite.api.ItemID.FIRE_RUNE;
import static net.runelite.api.ItemID.LAVA_RUNE;
import static net.runelite.api.ItemID.LAW_RUNE;
import static net.runelite.api.ItemID.MIND_RUNE;
import static net.runelite.api.ItemID.MIST_RUNE;
import static net.runelite.api.ItemID.MUD_RUNE;
import static net.runelite.api.ItemID.NATURE_RUNE;
import static net.runelite.api.ItemID.SMOKE_RUNE;
import static net.runelite.api.ItemID.SOUL_RUNE;
import static net.runelite.api.ItemID.STEAM_RUNE;
import static net.runelite.api.ItemID.WATER_RUNE;
import static net.runelite.api.ItemID.WRATH_RUNE;
public enum Runes
{
AIR(1, AIR_RUNE),
WATER(2, WATER_RUNE),
EARTH(3, EARTH_RUNE),
FIRE(4, FIRE_RUNE),
MIND(5, MIND_RUNE),
CHAOS(6, CHAOS_RUNE),
DEATH(7, DEATH_RUNE),
BLOOD(8, BLOOD_RUNE),
COSMIC(9, COSMIC_RUNE),
NATURE(10, NATURE_RUNE),
LAW(11, LAW_RUNE),
BODY(12, BODY_RUNE),
SOUL(13, SOUL_RUNE),
ASTRAL(14, ASTRAL_RUNE),
MIST(15, MIST_RUNE),
MUD(16, MUD_RUNE),
DUST(17, DUST_RUNE),
LAVA(18, LAVA_RUNE),
STEAM(19, STEAM_RUNE),
SMOKE(20, SMOKE_RUNE),
WRATH(21, WRATH_RUNE);
private static final Map<Integer, Runes> runes;
static
{
ImmutableMap.Builder<Integer, Runes> builder = new ImmutableMap.Builder<>();
for (Runes rune : values())
{
builder.put(rune.getId(), rune);
}
runes = builder.build();
}
@Getter
private final int id;
@Getter
private final int itemId;
@Getter
@Setter
private BufferedImage image;
Runes(int id, int itemId)
{
this.id = id;
this.itemId = itemId;
}
public static Runes getRune(int varbit)
{
return runes.get(varbit);
}
public String getName()
{
String name = this.name();
name = name.substring(0, 1) + name.substring(1).toLowerCase();
return name;
}
}

View File

@@ -28,9 +28,9 @@ import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter(AccessLevel.PACKAGE)
@Getter(AccessLevel.PUBLIC)
@AllArgsConstructor
class SuppliesTrackerItem
public class SuppliesTrackerItem
{
private int id;
private String name;

View File

@@ -49,16 +49,17 @@ import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemContainer;
import net.runelite.api.ItemDefinition;
import net.runelite.api.ItemID;
import static net.runelite.api.ItemID.*;
import net.runelite.api.Player;
import net.runelite.api.VarPlayer;
import net.runelite.api.Varbits;
import net.runelite.api.events.AnimationChanged;
import net.runelite.api.events.CannonChanged;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.events.StatChanged;
import net.runelite.api.events.VarbitChanged;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
@@ -67,6 +68,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType;
import static net.runelite.client.plugins.suppliestracker.ActionType.*;
import net.runelite.client.plugins.suppliestracker.ui.SuppliesTrackerPanel;
import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton;
import net.runelite.client.util.ImageUtil;
@@ -84,7 +86,7 @@ import net.runelite.http.api.item.ItemPrice;
public class SuppliesTrackerPlugin extends Plugin
{
//Regex patterns
static final String POTION_PATTERN = "[(]\\d[)]";
public static final String POTION_PATTERN = "[(]\\d[)]";
private static final String EAT_PATTERN = "^eat";
private static final String DRINK_PATTERN = "^drink";
private static final String TELEPORT_PATTERN = "^teleport";
@@ -101,6 +103,7 @@ public class SuppliesTrackerPlugin extends Plugin
private static final double ASSEMBLER_PERCENT = 0.20;
private static final double ACCUMULATOR_PERCENT = 0.28;
private static final double ATTRACTOR_PERCENT = 0.40;
private static final Random random = new Random();
//blowpipe attack timings
private static final int BLOWPIPE_TICKS_RAPID_PVM = 2;
@@ -114,21 +117,47 @@ public class SuppliesTrackerPlugin extends Plugin
//Max use amounts
private static final int POTION_DOSES = 4, CAKE_DOSES = 3, PIZZA_PIE_DOSES = 2;
private static final Random random = new Random();
// id array for checking thrown items and runes
private static final int[] THROWING_IDS = new int[]{BRONZE_DART, IRON_DART, STEEL_DART, BLACK_DART, MITHRIL_DART, ADAMANT_DART, RUNE_DART, DRAGON_DART, BRONZE_KNIFE, IRON_KNIFE, STEEL_KNIFE, BLACK_KNIFE, MITHRIL_KNIFE, ADAMANT_KNIFE, RUNE_KNIFE, BRONZE_THROWNAXE, IRON_THROWNAXE, STEEL_THROWNAXE, MITHRIL_THROWNAXE, ADAMANT_THROWNAXE, RUNE_THROWNAXE, DRAGON_KNIFE, DRAGON_KNIFE_22812, DRAGON_KNIFE_22814, DRAGON_KNIFEP_22808, DRAGON_KNIFEP_22810, DRAGON_KNIFEP, DRAGON_THROWNAXE, CHINCHOMPA_10033, RED_CHINCHOMPA_10034, BLACK_CHINCHOMPA};
private static final int[] RUNE_IDS = new int[]{AIR_RUNE, WATER_RUNE, EARTH_RUNE, MIND_RUNE, BODY_RUNE, COSMIC_RUNE, CHAOS_RUNE, NATURE_RUNE, LAW_RUNE, DEATH_RUNE, ASTRAL_RUNE, BLOOD_RUNE, SOUL_RUNE, WRATH_RUNE, MIST_RUNE, DUST_RUNE, MUD_RUNE, SMOKE_RUNE, STEAM_RUNE, LAVA_RUNE};
private static final int[] RUNE_IDS = new int[]{FIRE_RUNE, AIR_RUNE, WATER_RUNE, EARTH_RUNE, MIND_RUNE, BODY_RUNE, COSMIC_RUNE, CHAOS_RUNE, NATURE_RUNE, LAW_RUNE, DEATH_RUNE, ASTRAL_RUNE, BLOOD_RUNE, SOUL_RUNE, WRATH_RUNE, MIST_RUNE, DUST_RUNE, MUD_RUNE, SMOKE_RUNE, STEAM_RUNE, LAVA_RUNE};
//Hold Supply Data
private static final Map<Integer, SuppliesTrackerItem> suppliesEntry = new HashMap<>();
private final Deque<MenuAction> actionStack = new ArrayDeque<>();
private final Map<Integer, SuppliesTrackerItem> suppliesEntry = new HashMap<>();
private final Deque<MenuAction> actionStack = new ArrayDeque<>();
//Item arrays
private final String[] RAIDS_CONSUMABLES = new String[]{"xeric's", "elder", "twisted", "revitalisation", "overload", "prayer enhance", "pysk", "suphi", "leckish", "brawk", "mycil", "roqed", "kyren", "guanic", "prael", "giral", "phluxia", "kryket", "murng", "psykk"};
private final String[] RAIDS_CONSUMABLES = new String[]{"xeric's", "elder", "twisted", "revitalisation", "overload", "prayer enhance", "pysk", "suphi", "leckish", "brawk", "mycil", "roqed", "kyren", "guanic", "prael", "giral", "phluxia", "kryket", "murng", "psykk", "egniol"};
private final int[] TRIDENT_OF_THE_SEAS_IDS = new int[]{TRIDENT_OF_THE_SEAS, TRIDENT_OF_THE_SEAS_E, TRIDENT_OF_THE_SEAS_FULL};
private final int[] TRIDENT_OF_THE_SWAMP_IDS = new int[]{TRIDENT_OF_THE_SWAMP_E, TRIDENT_OF_THE_SWAMP, UNCHARGED_TOXIC_TRIDENT_E, UNCHARGED_TOXIC_TRIDENT};
//Rune pouch stuff
private final Varbits[] AMOUNT_VARBITS =
{
Varbits.RUNE_POUCH_AMOUNT1, Varbits.RUNE_POUCH_AMOUNT2, Varbits.RUNE_POUCH_AMOUNT3
};
private final Varbits[] RUNE_VARBITS =
{
Varbits.RUNE_POUCH_RUNE1, Varbits.RUNE_POUCH_RUNE2, Varbits.RUNE_POUCH_RUNE3
};
private final int[] OLD_AMOUNT_VARBITS =
{
0, 0, 0
};
private final int[] OLD_RUNE_VARBITS =
{
0, 0, 0
};
private int rune1 = 0;
private int rune2 = 0;
private int rune3 = 0;
private boolean runepouchInInv = false;
private int amountused1 = 0;
private int amountused2 = 0;
private int amountused3 = 0;
private boolean magicXpChanged = false;
private boolean skipTick = false;
private int magicXp = 0;
private ItemContainer old;
private int ammoId = 0;
private int ammoAmount = 0;
@@ -138,23 +167,21 @@ public class SuppliesTrackerPlugin extends Plugin
private boolean throwingAmmoLoaded = false;
private boolean mainHandThrowing = false;
private int mainHand = 0;
private SuppliesTrackerPanel panel;
private NavigationButton navButton;
private int attackStyleVarbit = -1;
private int ticks = 0;
private int ticksInAnimation;
private SuppliesTrackerPanel panel;
private NavigationButton navButton;
@Inject
private ClientToolbar clientToolbar;
@Inject
private ItemManager itemManager;
@Inject
private SuppliesTrackerConfig config;
@Inject
private Client client;
private boolean noXpCast = false;
/**
* Checks if item name is potion
@@ -162,30 +189,28 @@ public class SuppliesTrackerPlugin extends Plugin
* @param name the name of the item
* @return if the item is a potion - i.e. has a (1) (2) (3) or (4) in the name
*/
static boolean isPotion(String name)
public static boolean isPotion(String name)
{
return name.contains("(4)") ||
name.contains("(3)") ||
name.contains("(2)") ||
name.contains("(1)");
}
/**
* Checks if item name is pizza or pie
*
* @param name the name of the item
* @return if the item is a pizza or a pie - i.e. has pizza or pie in the name
*/
static boolean isPizzaPie(String name)
public static boolean isPizzaPie(String name)
{
return name.toLowerCase().contains("pizza") ||
name.toLowerCase().contains(" pie");
}
static boolean isCake(String name, int itemId)
public static boolean isCake(String name, int itemId)
{
return name.toLowerCase().contains("cake") ||
itemId == ItemID.CHOCOLATE_SLICE;
itemId == CHOCOLATE_SLICE;
}
@Override
@@ -219,6 +244,20 @@ public class SuppliesTrackerPlugin extends Plugin
return configManager.getConfig(SuppliesTrackerConfig.class);
}
@Subscribe
void onStatChanged(StatChanged event)
{
if (event.getSkill().name().toLowerCase().equals("magic"))
{
if (magicXp != event.getXp())
{
skipTick = true;
magicXpChanged = true;
magicXp = event.getXp();
}
}
}
@Subscribe
private void onGameTick(GameTick tick)
{
@@ -242,6 +281,27 @@ public class SuppliesTrackerPlugin extends Plugin
}
ticks = 0;
}
if (skipTick)
{
skipTick = false;
return;
}
else if (magicXpChanged)
{
checkUsedRunePouch();
magicXpChanged = false;
noXpCast = false;
}
else if (noXpCast)
{
checkUsedRunePouch();
noXpCast = false;
}
amountused1 = 0;
amountused2 = 0;
amountused3 = 0;
}
/**
@@ -282,6 +342,8 @@ public class SuppliesTrackerPlugin extends Plugin
@Subscribe
private void onVarbitChanged(VarbitChanged event)
{
updateRunePouch();
if (attackStyleVarbit == -1 ||
attackStyleVarbit != client.getVar(VarPlayer.ATTACK_STYLE))
{
@@ -308,6 +370,55 @@ public class SuppliesTrackerPlugin extends Plugin
}
}
/**
* Checks local variable data against client data then returns differences then updates local to client
*/
private void updateRunePouch()
{
//check amounts
if (OLD_AMOUNT_VARBITS[0] != client.getVar(AMOUNT_VARBITS[0]))
{
if (OLD_AMOUNT_VARBITS[0] > client.getVar(AMOUNT_VARBITS[0]))
{
amountused1 += OLD_AMOUNT_VARBITS[0] - client.getVar(AMOUNT_VARBITS[0]);
}
OLD_AMOUNT_VARBITS[0] = client.getVar(AMOUNT_VARBITS[0]);
}
if (OLD_AMOUNT_VARBITS[1] != client.getVar(AMOUNT_VARBITS[1]))
{
if (OLD_AMOUNT_VARBITS[1] > client.getVar(AMOUNT_VARBITS[1]))
{
amountused2 += OLD_AMOUNT_VARBITS[1] - client.getVar(AMOUNT_VARBITS[1]);
}
OLD_AMOUNT_VARBITS[1] = client.getVar(AMOUNT_VARBITS[1]);
}
if (OLD_AMOUNT_VARBITS[2] != client.getVar(AMOUNT_VARBITS[2]))
{
if (OLD_AMOUNT_VARBITS[2] > client.getVar(AMOUNT_VARBITS[2]))
{
amountused3 += OLD_AMOUNT_VARBITS[2] - client.getVar(AMOUNT_VARBITS[2]);
}
OLD_AMOUNT_VARBITS[2] = client.getVar(AMOUNT_VARBITS[2]);
}
//check runes
if (OLD_RUNE_VARBITS[0] != client.getVar(RUNE_VARBITS[0]))
{
rune1 = client.getVar(RUNE_VARBITS[0]);
OLD_RUNE_VARBITS[0] = client.getVar(RUNE_VARBITS[0]);
}
if (OLD_RUNE_VARBITS[1] != client.getVar(RUNE_VARBITS[1]))
{
rune2 = client.getVar(RUNE_VARBITS[1]);
OLD_RUNE_VARBITS[1] = client.getVar(RUNE_VARBITS[1]);
}
if (OLD_RUNE_VARBITS[2] != client.getVar(RUNE_VARBITS[2]))
{
rune3 = client.getVar(RUNE_VARBITS[2]);
OLD_RUNE_VARBITS[2] = client.getVar(RUNE_VARBITS[2]);
}
}
/**
* Checks for changes between the provided inventories in runes specifically to add those runes
* to the supply tracker
@@ -373,8 +484,11 @@ public class SuppliesTrackerPlugin extends Plugin
{
if (animationChanged.getActor() == client.getLocalPlayer())
{
if (animationChanged.getActor().getAnimation() == HIGH_LEVEL_MAGIC_ATTACK)
int playerAniId = animationChanged.getActor().getAnimation();
switch (playerAniId)
{
case HIGH_LEVEL_MAGIC_ATTACK:
//Trident of the seas
for (int tridentOfTheSeas : TRIDENT_OF_THE_SEAS_IDS)
{
@@ -425,32 +539,31 @@ public class SuppliesTrackerPlugin extends Plugin
buildEntries(BLOOD_RUNE, 3);
}
}
}
else if (animationChanged.getActor().getAnimation() == LOW_LEVEL_MAGIC_ATTACK)
{
break;
case LOW_LEVEL_MAGIC_ATTACK:
case BARRAGE_ANIMATION:
case BLITZ_ANIMATION:
case LOW_LEVEL_STANDARD_SPELLS:
case WAVE_SPELL_ANIMATION:
case SURGE_SPELL_ANIMATION:
case HIGH_ALCH_ANIMATION:
case LUNAR_HUMIDIFY:
old = client.getItemContainer(InventoryID.INVENTORY);
if (old != null && old.getItems() != null && actionStack.stream().noneMatch(a ->
if (old != null && old.getItems() != null &&
actionStack.stream().noneMatch(a ->
a.getType() == CAST))
{
MenuAction newAction = new MenuAction(CAST, old.getItems());
actionStack.push(newAction);
}
}
else if (animationChanged.getActor().getAnimation() == BARRAGE_ANIMATION ||
animationChanged.getActor().getAnimation() == BLITZ_ANIMATION)
if (!magicXpChanged)
{
old = client.getItemContainer(InventoryID.INVENTORY);
if (old != null && old.getItems() != null && actionStack.stream().noneMatch(a ->
a.getType() == CAST))
{
MenuAction newAction = new MenuAction(CAST, old.getItems());
actionStack.push(newAction);
skipTick = true;
noXpCast = true;
}
}
else if (animationChanged.getActor().getAnimation() == SCYTHE_OF_VITUR_ANIMATION)
{
break;
case SCYTHE_OF_VITUR_ANIMATION:
if (config.chargesBox())
{
buildChargesEntries(SCYTHE_OF_VITUR);
@@ -460,6 +573,11 @@ public class SuppliesTrackerPlugin extends Plugin
buildEntries(BLOOD_RUNE, 3);
buildEntries(COINS_995, itemManager.getItemPrice(VIAL_OF_BLOOD_22446) / 100);
}
break;
case ONEHAND_SLASH_SWORD_ANIMATION:
case ONEHAND_STAB_SWORD_ANIMATION:
buildChargesEntries(BLADE_OF_SAELDOR);
break;
}
}
}
@@ -469,6 +587,26 @@ public class SuppliesTrackerPlugin extends Plugin
{
ItemContainer itemContainer = itemContainerChanged.getItemContainer();
if (itemContainer != null && itemContainer == client.getItemContainer(InventoryID.INVENTORY))
{
for (int i = 0; i < client.getItemContainer(InventoryID.INVENTORY).getItems().length; i++)
{
int tItemId = client.getItemContainer(InventoryID.INVENTORY).getItems()[i].getId();
if (tItemId == RUNE_POUCH || tItemId == RUNE_POUCH_23650 || tItemId == RUNE_POUCH_L)
{
runepouchInInv = true;
break;
}
else
{
runepouchInInv = false;
}
}
}
if (itemContainer == client.getItemContainer(InventoryID.INVENTORY) &&
old != null)
{
@@ -844,6 +982,10 @@ public class SuppliesTrackerPlugin extends Plugin
}
}
if (itemId == PADDLEFISH)
{
return;
}
// convert potions, pizzas/pies, and cakes to their full equivalents
// e.g. a half pizza becomes full pizza, 3 dose potion becomes 4, etc...
if (isPotion(name))
@@ -914,13 +1056,13 @@ public class SuppliesTrackerPlugin extends Plugin
switch (itemId)
{
case AMULET_OF_GLORY6:
calculatedPrice = ((itemManager.getItemPrice(AMULET_OF_GLORY6) * newQuantity) / 6);
calculatedPrice = (((itemManager.getItemPrice(AMULET_OF_GLORY6) - (itemManager.getItemPrice(AMULET_OF_GLORY))) * newQuantity) / 6);
break;
case RING_OF_DUELING8:
calculatedPrice = ((itemManager.getItemPrice(RING_OF_DUELING8) * newQuantity) / 8);
break;
case RING_OF_WEALTH_5:
calculatedPrice = ((itemManager.getItemPrice(RING_OF_WEALTH_5) * newQuantity) / 5);
calculatedPrice = (((itemManager.getItemPrice(RING_OF_WEALTH_5) - (itemManager.getItemPrice(RING_OF_WEALTH))) * newQuantity) / 5);
break;
case COMBAT_BRACELET6:
calculatedPrice = ((itemManager.getItemPrice(COMBAT_BRACELET6) * newQuantity) / 6);
@@ -929,7 +1071,7 @@ public class SuppliesTrackerPlugin extends Plugin
calculatedPrice = ((itemManager.getItemPrice(GAMES_NECKLACE8) * newQuantity) / 8);
break;
case SKILLS_NECKLACE6:
calculatedPrice = ((itemManager.getItemPrice(SKILLS_NECKLACE6) * newQuantity) / 6);
calculatedPrice = (((itemManager.getItemPrice(SKILLS_NECKLACE6) - (itemManager.getItemPrice(SKILLS_NECKLACE))) * newQuantity) / 6);
break;
case NECKLACE_OF_PASSAGE5:
calculatedPrice = ((itemManager.getItemPrice(NECKLACE_OF_PASSAGE5) * newQuantity) / 5);
@@ -951,6 +1093,9 @@ public class SuppliesTrackerPlugin extends Plugin
case SANGUINESTI_STAFF:
calculatedPrice = (itemManager.getItemPrice(BLOOD_RUNE) * newQuantity * 3);
break;
case BLADE_OF_SAELDOR:
calculatedPrice = 0;
break;
}
// write the new quantity and calculated price for this entry
@@ -969,7 +1114,7 @@ public class SuppliesTrackerPlugin extends Plugin
/**
* reset all item stacks
*/
void clearSupplies()
public void clearSupplies()
{
suppliesEntry.clear();
}
@@ -979,7 +1124,7 @@ public class SuppliesTrackerPlugin extends Plugin
*
* @param itemId the id of the item stack
*/
void clearItem(int itemId)
public void clearItem(int itemId)
{
suppliesEntry.remove(itemId);
}
@@ -990,7 +1135,7 @@ public class SuppliesTrackerPlugin extends Plugin
* @param name the given name
* @return the item id for this name
*/
int getPotionID(String name)
public int getPotionID(String name)
{
int itemId = 0;
@@ -1069,4 +1214,23 @@ public class SuppliesTrackerPlugin extends Plugin
}
return itemId;
}
private void checkUsedRunePouch()
{
if (magicXpChanged || noXpCast)
{
if (amountused1 != 0)
{
buildEntries(Runes.getRune(rune1).getItemId(), amountused1);
}
if (amountused2 != 0)
{
buildEntries(Runes.getRune(rune2).getItemId(), amountused2);
}
if (amountused3 != 0)
{
buildEntries(Runes.getRune(rune3).getItemId(), amountused3);
}
}
}
}

View File

@@ -23,7 +23,7 @@
* (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.suppliestracker;
package net.runelite.client.plugins.suppliestracker.ui;
import java.awt.BorderLayout;
import java.awt.Color;
@@ -37,9 +37,11 @@ import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import net.runelite.client.plugins.suppliestracker.ItemType;
import net.runelite.client.plugins.suppliestracker.SuppliesTrackerItem;
import net.runelite.client.plugins.suppliestracker.SuppliesTrackerPlugin;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.ItemDefinition;
import static net.runelite.api.ItemID.*;
import net.runelite.api.util.Text;
import net.runelite.client.game.ItemManager;
@@ -50,9 +52,10 @@ import net.runelite.client.util.AsyncBufferedImage;
import net.runelite.client.util.QuantityFormatter;
@Singleton
abstract class SuppliesBox extends JPanel
public abstract class SuppliesBox extends JPanel
{
private static final int ITEMS_PER_ROW = 5;
public final ItemManager itemManager;
protected final SuppliesTrackerPlugin plugin;
private final JPanel itemContainer = new JPanel();
@@ -60,12 +63,10 @@ abstract class SuppliesBox extends JPanel
private final JLabel subTitleLabel = new JLabel();
private final SuppliesTrackerPanel panel;
@Getter(AccessLevel.PACKAGE)
private final String id;
@Getter(AccessLevel.PACKAGE)
private final ItemType type;
@Getter(AccessLevel.PACKAGE)
private final List<SuppliesTrackerItem> trackedItems = new ArrayList<>();
private long totalPrice;
@@ -85,8 +86,6 @@ abstract class SuppliesBox extends JPanel
render();
}
abstract String buildTooltip(int itemId, int qty, SuppliesTrackerItem item);
public static SuppliesBox of(
ItemManager itemManager,
String id,
@@ -109,6 +108,8 @@ abstract class SuppliesBox extends JPanel
return new DefaultSuppliesBox(itemManager, id, plugin, panel, type);
}
abstract String buildTooltip(int itemId, int qty, SuppliesTrackerItem item);
/**
* Builds the box onto the panel
*/
@@ -166,9 +167,13 @@ abstract class SuppliesBox extends JPanel
*
* @param item item to be checked
*/
void update(SuppliesTrackerItem item)
public void update(SuppliesTrackerItem item)
{
trackedItems.removeIf(r -> r.getId() == item.getId());
if (item.getName() == null || item.getId() == 0 || item.getName().toLowerCase().equals("null"))
{
return;
}
trackedItems.add(item);
setVisible(trackedItems.size() > 0);
}
@@ -188,7 +193,7 @@ abstract class SuppliesBox extends JPanel
/**
* Clears trackedItems
*/
void clearAll()
public void clearAll()
{
trackedItems.clear();
setVisible(false);
@@ -199,7 +204,7 @@ abstract class SuppliesBox extends JPanel
*
* @return the total cost of all tracked items
*/
long getTotalSupplies()
public long getTotalSupplies()
{
long totalSupplies = 0;
for (SuppliesTrackerItem item : trackedItems)
@@ -209,7 +214,7 @@ abstract class SuppliesBox extends JPanel
return totalSupplies;
}
long getTotalPrice()
public long getTotalPrice()
{
return totalPrice;
}
@@ -217,7 +222,7 @@ abstract class SuppliesBox extends JPanel
/**
* Runs buildItems method and recalculates supplies cost and quantity.
*/
void rebuild()
public void rebuild()
{
buildItems();
@@ -251,7 +256,7 @@ abstract class SuppliesBox extends JPanel
* Builds an arraylist of items based off trackedItems and populates
* boxes with item information
*/
private void buildItems()
void buildItems()
{
final List<SuppliesTrackerItem> items = new ArrayList<>(trackedItems);
totalPrice = 0;
@@ -286,6 +291,14 @@ abstract class SuppliesBox extends JPanel
itemImage.addTo(imageLabel);
slotContainer.add(imageLabel);
if (item.getName() == null || item.getId() == 0
|| item.getName().toLowerCase().equals("null")
|| getModifiedItemId(item.getName(), item.getId()) == 0
|| itemManager.getImage(getModifiedItemId(item.getName(), item.getId()), item.getQuantity(), item.getQuantity() > 1) == null)
{
continue;
}
// create popup menu
final JPopupMenu popupMenu = new JPopupMenu();
popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5));
@@ -316,8 +329,7 @@ abstract class SuppliesBox extends JPanel
@Override
final String buildTooltip(int itemId, int qty, SuppliesTrackerItem item)
{
ItemDefinition itemDef = itemManager.getItemDefinition(itemId);
final String name = itemDef.getName();
final String name = item.getName();
StringBuilder tooltip = new StringBuilder();
if (name.toLowerCase().contains("glory"))
@@ -429,7 +441,6 @@ abstract class SuppliesBox extends JPanel
return tooltip.toString();
case SANGUINESTI_STAFF:
tooltip.append("Blood Rune x ")
.append(qty * 3).append(" (")
.append(QuantityFormatter.quantityToStackSize(
@@ -438,6 +449,11 @@ abstract class SuppliesBox extends JPanel
.append("gp)");
return tooltip.toString();
case BLADE_OF_SAELDOR:
tooltip.append("Crystal Shard x ")
.append(qty).append(" / 100");
return tooltip.toString();
case TRIDENT_OF_THE_SEAS:
tooltip.append("<html>")
.append("Chaos Rune x ")
@@ -533,31 +549,6 @@ abstract class SuppliesBox extends JPanel
super(itemManager, id, plugin, panel, type);
}
@Override
final String buildTooltip(int itemId, int qty, SuppliesTrackerItem item)
{
ItemDefinition itemDef = itemManager.getItemDefinition(itemId);
final String name = itemDef.getName();
final long price = itemManager.getItemPrice(itemId);
return name + " x " + qty + " (" + QuantityFormatter.quantityToStackSize(price * qty) + ") ";
}
@Override
int getModifiedItemId(String name, int itemId)
{
if (SuppliesTrackerPlugin.isCake(name, itemId))
{
return getSlice(itemId);
}
if (SuppliesTrackerPlugin.isPizzaPie(name))
{
return getHalf(itemId);
}
return itemId;
}
//Switches full cake ids to get the image for slice
private static int getSlice(int itemId)
{
@@ -624,6 +615,28 @@ abstract class SuppliesBox extends JPanel
}
return itemId;
}
@Override
final String buildTooltip(int itemId, int qty, SuppliesTrackerItem item)
{
final long price = itemManager.getItemPrice(itemId);
return item.getName() + " x " + qty + " (" + QuantityFormatter.quantityToStackSize(price * qty) + ") ";
}
@Override
int getModifiedItemId(String name, int itemId)
{
if (SuppliesTrackerPlugin.isCake(name, itemId))
{
return getSlice(itemId);
}
if (SuppliesTrackerPlugin.isPizzaPie(name))
{
return getHalf(itemId);
}
return itemId;
}
}
private static class PotionSuppliesBox extends SuppliesBox
@@ -636,11 +649,8 @@ abstract class SuppliesBox extends JPanel
@Override
final String buildTooltip(int itemId, int qty, SuppliesTrackerItem item)
{
ItemDefinition itemDef = itemManager.getItemDefinition(itemId);
final String name = itemDef.getName();
final long price = itemManager.getItemPrice(plugin.getPotionID(name.replaceAll(POTION_PATTERN, "(4)"))) / 4;
return name + " x " + qty + " (" + QuantityFormatter.quantityToStackSize(price * qty) + ") ";
final long price = itemManager.getItemPrice(plugin.getPotionID(item.getName().replaceAll(POTION_PATTERN, "(4)"))) / 4;
return item.getName() + " x " + qty + " (" + QuantityFormatter.quantityToStackSize(price * qty) + ") ";
}
@Override
@@ -684,12 +694,8 @@ abstract class SuppliesBox extends JPanel
@Override
final String buildTooltip(int itemId, int qty, SuppliesTrackerItem item)
{
ItemDefinition itemDef = itemManager.getItemDefinition(itemId);
final String name = itemDef.getName();
final long price = itemManager.getItemPrice(itemId);
return name + " x " + qty + " (" + QuantityFormatter.quantityToStackSize(price * qty) + ") ";
return item.getName() + " x " + qty + " (" + QuantityFormatter.quantityToStackSize(price * qty) + ") ";
}
@Override

View File

@@ -24,7 +24,7 @@
* (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.suppliestracker;
package net.runelite.client.plugins.suppliestracker.ui;
import java.awt.BorderLayout;
import java.awt.GridLayout;
@@ -34,12 +34,18 @@ import java.util.List;
import javax.inject.Singleton;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.border.EmptyBorder;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.suppliestracker.ItemType;
import net.runelite.client.plugins.suppliestracker.SuppliesTrackerItem;
import net.runelite.client.plugins.suppliestracker.SuppliesTrackerPlugin;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.PluginPanel;
@@ -48,32 +54,34 @@ import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.QuantityFormatter;
@Singleton
class SuppliesTrackerPanel extends PluginPanel
public class SuppliesTrackerPanel extends PluginPanel
{
private static final String HTML_LABEL_TEMPLATE =
"<html><body style='color:%s'>%s<span style='color:white'>%s</span></body></html>";
// Handle supplies logs
@Getter(AccessLevel.PACKAGE)
private final JPanel logsContainer = new JPanel();
//Boxes for holding supplies
private final List<SuppliesBox> boxList = new ArrayList<>();
private final PluginErrorPanel errorPanel = new PluginErrorPanel();
// Handle overall session data
private final JPanel overallPanel = new JPanel();
//Boxes for holding supplies
private final List<SuppliesBox> boxList = new ArrayList<>();
private final PluginErrorPanel errorPanel = new PluginErrorPanel();
private final JLabel overallSuppliesUsedLabel = new JLabel();
private final JLabel overallCostLabel = new JLabel();
private final JLabel overallIcon = new JLabel();
private UpdatePanel updatePanel;
@Getter(AccessLevel.PACKAGE)
private JButton info;
private int overallSuppliesUsed;
private int overallCost;
SuppliesTrackerPanel(final ItemManager itemManager, SuppliesTrackerPlugin plugin)
public SuppliesTrackerPanel(final ItemManager itemManager, SuppliesTrackerPlugin plugin)
{
setBorder(new EmptyBorder(6, 6, 6, 6));
setBackground(ColorScheme.DARK_GRAY_COLOR);
setLayout(new BorderLayout());
updatePanel = new UpdatePanel(this);
// Create layout panel for wrapping
final JPanel layoutPanel = new JPanel();
@@ -133,8 +141,25 @@ class SuppliesTrackerPanel extends PluginPanel
layoutPanel.add(logsContainer);
errorPanel.setContent("Supply trackers", "You have not used any supplies yet.");
add(errorPanel);
add(updatePanel);
updatePanel.setVisible(true);
overallPanel.setVisible(false);
logsContainer.setVisible(false);
info = new JButton("Info");
info.addActionListener(e ->
{
overallPanel.setVisible(false);
logsContainer.setVisible(false);
remove(updatePanel);
updatePanel = new UpdatePanel(this);
add(updatePanel);
updatePanel.setVisible(true);
info.setVisible(false);
});
layoutPanel.add(info);
info.setVisible(false);
}
/**
@@ -155,7 +180,7 @@ class SuppliesTrackerPanel extends PluginPanel
*
* @param img the img for the header icon
*/
void loadHeaderIcon(BufferedImage img)
public void loadHeaderIcon(BufferedImage img)
{
overallIcon.setIcon(new ImageIcon(img));
}
@@ -165,7 +190,7 @@ class SuppliesTrackerPanel extends PluginPanel
*
* @param item the item to add
*/
void addItem(SuppliesTrackerItem item)
public void addItem(SuppliesTrackerItem item)
{
ItemType category = ItemType.categorize(item);
for (SuppliesBox box : boxList)
@@ -184,7 +209,7 @@ class SuppliesTrackerPanel extends PluginPanel
* Updates overall stats to calculate overall used and overall cost from
* the info in each box
*/
void updateOverall()
public void updateOverall()
{
overallSuppliesUsed = 0;
for (SuppliesBox box : boxList)
@@ -211,7 +236,10 @@ class SuppliesTrackerPanel extends PluginPanel
else
{
remove(errorPanel);
if (!updatePanel.isVisible())
{
overallPanel.setVisible(true);
}
}
}
}

View File

@@ -0,0 +1,54 @@
package net.runelite.client.plugins.suppliestracker.ui;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.PluginPanel;
import javax.inject.Singleton;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.border.EmptyBorder;
import java.io.IOException;
@Singleton
class UpdatePanel extends PluginPanel
{
private SuppliesTrackerPanel panel;
UpdatePanel(SuppliesTrackerPanel suppliesTrackerPanel)
{
this.panel = suppliesTrackerPanel;
setBorder(new EmptyBorder(6, 6, 6, 6));
setBackground(ColorScheme.DARK_GRAY_COLOR);
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
java.net.URL helpURL = UpdatePanel.class.getResource(
"Info.html");
if (helpURL != null)
{
try
{
editorPane.setPage(helpURL);
}
catch (IOException e)
{
throw new IllegalStateException("File not found");
}
}
JButton close = new JButton("Close info");
close.addActionListener(e ->
{
this.setVisible(false);
panel.updateOverall();
panel.getInfo().setVisible(true);
panel.getLogsContainer().setVisible(true);
});
this.add(close);
this.add(editorPane);
}
}

View File

@@ -0,0 +1,33 @@
<h1 style="text-align: center;">Supplies Tracker</h1>
<h2>Info:</h2>
<h4>Toxic Blowpipe:</h4>
<p>Set darts used in config before using.</p>
<p>Uses a formula to estimate usage since there is no way to get info from blowpipe automatically.&nbsp;</p>
<p>&nbsp;</p>
<h4>Weapon charges:</h4>
<p>(Default disabled to enable check box in configs) Weapons charges groups items used in weapons charged in a box with
the weapons icon. Tooltip shows the items used.&nbsp;</p>
<p>Current supported weapons:</p>
<ol>
<li>Scythe</li>
<li>Tridents</li>
<li>Sang staff</li>
</ol>
<p>&nbsp;</p>
<p><span style="color: #ff0000;"><em>Supplies tracker may not be 100% accurate. Tick eating with Karambwan can be missed if they aren't eaten the same tick as other food.</em></span>
</p>
<p>&nbsp;</p>
<p>Current tracking capabilities:</p>
<p>Supplies (food, potions, teleport tablets, teleport scrolls)</p>
<p>Ammo (blowpipe [must be set in config], arrows, thrown items)</p>
<p>Runes (Rune Pouch support added in 1.5)</p>
<p>Jewellery</p>
<p>Weapons charges</p>
<h3 style="text-align: center;">Changelog</h3>
<h2>1.5</h2>
<p>Added Rune pouch support!</p>
<p>Null items shouldn't show anymore</p>
<p>Fixed barrows tablet in ammo bug</p>
<p>Fixed knives in food bug</p>
<p>&nbsp;</p>
<p>&nbsp;</p>