From 50d72f96358412e26b5590de8a39ba264b726f36 Mon Sep 17 00:00:00 2001 From: Christopher Riwik Date: Wed, 20 Aug 2025 17:53:48 +0200 Subject: [PATCH 1/3] Added an info box showing the total amount of usable metal you own for Giants' foundry, with possibility to filter for any combination of equipment, metal bars and ore. --- .../EasyGiantsFoundryConfig.java | 55 ++- .../EasyGiantsFoundryMetalInfo.java | 326 ++++++++++++++++++ .../EasyGiantsFoundryPlugin.java | 11 + .../easygiantsfoundry/enums/Location.java | 19 + 4 files changed, 410 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryMetalInfo.java create mode 100644 src/main/java/com/toofifty/easygiantsfoundry/enums/Location.java diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java index af42757..d440df2 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java @@ -1,6 +1,8 @@ package com.toofifty.easygiantsfoundry; import java.awt.Color; + +import com.toofifty.easygiantsfoundry.enums.Location; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; @@ -509,10 +511,61 @@ public interface EasyGiantsFoundryConfig extends Config return Color.CYAN; } + @ConfigSection( + name = "Total Metals Info", + description = "Shows an info box with total number of metals usable for the foundry", + position = 5 + ) + String totalMetalsInfo = "metalInfoSettings"; + @ConfigItem( + position = 1, + keyName = "location", + name = "Where To Show:", + description = "Where to show the info box", + section = totalMetalsInfo + ) + default Location location() { return Location.GIANTS_FOUNDRY; } + + @ConfigItem( + position = 2, + keyName = "includeEquipment", + name = "Include Equipment", + description = "Include equipment that are meltable in the foundry in the count", + section = totalMetalsInfo + ) + default boolean includeEquipment() { return true; } + + @ConfigItem( + position = 3, + keyName = "includeMetalBars", + name = "Include Metal Bars", + description = "Include actual metal bars in the count", + section = totalMetalsInfo + ) + default boolean includeMetalBars() { return true; } + + @ConfigItem( + position = 4, + keyName = "includeOre", + name = "Include Ore", + description = "Include unmelted ores in the count (iron ore is added to both iron and steel)", + section = totalMetalsInfo + ) + default boolean includeOre() { return false; } + + @ConfigItem( + position = 4, + keyName = "showZeroValues", + name = "Show All Metals", + description = "Show rows for metals even if you don't have any of that type", + section = totalMetalsInfo + ) + default boolean showZeroValues() { return false; } + @ConfigSection( name = "Advanced", description = "Advanced Settings", - position = 5 + position = 6 ) String advancedSettings = "generalSettings"; diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryMetalInfo.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryMetalInfo.java new file mode 100644 index 0000000..f56b601 --- /dev/null +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryMetalInfo.java @@ -0,0 +1,326 @@ +package com.toofifty.easygiantsfoundry; + +import com.toofifty.easygiantsfoundry.enums.Location; +import net.runelite.api.Client; +import net.runelite.api.Item; +import net.runelite.api.ItemContainer; +import net.runelite.api.coords.WorldPoint; +import net.runelite.api.gameval.ItemID; +import net.runelite.client.ui.overlay.OverlayPanel; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.components.LineComponent; + +import javax.inject.Inject; +import java.awt.*; +import java.util.HashMap; + +class EasyGiantsFoundryMetalInfo extends OverlayPanel +{ + private final Rectangle giantsFoundryArea = new Rectangle(3354, 11478, 24, 25); + + private final Client client; + private final EasyGiantsFoundryConfig config; + + private final HashMap bronzeBarValues = new HashMap<>(); + private final HashMap ironBarValues = new HashMap<>(); + private final HashMap steelBarValues = new HashMap<>(); + private final HashMap mithrilBarValues = new HashMap<>(); + private final HashMap adamBarValues = new HashMap<>(); + private final HashMap runeBarValues = new HashMap<>(); + protected int bronzeBars; + protected int copperOre; + protected int tinOre; + protected int ironBars; + protected int steelBars; + protected int mithrilBars; + protected int adamantiteBars; + protected int runiteBars; + + protected ItemContainer bank; + protected ItemContainer inventory; + + @Inject + private EasyGiantsFoundryMetalInfo(final Client client, final EasyGiantsFoundryPlugin plugin, final EasyGiantsFoundryConfig config) + { + super(plugin); + setPosition(OverlayPosition.BOTTOM_RIGHT); + this.client = client; + this.config = config; + + InitializeEquipmentValues(); + } + + @Override + public Dimension render(Graphics2D graphics) + { + if ((config.location() == Location.GIANTS_FOUNDRY && !TileIsInFoundry(client.getLocalPlayer().getWorldLocation())) + || config.location() == Location.NOWHERE) + return null; + + CountBars(); + if (bronzeBars > 0 || config.showZeroValues()) + AddMetalBarText("Bronze bars:", bronzeBars); + if (ironBars > 0 || config.showZeroValues()) + AddMetalBarText("Iron bars:", ironBars); + if (steelBars > 0 || config.showZeroValues()) + AddMetalBarText("Steel bars:", steelBars); + if (mithrilBars > 0 || config.showZeroValues()) + AddMetalBarText("Mithril bars:", mithrilBars); + if (adamantiteBars > 0 || config.showZeroValues()) + AddMetalBarText("Adamantite bars:", adamantiteBars); + if (runiteBars > 0 || config.showZeroValues()) + AddMetalBarText("Runite bars:", runiteBars); + + return super.render(graphics); + } + + private void AddMetalBarText(String text, int number) { + panelComponent.getChildren().add(LineComponent.builder() + .left(text) + .right(Integer.toString(number)) + .build()); + } + + public void CountBars() + { + bronzeBars = 0; + ironBars = 0; + steelBars = 0; + mithrilBars = 0; + adamantiteBars = 0; + runiteBars = 0; + copperOre = 0; + tinOre = 0; + + if (inventory != null) { + AddMetalValues(inventory); + } + if (bank != null) { + AddMetalValues(bank); + } + + if (config.includeOre()) + bronzeBars += Math.min(copperOre, tinOre); + } + + private void AddMetalValues(ItemContainer container) { + for (Item item : container.getItems()) { + if (item.getId() >= 0 && item.getQuantity() > 0) { + if (config.includeEquipment()) { + if (bronzeBarValues.containsKey(item.getId())) + bronzeBars += bronzeBarValues.get(item.getId()) * item.getQuantity(); + if (ironBarValues.containsKey(item.getId())) + ironBars += ironBarValues.get(item.getId()) * item.getQuantity(); + if (steelBarValues.containsKey(item.getId())) + steelBars += steelBarValues.get(item.getId()) * item.getQuantity(); + if (mithrilBarValues.containsKey(item.getId())) + mithrilBars += mithrilBarValues.get(item.getId()) * item.getQuantity(); + if (adamBarValues.containsKey(item.getId())) + adamantiteBars += adamBarValues.get(item.getId()) * item.getQuantity(); + if (runeBarValues.containsKey(item.getId())) + runiteBars += runeBarValues.get(item.getId()) * item.getQuantity(); + } + + if (config.includeMetalBars()) { + if (item.getId() == ItemID.BRONZE_BAR || item.getId() == ItemID.Cert.BRONZE_BAR) + bronzeBars += item.getQuantity(); + if (item.getId() == ItemID.IRON_BAR || item.getId() == ItemID.Cert.IRON_BAR) + ironBars += item.getQuantity(); + if (item.getId() == ItemID.STEEL_BAR || item.getId() == ItemID.Cert.STEEL_BAR) + steelBars += item.getQuantity(); + if (item.getId() == ItemID.MITHRIL_BAR || item.getId() == ItemID.Cert.MITHRIL_BAR) + mithrilBars += item.getQuantity(); + if (item.getId() == ItemID.ADAMANTITE_BAR || item.getId() == ItemID.Cert.ADAMANTITE_BAR) + adamantiteBars += item.getQuantity(); + if (item.getId() == ItemID.RUNITE_BAR || item.getId() == ItemID.Cert.RUNITE_BAR) + runiteBars += item.getQuantity(); + } + + if (config.includeOre()) { + if (item.getId() == ItemID.COPPER_ORE || item.getId() == ItemID.Cert.COPPER_ORE) + copperOre += item.getQuantity(); + if (item.getId() == ItemID.TIN_ORE || item.getId() == ItemID.Cert.TIN_ORE) + tinOre += item.getQuantity(); + if (item.getId() == ItemID.IRON_ORE || item.getId() == ItemID.Cert.IRON_ORE) { + ironBars += item.getQuantity(); + steelBars += item.getQuantity(); + } + if (item.getId() == ItemID.MITHRIL_ORE || item.getId() == ItemID.Cert.MITHRIL_ORE) + mithrilBars += item.getQuantity(); + if (item.getId() == ItemID.ADAMANTITE_ORE || item.getId() == ItemID.Cert.ADAMANTITE_ORE) + adamantiteBars += item.getQuantity(); + if (item.getId() == ItemID.RUNITE_ORE || item.getId() == ItemID.Cert.RUNITE_ORE) + runiteBars += item.getQuantity(); + } + } + } + } + + private boolean TileIsInFoundry(WorldPoint tile) { + return giantsFoundryArea.contains(new Point(tile.getX(), tile.getY())); + } + + private void InitializeEquipmentValues() { + bronzeBarValues.put(ItemID.BRONZE_SCIMITAR, 1); + bronzeBarValues.put(ItemID.BRONZE_LONGSWORD, 1); + bronzeBarValues.put(ItemID.BRONZE_FULL_HELM, 1); + bronzeBarValues.put(ItemID.BRONZE_SQ_SHIELD, 1); + bronzeBarValues.put(ItemID.BRONZE_CLAWS, 1); + bronzeBarValues.put(ItemID.BRONZE_WARHAMMER, 2); + bronzeBarValues.put(ItemID.BRONZE_BATTLEAXE, 2); + bronzeBarValues.put(ItemID.BRONZE_CHAINBODY, 2); + bronzeBarValues.put(ItemID.BRONZE_KITESHIELD, 2); + bronzeBarValues.put(ItemID.BRONZE_2H_SWORD, 2); + bronzeBarValues.put(ItemID.BRONZE_PLATELEGS, 2); + bronzeBarValues.put(ItemID.BRONZE_PLATESKIRT, 2); + bronzeBarValues.put(ItemID.BRONZE_PLATEBODY, 4); + bronzeBarValues.put(ItemID.Cert.BRONZE_SCIMITAR, 1); + bronzeBarValues.put(ItemID.Cert.BRONZE_LONGSWORD, 1); + bronzeBarValues.put(ItemID.Cert.BRONZE_FULL_HELM, 1); + bronzeBarValues.put(ItemID.Cert.BRONZE_SQ_SHIELD, 1); + bronzeBarValues.put(ItemID.Cert.BRONZE_CLAWS, 1); + bronzeBarValues.put(ItemID.Cert.BRONZE_WARHAMMER, 2); + bronzeBarValues.put(ItemID.Cert.BRONZE_BATTLEAXE, 2); + bronzeBarValues.put(ItemID.Cert.BRONZE_CHAINBODY, 2); + bronzeBarValues.put(ItemID.Cert.BRONZE_KITESHIELD, 2); + bronzeBarValues.put(ItemID.Cert.BRONZE_2H_SWORD, 2); + bronzeBarValues.put(ItemID.Cert.BRONZE_PLATELEGS, 2); + bronzeBarValues.put(ItemID.Cert.BRONZE_PLATESKIRT, 2); + bronzeBarValues.put(ItemID.Cert.BRONZE_PLATEBODY, 4); + + ironBarValues.put(ItemID.IRON_SCIMITAR, 1); + ironBarValues.put(ItemID.IRON_LONGSWORD, 1); + ironBarValues.put(ItemID.IRON_FULL_HELM, 1); + ironBarValues.put(ItemID.IRON_SQ_SHIELD, 1); + ironBarValues.put(ItemID.IRON_CLAWS, 1); + ironBarValues.put(ItemID.IRON_WARHAMMER, 2); + ironBarValues.put(ItemID.IRON_BATTLEAXE, 2); + ironBarValues.put(ItemID.IRON_CHAINBODY, 2); + ironBarValues.put(ItemID.IRON_KITESHIELD, 2); + ironBarValues.put(ItemID.IRON_2H_SWORD, 2); + ironBarValues.put(ItemID.IRON_PLATELEGS, 2); + ironBarValues.put(ItemID.IRON_PLATESKIRT, 2); + ironBarValues.put(ItemID.IRON_PLATEBODY, 4); + ironBarValues.put(ItemID.Cert.IRON_SCIMITAR, 1); + ironBarValues.put(ItemID.Cert.IRON_LONGSWORD, 1); + ironBarValues.put(ItemID.Cert.IRON_FULL_HELM, 1); + ironBarValues.put(ItemID.Cert.IRON_SQ_SHIELD, 1); + ironBarValues.put(ItemID.Cert.IRON_CLAWS, 1); + ironBarValues.put(ItemID.Cert.IRON_WARHAMMER, 2); + ironBarValues.put(ItemID.Cert.IRON_BATTLEAXE, 2); + ironBarValues.put(ItemID.Cert.IRON_CHAINBODY, 2); + ironBarValues.put(ItemID.Cert.IRON_KITESHIELD, 2); + ironBarValues.put(ItemID.Cert.IRON_2H_SWORD, 2); + ironBarValues.put(ItemID.Cert.IRON_PLATELEGS, 2); + ironBarValues.put(ItemID.Cert.IRON_PLATESKIRT, 2); + ironBarValues.put(ItemID.Cert.IRON_PLATEBODY, 4); + + steelBarValues.put(ItemID.STEEL_SCIMITAR, 1); + steelBarValues.put(ItemID.STEEL_LONGSWORD, 1); + steelBarValues.put(ItemID.STEEL_FULL_HELM, 1); + steelBarValues.put(ItemID.STEEL_SQ_SHIELD, 1); + steelBarValues.put(ItemID.STEEL_CLAWS, 1); + steelBarValues.put(ItemID.STEEL_WARHAMMER, 2); + steelBarValues.put(ItemID.STEEL_BATTLEAXE, 2); + steelBarValues.put(ItemID.STEEL_CHAINBODY, 2); + steelBarValues.put(ItemID.STEEL_KITESHIELD, 2); + steelBarValues.put(ItemID.STEEL_2H_SWORD, 2); + steelBarValues.put(ItemID.STEEL_PLATELEGS, 2); + steelBarValues.put(ItemID.STEEL_PLATESKIRT, 2); + steelBarValues.put(ItemID.STEEL_PLATEBODY, 4); + steelBarValues.put(ItemID.Cert.STEEL_SCIMITAR, 1); + steelBarValues.put(ItemID.Cert.STEEL_LONGSWORD, 1); + steelBarValues.put(ItemID.Cert.STEEL_FULL_HELM, 1); + steelBarValues.put(ItemID.Cert.STEEL_SQ_SHIELD, 1); + steelBarValues.put(ItemID.Cert.STEEL_CLAWS, 1); + steelBarValues.put(ItemID.Cert.STEEL_WARHAMMER, 2); + steelBarValues.put(ItemID.Cert.STEEL_BATTLEAXE, 2); + steelBarValues.put(ItemID.Cert.STEEL_CHAINBODY, 2); + steelBarValues.put(ItemID.Cert.STEEL_KITESHIELD, 2); + steelBarValues.put(ItemID.Cert.STEEL_2H_SWORD, 2); + steelBarValues.put(ItemID.Cert.STEEL_PLATELEGS, 2); + steelBarValues.put(ItemID.Cert.STEEL_PLATESKIRT, 2); + steelBarValues.put(ItemID.Cert.STEEL_PLATEBODY, 4); + + mithrilBarValues.put(ItemID.MITHRIL_SCIMITAR, 1); + mithrilBarValues.put(ItemID.MITHRIL_LONGSWORD, 1); + mithrilBarValues.put(ItemID.MITHRIL_FULL_HELM, 1); + mithrilBarValues.put(ItemID.MITHRIL_SQ_SHIELD, 1); + mithrilBarValues.put(ItemID.MITHRIL_CLAWS, 1); + mithrilBarValues.put(ItemID.MITHRIL_WARHAMMER, 2); + mithrilBarValues.put(ItemID.MITHRIL_BATTLEAXE, 2); + mithrilBarValues.put(ItemID.MITHRIL_CHAINBODY, 2); + mithrilBarValues.put(ItemID.MITHRIL_KITESHIELD, 2); + mithrilBarValues.put(ItemID.MITHRIL_2H_SWORD, 2); + mithrilBarValues.put(ItemID.MITHRIL_PLATELEGS, 2); + mithrilBarValues.put(ItemID.MITHRIL_PLATESKIRT, 2); + mithrilBarValues.put(ItemID.MITHRIL_PLATEBODY, 4); + mithrilBarValues.put(ItemID.Cert.MITHRIL_SCIMITAR, 1); + mithrilBarValues.put(ItemID.Cert.MITHRIL_LONGSWORD, 1); + mithrilBarValues.put(ItemID.Cert.MITHRIL_FULL_HELM, 1); + mithrilBarValues.put(ItemID.Cert.MITHRIL_SQ_SHIELD, 1); + mithrilBarValues.put(ItemID.Cert.MITHRIL_CLAWS, 1); + mithrilBarValues.put(ItemID.Cert.MITHRIL_WARHAMMER, 2); + mithrilBarValues.put(ItemID.Cert.MITHRIL_BATTLEAXE, 2); + mithrilBarValues.put(ItemID.Cert.MITHRIL_CHAINBODY, 2); + mithrilBarValues.put(ItemID.Cert.MITHRIL_KITESHIELD, 2); + mithrilBarValues.put(ItemID.Cert.MITHRIL_2H_SWORD, 2); + mithrilBarValues.put(ItemID.Cert.MITHRIL_PLATELEGS, 2); + mithrilBarValues.put(ItemID.Cert.MITHRIL_PLATESKIRT, 2); + mithrilBarValues.put(ItemID.Cert.MITHRIL_PLATEBODY, 4); + + adamBarValues.put(ItemID.ADAMANT_SCIMITAR, 1); + adamBarValues.put(ItemID.ADAMANT_LONGSWORD, 1); + adamBarValues.put(ItemID.ADAMANT_FULL_HELM, 1); + adamBarValues.put(ItemID.ADAMANT_SQ_SHIELD, 1); + adamBarValues.put(ItemID.ADAMANT_CLAWS, 1); + adamBarValues.put(ItemID.ADAMNT_WARHAMMER, 2); + adamBarValues.put(ItemID.ADAMANT_BATTLEAXE, 2); + adamBarValues.put(ItemID.ADAMANT_CHAINBODY, 2); + adamBarValues.put(ItemID.ADAMANT_KITESHIELD, 2); + adamBarValues.put(ItemID.ADAMANT_2H_SWORD, 2); + adamBarValues.put(ItemID.ADAMANT_PLATELEGS, 2); + adamBarValues.put(ItemID.ADAMANT_PLATESKIRT, 2); + adamBarValues.put(ItemID.ADAMANT_PLATEBODY, 4); + adamBarValues.put(ItemID.Cert.ADAMANT_SCIMITAR, 1); + adamBarValues.put(ItemID.Cert.ADAMANT_LONGSWORD, 1); + adamBarValues.put(ItemID.Cert.ADAMANT_FULL_HELM, 1); + adamBarValues.put(ItemID.Cert.ADAMANT_SQ_SHIELD, 1); + adamBarValues.put(ItemID.Cert.ADAMANT_CLAWS, 1); + adamBarValues.put(ItemID.Cert.ADAMNT_WARHAMMER, 2); + adamBarValues.put(ItemID.Cert.ADAMANT_BATTLEAXE, 2); + adamBarValues.put(ItemID.Cert.ADAMANT_CHAINBODY, 2); + adamBarValues.put(ItemID.Cert.ADAMANT_KITESHIELD, 2); + adamBarValues.put(ItemID.Cert.ADAMANT_2H_SWORD, 2); + adamBarValues.put(ItemID.Cert.ADAMANT_PLATELEGS, 2); + adamBarValues.put(ItemID.Cert.ADAMANT_PLATESKIRT, 2); + adamBarValues.put(ItemID.Cert.ADAMANT_PLATEBODY, 4); + + runeBarValues.put(ItemID.RUNE_SCIMITAR, 1); + runeBarValues.put(ItemID.RUNE_LONGSWORD, 1); + runeBarValues.put(ItemID.RUNE_FULL_HELM, 1); + runeBarValues.put(ItemID.RUNE_SQ_SHIELD, 1); + runeBarValues.put(ItemID.RUNE_CLAWS, 1); + runeBarValues.put(ItemID.RUNE_WARHAMMER, 2); + runeBarValues.put(ItemID.RUNE_BATTLEAXE, 2); + runeBarValues.put(ItemID.RUNE_CHAINBODY, 2); + runeBarValues.put(ItemID.RUNE_KITESHIELD, 2); + runeBarValues.put(ItemID.RUNE_2H_SWORD, 2); + runeBarValues.put(ItemID.RUNE_PLATELEGS, 2); + runeBarValues.put(ItemID.RUNE_PLATESKIRT, 2); + runeBarValues.put(ItemID.RUNE_PLATEBODY, 4); + runeBarValues.put(ItemID.Cert.RUNE_SCIMITAR, 1); + runeBarValues.put(ItemID.Cert.RUNE_LONGSWORD, 1); + runeBarValues.put(ItemID.Cert.RUNE_FULL_HELM, 1); + runeBarValues.put(ItemID.Cert.RUNE_SQ_SHIELD, 1); + runeBarValues.put(ItemID.Cert.RUNE_CLAWS, 1); + runeBarValues.put(ItemID.Cert.RUNE_WARHAMMER, 2); + runeBarValues.put(ItemID.Cert.RUNE_BATTLEAXE, 2); + runeBarValues.put(ItemID.Cert.RUNE_CHAINBODY, 2); + runeBarValues.put(ItemID.Cert.RUNE_KITESHIELD, 2); + runeBarValues.put(ItemID.Cert.RUNE_2H_SWORD, 2); + runeBarValues.put(ItemID.Cert.RUNE_PLATELEGS, 2); + runeBarValues.put(ItemID.Cert.RUNE_PLATESKIRT, 2); + runeBarValues.put(ItemID.Cert.RUNE_PLATEBODY, 4); + } +} diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java index 72e77a1..803f137 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java @@ -84,6 +84,9 @@ public class EasyGiantsFoundryPlugin extends Plugin @Inject private FoundryOverlay3D overlay3d; + @Inject + private EasyGiantsFoundryMetalInfo metalInfo; + @Inject private MouldHelper mouldHelper; @@ -107,6 +110,7 @@ public class EasyGiantsFoundryPlugin extends Plugin { overlayManager.add(overlay2d); overlayManager.add(overlay3d); + overlayManager.add(metalInfo); if (client.getGameState() == GameState.LOGGED_IN) { reputation = client.getVarpValue(REPUTATION_VARBIT); @@ -118,6 +122,7 @@ public class EasyGiantsFoundryPlugin extends Plugin { overlayManager.remove(overlay2d); overlayManager.remove(overlay3d); + overlayManager.remove(metalInfo); } @Subscribe @@ -265,6 +270,12 @@ public class EasyGiantsFoundryPlugin extends Plugin updateSmithsOutfitPieces(); } } + else if (event.getContainerId() == InventoryID.BANK.getId()) { + metalInfo.bank = event.getItemContainer(); + } + else if (event.getContainerId() == InventoryID.INVENTORY.getId()) { + metalInfo.inventory = event.getItemContainer(); + } } public void onMenuEntryAdded(MenuEntryAdded event) diff --git a/src/main/java/com/toofifty/easygiantsfoundry/enums/Location.java b/src/main/java/com/toofifty/easygiantsfoundry/enums/Location.java new file mode 100644 index 0000000..20ca938 --- /dev/null +++ b/src/main/java/com/toofifty/easygiantsfoundry/enums/Location.java @@ -0,0 +1,19 @@ +package com.toofifty.easygiantsfoundry.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum Location { + GIANTS_FOUNDRY("Giants' Foundry"), + EVERYWHERE("Everywhere"), + NOWHERE("Nowhere"); + + private final String type; + + @Override + public String toString() { + return type; + } +} From 82d6add9281992aa0c13044a92d02a0472b8dda5 Mon Sep 17 00:00:00 2001 From: Christopher Riwik Date: Wed, 27 Aug 2025 18:28:56 +0200 Subject: [PATCH 2/3] Default to not show info box anywhere. Added a red "Open bank" text if you haven't opened the bank yet. Updated the count to only update when itemContainerChanged triggers. --- .../EasyGiantsFoundryConfig.java | 2 +- .../EasyGiantsFoundryMetalInfo.java | 7 ++++++- .../EasyGiantsFoundryPlugin.java | 15 +++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java index d440df2..a2f5111 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java @@ -524,7 +524,7 @@ public interface EasyGiantsFoundryConfig extends Config description = "Where to show the info box", section = totalMetalsInfo ) - default Location location() { return Location.GIANTS_FOUNDRY; } + default Location location() { return Location.NOWHERE; } @ConfigItem( position = 2, diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryMetalInfo.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryMetalInfo.java index f56b601..7f635dd 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryMetalInfo.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryMetalInfo.java @@ -57,7 +57,12 @@ class EasyGiantsFoundryMetalInfo extends OverlayPanel || config.location() == Location.NOWHERE) return null; - CountBars(); + if (bank == null) + panelComponent.getChildren().add(LineComponent.builder() + .left("Open bank") + .leftColor(Color.RED) + .build()); + if (bronzeBars > 0 || config.showZeroValues()) AddMetalBarText("Bronze bars:", bronzeBars); if (ironBars > 0 || config.showZeroValues()) diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java index 803f137..11b0a77 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java @@ -270,12 +270,15 @@ public class EasyGiantsFoundryPlugin extends Plugin updateSmithsOutfitPieces(); } } - else if (event.getContainerId() == InventoryID.BANK.getId()) { - metalInfo.bank = event.getItemContainer(); - } - else if (event.getContainerId() == InventoryID.INVENTORY.getId()) { - metalInfo.inventory = event.getItemContainer(); - } + else { + if (event.getContainerId() == InventoryID.BANK.getId()) { + metalInfo.bank = event.getItemContainer(); + } + else if (event.getContainerId() == InventoryID.INVENTORY.getId()) { + metalInfo.inventory = event.getItemContainer(); + } + metalInfo.CountBars(); + } } public void onMenuEntryAdded(MenuEntryAdded event) From 257288a6a3ab769e26e148d6d51c6d3d3cf2aea3 Mon Sep 17 00:00:00 2001 From: riktenx Date: Thu, 28 Aug 2025 14:34:17 -0400 Subject: [PATCH 3/3] fixup --- .../EasyGiantsFoundryConfig.java | 96 +++-- .../EasyGiantsFoundryMetalInfo.java | 331 ------------------ .../EasyGiantsFoundryPlugin.java | 28 +- .../easygiantsfoundry/FoundryOverlay2D.java | 45 ++- .../easygiantsfoundry/MetalBarCounter.java | 148 ++++++++ .../easygiantsfoundry/MetalBarValues.java | 238 +++++++++++++ .../enums/MetalBarSource.java | 9 + .../easygiantsfoundry/enums/MetalBarType.java | 12 + 8 files changed, 519 insertions(+), 388 deletions(-) delete mode 100644 src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryMetalInfo.java create mode 100644 src/main/java/com/toofifty/easygiantsfoundry/MetalBarCounter.java create mode 100644 src/main/java/com/toofifty/easygiantsfoundry/MetalBarValues.java create mode 100644 src/main/java/com/toofifty/easygiantsfoundry/enums/MetalBarSource.java create mode 100644 src/main/java/com/toofifty/easygiantsfoundry/enums/MetalBarType.java diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java index a2f5111..4b317ff 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java @@ -2,7 +2,6 @@ package com.toofifty.easygiantsfoundry; import java.awt.Color; -import com.toofifty.easygiantsfoundry.enums.Location; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; @@ -511,61 +510,82 @@ public interface EasyGiantsFoundryConfig extends Config return Color.CYAN; } - @ConfigSection( - name = "Total Metals Info", - description = "Shows an info box with total number of metals usable for the foundry", - position = 5 - ) - String totalMetalsInfo = "metalInfoSettings"; @ConfigItem( - position = 1, - keyName = "location", - name = "Where To Show:", - description = "Where to show the info box", - section = totalMetalsInfo + position = -100, + keyName = "alwaysShowInfoPanel", + name = "Always show", + description = "Always show the info panel, even outside of Giants' Foundry.", + section = infoPanelList ) - default Location location() { return Location.NOWHERE; } + default boolean alwaysDrawInfoPanel() + { + return false; + } @ConfigItem( - position = 2, - keyName = "includeEquipment", - name = "Include Equipment", - description = "Include equipment that are meltable in the foundry in the count", - section = totalMetalsInfo + position = 100, + keyName = "drawMetals", + name = "Metals", + description = "Show total metals count in the info panel.", + section = infoPanelList ) - default boolean includeEquipment() { return true; } + default boolean drawMetals() + { + return false; + } @ConfigItem( - position = 3, - keyName = "includeMetalBars", - name = "Include Metal Bars", - description = "Include actual metal bars in the count", - section = totalMetalsInfo + position = 101, + keyName = "drawAllMetals", + name = "Metals: show all", + description = "Show rows for metals even if you don't have any of that type.", + section = infoPanelList ) - default boolean includeMetalBars() { return true; } + default boolean drawAllMetals() + { + return false; + } @ConfigItem( - position = 4, - keyName = "includeOre", - name = "Include Ore", - description = "Include unmelted ores in the count (iron ore is added to both iron and steel)", - section = totalMetalsInfo + position = 110, + keyName = "countOre", + name = "Metals: count ore", + description = "Include raw ores in the metals count.", + section = infoPanelList ) - default boolean includeOre() { return false; } + default boolean countOre() + { + return true; + } @ConfigItem( - position = 4, - keyName = "showZeroValues", - name = "Show All Metals", - description = "Show rows for metals even if you don't have any of that type", - section = totalMetalsInfo + position = 111, + keyName = "countBars", + name = "Metals: count bars", + description = "Include smelted bars in the metals count.", + section = infoPanelList ) - default boolean showZeroValues() { return false; } + default boolean countBars() + { + return true; + } + + @ConfigItem( + position = 112, + keyName = "countEquipment", + name = "Metals: count equipment", + description = "Include equipment in the metals count.", + section = infoPanelList + ) + default boolean countEquipment() + { + return true; + } @ConfigSection( name = "Advanced", description = "Advanced Settings", - position = 6 + position = 5 ) String advancedSettings = "generalSettings"; diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryMetalInfo.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryMetalInfo.java deleted file mode 100644 index 7f635dd..0000000 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryMetalInfo.java +++ /dev/null @@ -1,331 +0,0 @@ -package com.toofifty.easygiantsfoundry; - -import com.toofifty.easygiantsfoundry.enums.Location; -import net.runelite.api.Client; -import net.runelite.api.Item; -import net.runelite.api.ItemContainer; -import net.runelite.api.coords.WorldPoint; -import net.runelite.api.gameval.ItemID; -import net.runelite.client.ui.overlay.OverlayPanel; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.LineComponent; - -import javax.inject.Inject; -import java.awt.*; -import java.util.HashMap; - -class EasyGiantsFoundryMetalInfo extends OverlayPanel -{ - private final Rectangle giantsFoundryArea = new Rectangle(3354, 11478, 24, 25); - - private final Client client; - private final EasyGiantsFoundryConfig config; - - private final HashMap bronzeBarValues = new HashMap<>(); - private final HashMap ironBarValues = new HashMap<>(); - private final HashMap steelBarValues = new HashMap<>(); - private final HashMap mithrilBarValues = new HashMap<>(); - private final HashMap adamBarValues = new HashMap<>(); - private final HashMap runeBarValues = new HashMap<>(); - protected int bronzeBars; - protected int copperOre; - protected int tinOre; - protected int ironBars; - protected int steelBars; - protected int mithrilBars; - protected int adamantiteBars; - protected int runiteBars; - - protected ItemContainer bank; - protected ItemContainer inventory; - - @Inject - private EasyGiantsFoundryMetalInfo(final Client client, final EasyGiantsFoundryPlugin plugin, final EasyGiantsFoundryConfig config) - { - super(plugin); - setPosition(OverlayPosition.BOTTOM_RIGHT); - this.client = client; - this.config = config; - - InitializeEquipmentValues(); - } - - @Override - public Dimension render(Graphics2D graphics) - { - if ((config.location() == Location.GIANTS_FOUNDRY && !TileIsInFoundry(client.getLocalPlayer().getWorldLocation())) - || config.location() == Location.NOWHERE) - return null; - - if (bank == null) - panelComponent.getChildren().add(LineComponent.builder() - .left("Open bank") - .leftColor(Color.RED) - .build()); - - if (bronzeBars > 0 || config.showZeroValues()) - AddMetalBarText("Bronze bars:", bronzeBars); - if (ironBars > 0 || config.showZeroValues()) - AddMetalBarText("Iron bars:", ironBars); - if (steelBars > 0 || config.showZeroValues()) - AddMetalBarText("Steel bars:", steelBars); - if (mithrilBars > 0 || config.showZeroValues()) - AddMetalBarText("Mithril bars:", mithrilBars); - if (adamantiteBars > 0 || config.showZeroValues()) - AddMetalBarText("Adamantite bars:", adamantiteBars); - if (runiteBars > 0 || config.showZeroValues()) - AddMetalBarText("Runite bars:", runiteBars); - - return super.render(graphics); - } - - private void AddMetalBarText(String text, int number) { - panelComponent.getChildren().add(LineComponent.builder() - .left(text) - .right(Integer.toString(number)) - .build()); - } - - public void CountBars() - { - bronzeBars = 0; - ironBars = 0; - steelBars = 0; - mithrilBars = 0; - adamantiteBars = 0; - runiteBars = 0; - copperOre = 0; - tinOre = 0; - - if (inventory != null) { - AddMetalValues(inventory); - } - if (bank != null) { - AddMetalValues(bank); - } - - if (config.includeOre()) - bronzeBars += Math.min(copperOre, tinOre); - } - - private void AddMetalValues(ItemContainer container) { - for (Item item : container.getItems()) { - if (item.getId() >= 0 && item.getQuantity() > 0) { - if (config.includeEquipment()) { - if (bronzeBarValues.containsKey(item.getId())) - bronzeBars += bronzeBarValues.get(item.getId()) * item.getQuantity(); - if (ironBarValues.containsKey(item.getId())) - ironBars += ironBarValues.get(item.getId()) * item.getQuantity(); - if (steelBarValues.containsKey(item.getId())) - steelBars += steelBarValues.get(item.getId()) * item.getQuantity(); - if (mithrilBarValues.containsKey(item.getId())) - mithrilBars += mithrilBarValues.get(item.getId()) * item.getQuantity(); - if (adamBarValues.containsKey(item.getId())) - adamantiteBars += adamBarValues.get(item.getId()) * item.getQuantity(); - if (runeBarValues.containsKey(item.getId())) - runiteBars += runeBarValues.get(item.getId()) * item.getQuantity(); - } - - if (config.includeMetalBars()) { - if (item.getId() == ItemID.BRONZE_BAR || item.getId() == ItemID.Cert.BRONZE_BAR) - bronzeBars += item.getQuantity(); - if (item.getId() == ItemID.IRON_BAR || item.getId() == ItemID.Cert.IRON_BAR) - ironBars += item.getQuantity(); - if (item.getId() == ItemID.STEEL_BAR || item.getId() == ItemID.Cert.STEEL_BAR) - steelBars += item.getQuantity(); - if (item.getId() == ItemID.MITHRIL_BAR || item.getId() == ItemID.Cert.MITHRIL_BAR) - mithrilBars += item.getQuantity(); - if (item.getId() == ItemID.ADAMANTITE_BAR || item.getId() == ItemID.Cert.ADAMANTITE_BAR) - adamantiteBars += item.getQuantity(); - if (item.getId() == ItemID.RUNITE_BAR || item.getId() == ItemID.Cert.RUNITE_BAR) - runiteBars += item.getQuantity(); - } - - if (config.includeOre()) { - if (item.getId() == ItemID.COPPER_ORE || item.getId() == ItemID.Cert.COPPER_ORE) - copperOre += item.getQuantity(); - if (item.getId() == ItemID.TIN_ORE || item.getId() == ItemID.Cert.TIN_ORE) - tinOre += item.getQuantity(); - if (item.getId() == ItemID.IRON_ORE || item.getId() == ItemID.Cert.IRON_ORE) { - ironBars += item.getQuantity(); - steelBars += item.getQuantity(); - } - if (item.getId() == ItemID.MITHRIL_ORE || item.getId() == ItemID.Cert.MITHRIL_ORE) - mithrilBars += item.getQuantity(); - if (item.getId() == ItemID.ADAMANTITE_ORE || item.getId() == ItemID.Cert.ADAMANTITE_ORE) - adamantiteBars += item.getQuantity(); - if (item.getId() == ItemID.RUNITE_ORE || item.getId() == ItemID.Cert.RUNITE_ORE) - runiteBars += item.getQuantity(); - } - } - } - } - - private boolean TileIsInFoundry(WorldPoint tile) { - return giantsFoundryArea.contains(new Point(tile.getX(), tile.getY())); - } - - private void InitializeEquipmentValues() { - bronzeBarValues.put(ItemID.BRONZE_SCIMITAR, 1); - bronzeBarValues.put(ItemID.BRONZE_LONGSWORD, 1); - bronzeBarValues.put(ItemID.BRONZE_FULL_HELM, 1); - bronzeBarValues.put(ItemID.BRONZE_SQ_SHIELD, 1); - bronzeBarValues.put(ItemID.BRONZE_CLAWS, 1); - bronzeBarValues.put(ItemID.BRONZE_WARHAMMER, 2); - bronzeBarValues.put(ItemID.BRONZE_BATTLEAXE, 2); - bronzeBarValues.put(ItemID.BRONZE_CHAINBODY, 2); - bronzeBarValues.put(ItemID.BRONZE_KITESHIELD, 2); - bronzeBarValues.put(ItemID.BRONZE_2H_SWORD, 2); - bronzeBarValues.put(ItemID.BRONZE_PLATELEGS, 2); - bronzeBarValues.put(ItemID.BRONZE_PLATESKIRT, 2); - bronzeBarValues.put(ItemID.BRONZE_PLATEBODY, 4); - bronzeBarValues.put(ItemID.Cert.BRONZE_SCIMITAR, 1); - bronzeBarValues.put(ItemID.Cert.BRONZE_LONGSWORD, 1); - bronzeBarValues.put(ItemID.Cert.BRONZE_FULL_HELM, 1); - bronzeBarValues.put(ItemID.Cert.BRONZE_SQ_SHIELD, 1); - bronzeBarValues.put(ItemID.Cert.BRONZE_CLAWS, 1); - bronzeBarValues.put(ItemID.Cert.BRONZE_WARHAMMER, 2); - bronzeBarValues.put(ItemID.Cert.BRONZE_BATTLEAXE, 2); - bronzeBarValues.put(ItemID.Cert.BRONZE_CHAINBODY, 2); - bronzeBarValues.put(ItemID.Cert.BRONZE_KITESHIELD, 2); - bronzeBarValues.put(ItemID.Cert.BRONZE_2H_SWORD, 2); - bronzeBarValues.put(ItemID.Cert.BRONZE_PLATELEGS, 2); - bronzeBarValues.put(ItemID.Cert.BRONZE_PLATESKIRT, 2); - bronzeBarValues.put(ItemID.Cert.BRONZE_PLATEBODY, 4); - - ironBarValues.put(ItemID.IRON_SCIMITAR, 1); - ironBarValues.put(ItemID.IRON_LONGSWORD, 1); - ironBarValues.put(ItemID.IRON_FULL_HELM, 1); - ironBarValues.put(ItemID.IRON_SQ_SHIELD, 1); - ironBarValues.put(ItemID.IRON_CLAWS, 1); - ironBarValues.put(ItemID.IRON_WARHAMMER, 2); - ironBarValues.put(ItemID.IRON_BATTLEAXE, 2); - ironBarValues.put(ItemID.IRON_CHAINBODY, 2); - ironBarValues.put(ItemID.IRON_KITESHIELD, 2); - ironBarValues.put(ItemID.IRON_2H_SWORD, 2); - ironBarValues.put(ItemID.IRON_PLATELEGS, 2); - ironBarValues.put(ItemID.IRON_PLATESKIRT, 2); - ironBarValues.put(ItemID.IRON_PLATEBODY, 4); - ironBarValues.put(ItemID.Cert.IRON_SCIMITAR, 1); - ironBarValues.put(ItemID.Cert.IRON_LONGSWORD, 1); - ironBarValues.put(ItemID.Cert.IRON_FULL_HELM, 1); - ironBarValues.put(ItemID.Cert.IRON_SQ_SHIELD, 1); - ironBarValues.put(ItemID.Cert.IRON_CLAWS, 1); - ironBarValues.put(ItemID.Cert.IRON_WARHAMMER, 2); - ironBarValues.put(ItemID.Cert.IRON_BATTLEAXE, 2); - ironBarValues.put(ItemID.Cert.IRON_CHAINBODY, 2); - ironBarValues.put(ItemID.Cert.IRON_KITESHIELD, 2); - ironBarValues.put(ItemID.Cert.IRON_2H_SWORD, 2); - ironBarValues.put(ItemID.Cert.IRON_PLATELEGS, 2); - ironBarValues.put(ItemID.Cert.IRON_PLATESKIRT, 2); - ironBarValues.put(ItemID.Cert.IRON_PLATEBODY, 4); - - steelBarValues.put(ItemID.STEEL_SCIMITAR, 1); - steelBarValues.put(ItemID.STEEL_LONGSWORD, 1); - steelBarValues.put(ItemID.STEEL_FULL_HELM, 1); - steelBarValues.put(ItemID.STEEL_SQ_SHIELD, 1); - steelBarValues.put(ItemID.STEEL_CLAWS, 1); - steelBarValues.put(ItemID.STEEL_WARHAMMER, 2); - steelBarValues.put(ItemID.STEEL_BATTLEAXE, 2); - steelBarValues.put(ItemID.STEEL_CHAINBODY, 2); - steelBarValues.put(ItemID.STEEL_KITESHIELD, 2); - steelBarValues.put(ItemID.STEEL_2H_SWORD, 2); - steelBarValues.put(ItemID.STEEL_PLATELEGS, 2); - steelBarValues.put(ItemID.STEEL_PLATESKIRT, 2); - steelBarValues.put(ItemID.STEEL_PLATEBODY, 4); - steelBarValues.put(ItemID.Cert.STEEL_SCIMITAR, 1); - steelBarValues.put(ItemID.Cert.STEEL_LONGSWORD, 1); - steelBarValues.put(ItemID.Cert.STEEL_FULL_HELM, 1); - steelBarValues.put(ItemID.Cert.STEEL_SQ_SHIELD, 1); - steelBarValues.put(ItemID.Cert.STEEL_CLAWS, 1); - steelBarValues.put(ItemID.Cert.STEEL_WARHAMMER, 2); - steelBarValues.put(ItemID.Cert.STEEL_BATTLEAXE, 2); - steelBarValues.put(ItemID.Cert.STEEL_CHAINBODY, 2); - steelBarValues.put(ItemID.Cert.STEEL_KITESHIELD, 2); - steelBarValues.put(ItemID.Cert.STEEL_2H_SWORD, 2); - steelBarValues.put(ItemID.Cert.STEEL_PLATELEGS, 2); - steelBarValues.put(ItemID.Cert.STEEL_PLATESKIRT, 2); - steelBarValues.put(ItemID.Cert.STEEL_PLATEBODY, 4); - - mithrilBarValues.put(ItemID.MITHRIL_SCIMITAR, 1); - mithrilBarValues.put(ItemID.MITHRIL_LONGSWORD, 1); - mithrilBarValues.put(ItemID.MITHRIL_FULL_HELM, 1); - mithrilBarValues.put(ItemID.MITHRIL_SQ_SHIELD, 1); - mithrilBarValues.put(ItemID.MITHRIL_CLAWS, 1); - mithrilBarValues.put(ItemID.MITHRIL_WARHAMMER, 2); - mithrilBarValues.put(ItemID.MITHRIL_BATTLEAXE, 2); - mithrilBarValues.put(ItemID.MITHRIL_CHAINBODY, 2); - mithrilBarValues.put(ItemID.MITHRIL_KITESHIELD, 2); - mithrilBarValues.put(ItemID.MITHRIL_2H_SWORD, 2); - mithrilBarValues.put(ItemID.MITHRIL_PLATELEGS, 2); - mithrilBarValues.put(ItemID.MITHRIL_PLATESKIRT, 2); - mithrilBarValues.put(ItemID.MITHRIL_PLATEBODY, 4); - mithrilBarValues.put(ItemID.Cert.MITHRIL_SCIMITAR, 1); - mithrilBarValues.put(ItemID.Cert.MITHRIL_LONGSWORD, 1); - mithrilBarValues.put(ItemID.Cert.MITHRIL_FULL_HELM, 1); - mithrilBarValues.put(ItemID.Cert.MITHRIL_SQ_SHIELD, 1); - mithrilBarValues.put(ItemID.Cert.MITHRIL_CLAWS, 1); - mithrilBarValues.put(ItemID.Cert.MITHRIL_WARHAMMER, 2); - mithrilBarValues.put(ItemID.Cert.MITHRIL_BATTLEAXE, 2); - mithrilBarValues.put(ItemID.Cert.MITHRIL_CHAINBODY, 2); - mithrilBarValues.put(ItemID.Cert.MITHRIL_KITESHIELD, 2); - mithrilBarValues.put(ItemID.Cert.MITHRIL_2H_SWORD, 2); - mithrilBarValues.put(ItemID.Cert.MITHRIL_PLATELEGS, 2); - mithrilBarValues.put(ItemID.Cert.MITHRIL_PLATESKIRT, 2); - mithrilBarValues.put(ItemID.Cert.MITHRIL_PLATEBODY, 4); - - adamBarValues.put(ItemID.ADAMANT_SCIMITAR, 1); - adamBarValues.put(ItemID.ADAMANT_LONGSWORD, 1); - adamBarValues.put(ItemID.ADAMANT_FULL_HELM, 1); - adamBarValues.put(ItemID.ADAMANT_SQ_SHIELD, 1); - adamBarValues.put(ItemID.ADAMANT_CLAWS, 1); - adamBarValues.put(ItemID.ADAMNT_WARHAMMER, 2); - adamBarValues.put(ItemID.ADAMANT_BATTLEAXE, 2); - adamBarValues.put(ItemID.ADAMANT_CHAINBODY, 2); - adamBarValues.put(ItemID.ADAMANT_KITESHIELD, 2); - adamBarValues.put(ItemID.ADAMANT_2H_SWORD, 2); - adamBarValues.put(ItemID.ADAMANT_PLATELEGS, 2); - adamBarValues.put(ItemID.ADAMANT_PLATESKIRT, 2); - adamBarValues.put(ItemID.ADAMANT_PLATEBODY, 4); - adamBarValues.put(ItemID.Cert.ADAMANT_SCIMITAR, 1); - adamBarValues.put(ItemID.Cert.ADAMANT_LONGSWORD, 1); - adamBarValues.put(ItemID.Cert.ADAMANT_FULL_HELM, 1); - adamBarValues.put(ItemID.Cert.ADAMANT_SQ_SHIELD, 1); - adamBarValues.put(ItemID.Cert.ADAMANT_CLAWS, 1); - adamBarValues.put(ItemID.Cert.ADAMNT_WARHAMMER, 2); - adamBarValues.put(ItemID.Cert.ADAMANT_BATTLEAXE, 2); - adamBarValues.put(ItemID.Cert.ADAMANT_CHAINBODY, 2); - adamBarValues.put(ItemID.Cert.ADAMANT_KITESHIELD, 2); - adamBarValues.put(ItemID.Cert.ADAMANT_2H_SWORD, 2); - adamBarValues.put(ItemID.Cert.ADAMANT_PLATELEGS, 2); - adamBarValues.put(ItemID.Cert.ADAMANT_PLATESKIRT, 2); - adamBarValues.put(ItemID.Cert.ADAMANT_PLATEBODY, 4); - - runeBarValues.put(ItemID.RUNE_SCIMITAR, 1); - runeBarValues.put(ItemID.RUNE_LONGSWORD, 1); - runeBarValues.put(ItemID.RUNE_FULL_HELM, 1); - runeBarValues.put(ItemID.RUNE_SQ_SHIELD, 1); - runeBarValues.put(ItemID.RUNE_CLAWS, 1); - runeBarValues.put(ItemID.RUNE_WARHAMMER, 2); - runeBarValues.put(ItemID.RUNE_BATTLEAXE, 2); - runeBarValues.put(ItemID.RUNE_CHAINBODY, 2); - runeBarValues.put(ItemID.RUNE_KITESHIELD, 2); - runeBarValues.put(ItemID.RUNE_2H_SWORD, 2); - runeBarValues.put(ItemID.RUNE_PLATELEGS, 2); - runeBarValues.put(ItemID.RUNE_PLATESKIRT, 2); - runeBarValues.put(ItemID.RUNE_PLATEBODY, 4); - runeBarValues.put(ItemID.Cert.RUNE_SCIMITAR, 1); - runeBarValues.put(ItemID.Cert.RUNE_LONGSWORD, 1); - runeBarValues.put(ItemID.Cert.RUNE_FULL_HELM, 1); - runeBarValues.put(ItemID.Cert.RUNE_SQ_SHIELD, 1); - runeBarValues.put(ItemID.Cert.RUNE_CLAWS, 1); - runeBarValues.put(ItemID.Cert.RUNE_WARHAMMER, 2); - runeBarValues.put(ItemID.Cert.RUNE_BATTLEAXE, 2); - runeBarValues.put(ItemID.Cert.RUNE_CHAINBODY, 2); - runeBarValues.put(ItemID.Cert.RUNE_KITESHIELD, 2); - runeBarValues.put(ItemID.Cert.RUNE_2H_SWORD, 2); - runeBarValues.put(ItemID.Cert.RUNE_PLATELEGS, 2); - runeBarValues.put(ItemID.Cert.RUNE_PLATESKIRT, 2); - runeBarValues.put(ItemID.Cert.RUNE_PLATEBODY, 4); - } -} diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java index 11b0a77..4b8d60e 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java @@ -14,7 +14,7 @@ import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.GameObject; import net.runelite.api.GameState; -import net.runelite.api.InventoryID; +import net.runelite.api.gameval.InventoryID; import net.runelite.api.Item; import net.runelite.api.ItemContainer; import net.runelite.api.MenuAction; @@ -75,6 +75,9 @@ public class EasyGiantsFoundryPlugin extends Plugin @Inject private EasyGiantsFoundryHelper helper; + @Inject + private MetalBarCounter metalBarCounter; + @Inject private OverlayManager overlayManager; @@ -84,9 +87,6 @@ public class EasyGiantsFoundryPlugin extends Plugin @Inject private FoundryOverlay3D overlay3d; - @Inject - private EasyGiantsFoundryMetalInfo metalInfo; - @Inject private MouldHelper mouldHelper; @@ -110,7 +110,6 @@ public class EasyGiantsFoundryPlugin extends Plugin { overlayManager.add(overlay2d); overlayManager.add(overlay3d); - overlayManager.add(metalInfo); if (client.getGameState() == GameState.LOGGED_IN) { reputation = client.getVarpValue(REPUTATION_VARBIT); @@ -122,7 +121,7 @@ public class EasyGiantsFoundryPlugin extends Plugin { overlayManager.remove(overlay2d); overlayManager.remove(overlay3d); - overlayManager.remove(metalInfo); + metalBarCounter.clear(); } @Subscribe @@ -258,7 +257,7 @@ public class EasyGiantsFoundryPlugin extends Plugin @Subscribe public void onItemContainerChanged(ItemContainerChanged event) { - if (event.getContainerId() == InventoryID.EQUIPMENT.getId()) + if (event.getContainerId() == InventoryID.WORN) { if (event.getItemContainer().count(PREFORM) == 0) { @@ -270,15 +269,10 @@ public class EasyGiantsFoundryPlugin extends Plugin updateSmithsOutfitPieces(); } } - else { - if (event.getContainerId() == InventoryID.BANK.getId()) { - metalInfo.bank = event.getItemContainer(); - } - else if (event.getContainerId() == InventoryID.INVENTORY.getId()) { - metalInfo.inventory = event.getItemContainer(); - } - metalInfo.CountBars(); - } + else if (event.getContainerId() == InventoryID.INV || event.getContainerId() == InventoryID.BANK) + { + metalBarCounter.put(event.getItemContainer()); + } } public void onMenuEntryAdded(MenuEntryAdded event) @@ -488,7 +482,7 @@ public class EasyGiantsFoundryPlugin extends Plugin { int pieces = 0; - ItemContainer equipment = client.getItemContainer(InventoryID.EQUIPMENT); + ItemContainer equipment = client.getItemContainer(InventoryID.WORN); if (equipment != null) { for (Item item : equipment.getItems()) diff --git a/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay2D.java b/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay2D.java index 7280025..1954b3a 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay2D.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay2D.java @@ -1,7 +1,7 @@ package com.toofifty.easygiantsfoundry; -import static com.toofifty.easygiantsfoundry.EasyGiantsFoundryHelper.getHeatColor; import com.toofifty.easygiantsfoundry.enums.Heat; +import com.toofifty.easygiantsfoundry.enums.MetalBarType; import com.toofifty.easygiantsfoundry.enums.Stage; import java.awt.Color; @@ -24,6 +24,7 @@ public class FoundryOverlay2D extends OverlayPanel private final Client client; private final EasyGiantsFoundryPlugin plugin; private final EasyGiantsFoundryState state; + private final MetalBarCounter metalBarCounter; private final EasyGiantsFoundryConfig config; @Inject @@ -31,11 +32,13 @@ public class FoundryOverlay2D extends OverlayPanel Client client, EasyGiantsFoundryPlugin plugin, EasyGiantsFoundryState state, + MetalBarCounter metalBarCounter, EasyGiantsFoundryConfig config) { this.client = client; this.plugin = plugin; this.state = state; + this.metalBarCounter = metalBarCounter; this.config = config; this.setPosition(OverlayPosition.BOTTOM_LEFT); } @@ -68,7 +71,7 @@ public class FoundryOverlay2D extends OverlayPanel @Override public Dimension render(Graphics2D graphics) { - if (client.getLocalPlayer().getWorldLocation().getRegionID() != REGION_ID) + if (!config.alwaysDrawInfoPanel() && client.getLocalPlayer().getWorldLocation().getRegionID() != REGION_ID) { return null; } @@ -79,6 +82,11 @@ public class FoundryOverlay2D extends OverlayPanel panelComponent.getChildren().add(TitleComponent.builder().text("Easy Giants' Foundry").build()); } + if (config.drawMetals()) + { + drawMetals(graphics); + } + if (swordPickedUp) { Heat heat = state.getCurrentHeat(); @@ -130,4 +138,37 @@ public class FoundryOverlay2D extends OverlayPanel return super.render(graphics); } + + private void drawMetals(Graphics2D graphics2D) + { + if (!metalBarCounter.isSeenBank()) + { + panelComponent.getChildren().add( + LineComponent.builder() + .left("Metals: open bank") + .leftColor(Color.RED) + .build() + ); + } + + drawMetalCount(graphics2D, "Bronze bars:", metalBarCounter.get(MetalBarType.BRONZE)); + drawMetalCount(graphics2D, "Iron bars:", metalBarCounter.get(MetalBarType.IRON)); + drawMetalCount(graphics2D, "Steel bars:", metalBarCounter.get(MetalBarType.STEEL)); + drawMetalCount(graphics2D, "Mithril bars:", metalBarCounter.get(MetalBarType.MITHRIL)); + drawMetalCount(graphics2D, "Adamant bars:", metalBarCounter.get(MetalBarType.ADAMANT)); + drawMetalCount(graphics2D, "Runite bars:", metalBarCounter.get(MetalBarType.RUNITE)); + } + + private void drawMetalCount(Graphics2D graphics2D, String displayName, int count) + { + if (count > 0 || config.drawAllMetals()) + { + panelComponent.getChildren().add( + LineComponent.builder() + .left(displayName) + .right(Integer.toString(count)) + .build() + ); + } + } } diff --git a/src/main/java/com/toofifty/easygiantsfoundry/MetalBarCounter.java b/src/main/java/com/toofifty/easygiantsfoundry/MetalBarCounter.java new file mode 100644 index 0000000..5b65ade --- /dev/null +++ b/src/main/java/com/toofifty/easygiantsfoundry/MetalBarCounter.java @@ -0,0 +1,148 @@ +package com.toofifty.easygiantsfoundry; + +import com.toofifty.easygiantsfoundry.enums.MetalBarSource; +import com.toofifty.easygiantsfoundry.enums.MetalBarType; +import lombok.Getter; +import lombok.Value; +import net.runelite.api.Item; +import net.runelite.api.ItemContainer; +import net.runelite.api.gameval.InventoryID; +import net.runelite.api.gameval.ItemID; + +import javax.inject.Inject; +import javax.inject.Singleton; +import java.util.HashMap; +import java.util.Map; + +@Singleton +public class MetalBarCounter +{ + private final Map> index = new HashMap<>(); // container id -> bar counts + + @Inject + private EasyGiantsFoundryConfig config; + + @Getter + private boolean seenBank = false; + + public int get(MetalBarType type) + { + int count = 0; + for (Map counts : index.values()) + { + count += counts.get(type).sum(config); + } + + return count; + } + + public void clear() + { + index.clear(); + seenBank = false; + } + + public void put(ItemContainer container) + { + int tinOre = 0; + int copperOre = 0; + int ironOre = 0; + + if (container.getId() == InventoryID.BANK) + { + seenBank = true; + } + + Map counts = newCounts(); + for (Item item : container.getItems()) + { + MetalBarValues.Record record = MetalBarValues.get(item.getId()); + if (record == null) + { + continue; + } + + // ore special cases: + // * add bronze bars equal to min(tin, copper) + // * there is an edge case here where it won't sum quite right multiple item containers but I don't really + // care to code for that right now + // * iron ore counts for both iron and steel + switch (item.getId()) + { + case ItemID.TIN_ORE: + case ItemID.Cert.TIN_ORE: + tinOre += item.getQuantity(); + break; + case ItemID.COPPER_ORE: + case ItemID.Cert.COPPER_ORE: + copperOre += item.getQuantity(); + break; + case ItemID.IRON_ORE: + case ItemID.Cert.IRON_ORE: + ironOre += item.getQuantity(); + break; + default: + counts.compute(record.getType(), (k, v) -> + v.add(record.getSource(), record.getValue() * item.getQuantity())); + } + } + + int finalTinOre = tinOre; + int finalCopperOre = copperOre; + int finalIronOre = ironOre; + counts.compute(MetalBarType.BRONZE, (k, v) -> + v.add(MetalBarSource.ORE, Math.min(finalTinOre, finalCopperOre))); + counts.compute(MetalBarType.IRON, (k, v) -> + v.add(MetalBarSource.ORE, finalIronOre)); + counts.compute(MetalBarType.STEEL, (k, v) -> + v.add(MetalBarSource.ORE, finalIronOre)); + + index.put(container.getId(), counts); + } + + private static Map newCounts() + { + Map counts = new HashMap<>(); + counts.put(MetalBarType.BRONZE, CountsBySource.empty()); + counts.put(MetalBarType.IRON, CountsBySource.empty()); + counts.put(MetalBarType.STEEL, CountsBySource.empty()); + counts.put(MetalBarType.MITHRIL, CountsBySource.empty()); + counts.put(MetalBarType.ADAMANT, CountsBySource.empty()); + counts.put(MetalBarType.RUNITE, CountsBySource.empty()); + return counts; + } + + @Value + private static class CountsBySource + { + int ores, bars, equipment; + + public static CountsBySource empty() + { + return new CountsBySource(0, 0, 0); + } + + public CountsBySource add(MetalBarSource source, int count) + { + switch (source) + { + case ORE: + return new CountsBySource(ores + count, bars, equipment); + case BAR: + return new CountsBySource(ores, bars + count, equipment); + case EQUIPMENT: + return new CountsBySource(ores, bars, equipment + count); + default: + return this; + } + } + + public int sum(EasyGiantsFoundryConfig config) + { + int sum = config.countOre() ? ores : 0; + sum += config.countBars() ? bars : 0; + sum += config.countEquipment() ? equipment : 0; + return sum; + } + } +} diff --git a/src/main/java/com/toofifty/easygiantsfoundry/MetalBarValues.java b/src/main/java/com/toofifty/easygiantsfoundry/MetalBarValues.java new file mode 100644 index 0000000..efcd5c8 --- /dev/null +++ b/src/main/java/com/toofifty/easygiantsfoundry/MetalBarValues.java @@ -0,0 +1,238 @@ +package com.toofifty.easygiantsfoundry; + +import com.toofifty.easygiantsfoundry.enums.MetalBarSource; +import com.toofifty.easygiantsfoundry.enums.MetalBarType; +import lombok.Value; +import net.runelite.api.gameval.ItemID; + +import java.util.HashMap; + +public class MetalBarValues +{ + private static final HashMap values = new HashMap<>(); + + static + { + // tin, copper, and iron are included here so the counter doesn't ignore them, but their actual counts are + // handled as special cases + putOre(ItemID.TIN_ORE, MetalBarType.BRONZE); + putOre(ItemID.COPPER_ORE, MetalBarType.BRONZE); + putOre(ItemID.IRON_BAR, MetalBarType.IRON); + putOre(ItemID.MITHRIL_ORE, MetalBarType.MITHRIL); + putOre(ItemID.ADAMANTITE_ORE, MetalBarType.ADAMANT); + putOre(ItemID.RUNITE_ORE, MetalBarType.RUNITE); + putOre(ItemID.Cert.TIN_ORE, MetalBarType.BRONZE); + putOre(ItemID.Cert.COPPER_ORE, MetalBarType.BRONZE); + putOre(ItemID.Cert.IRON_BAR, MetalBarType.IRON); + putOre(ItemID.Cert.MITHRIL_ORE, MetalBarType.MITHRIL); + putOre(ItemID.Cert.ADAMANTITE_ORE, MetalBarType.ADAMANT); + putOre(ItemID.Cert.RUNITE_ORE, MetalBarType.RUNITE); + + putBar(ItemID.BRONZE_BAR, MetalBarType.BRONZE); + putBar(ItemID.IRON_BAR, MetalBarType.IRON); + putBar(ItemID.STEEL_BAR, MetalBarType.STEEL); + putBar(ItemID.MITHRIL_BAR, MetalBarType.MITHRIL); + putBar(ItemID.ADAMANTITE_BAR, MetalBarType.ADAMANT); + putBar(ItemID.RUNITE_BAR, MetalBarType.RUNITE); + putBar(ItemID.Cert.BRONZE_BAR, MetalBarType.BRONZE); + putBar(ItemID.Cert.IRON_BAR, MetalBarType.IRON); + putBar(ItemID.Cert.STEEL_BAR, MetalBarType.STEEL); + putBar(ItemID.Cert.MITHRIL_BAR, MetalBarType.MITHRIL); + putBar(ItemID.Cert.ADAMANTITE_BAR, MetalBarType.ADAMANT); + putBar(ItemID.Cert.RUNITE_BAR, MetalBarType.RUNITE); + + putEquipment(ItemID.BRONZE_SCIMITAR, MetalBarType.BRONZE, 1); + putEquipment(ItemID.BRONZE_LONGSWORD, MetalBarType.BRONZE, 1); + putEquipment(ItemID.BRONZE_FULL_HELM, MetalBarType.BRONZE, 1); + putEquipment(ItemID.BRONZE_SQ_SHIELD, MetalBarType.BRONZE, 1); + putEquipment(ItemID.BRONZE_CLAWS, MetalBarType.BRONZE, 1); + putEquipment(ItemID.BRONZE_WARHAMMER, MetalBarType.BRONZE, 2); + putEquipment(ItemID.BRONZE_BATTLEAXE, MetalBarType.BRONZE, 2); + putEquipment(ItemID.BRONZE_CHAINBODY, MetalBarType.BRONZE, 2); + putEquipment(ItemID.BRONZE_KITESHIELD, MetalBarType.BRONZE, 2); + putEquipment(ItemID.BRONZE_2H_SWORD, MetalBarType.BRONZE, 2); + putEquipment(ItemID.BRONZE_PLATELEGS, MetalBarType.BRONZE, 2); + putEquipment(ItemID.BRONZE_PLATESKIRT, MetalBarType.BRONZE, 2); + putEquipment(ItemID.BRONZE_PLATEBODY, MetalBarType.BRONZE, 4); + putEquipment(ItemID.Cert.BRONZE_SCIMITAR, MetalBarType.BRONZE, 1); + putEquipment(ItemID.Cert.BRONZE_LONGSWORD, MetalBarType.BRONZE, 1); + putEquipment(ItemID.Cert.BRONZE_FULL_HELM, MetalBarType.BRONZE, 1); + putEquipment(ItemID.Cert.BRONZE_SQ_SHIELD, MetalBarType.BRONZE, 1); + putEquipment(ItemID.Cert.BRONZE_CLAWS, MetalBarType.BRONZE, 1); + putEquipment(ItemID.Cert.BRONZE_WARHAMMER, MetalBarType.BRONZE, 2); + putEquipment(ItemID.Cert.BRONZE_BATTLEAXE, MetalBarType.BRONZE, 2); + putEquipment(ItemID.Cert.BRONZE_CHAINBODY, MetalBarType.BRONZE, 2); + putEquipment(ItemID.Cert.BRONZE_KITESHIELD, MetalBarType.BRONZE, 2); + putEquipment(ItemID.Cert.BRONZE_2H_SWORD, MetalBarType.BRONZE, 2); + putEquipment(ItemID.Cert.BRONZE_PLATELEGS, MetalBarType.BRONZE, 2); + putEquipment(ItemID.Cert.BRONZE_PLATESKIRT, MetalBarType.BRONZE, 2); + putEquipment(ItemID.Cert.BRONZE_PLATEBODY, MetalBarType.BRONZE, 4); + + putEquipment(ItemID.IRON_SCIMITAR, MetalBarType.IRON, 1); + putEquipment(ItemID.IRON_LONGSWORD, MetalBarType.IRON, 1); + putEquipment(ItemID.IRON_FULL_HELM, MetalBarType.IRON, 1); + putEquipment(ItemID.IRON_SQ_SHIELD, MetalBarType.IRON, 1); + putEquipment(ItemID.IRON_CLAWS, MetalBarType.IRON, 1); + putEquipment(ItemID.IRON_WARHAMMER, MetalBarType.IRON, 2); + putEquipment(ItemID.IRON_BATTLEAXE, MetalBarType.IRON, 2); + putEquipment(ItemID.IRON_CHAINBODY, MetalBarType.IRON, 2); + putEquipment(ItemID.IRON_KITESHIELD, MetalBarType.IRON, 2); + putEquipment(ItemID.IRON_2H_SWORD, MetalBarType.IRON, 2); + putEquipment(ItemID.IRON_PLATELEGS, MetalBarType.IRON, 2); + putEquipment(ItemID.IRON_PLATESKIRT, MetalBarType.IRON, 2); + putEquipment(ItemID.IRON_PLATEBODY, MetalBarType.IRON, 4); + putEquipment(ItemID.Cert.IRON_SCIMITAR, MetalBarType.IRON, 1); + putEquipment(ItemID.Cert.IRON_LONGSWORD, MetalBarType.IRON, 1); + putEquipment(ItemID.Cert.IRON_FULL_HELM, MetalBarType.IRON, 1); + putEquipment(ItemID.Cert.IRON_SQ_SHIELD, MetalBarType.IRON, 1); + putEquipment(ItemID.Cert.IRON_CLAWS, MetalBarType.IRON, 1); + putEquipment(ItemID.Cert.IRON_WARHAMMER, MetalBarType.IRON, 2); + putEquipment(ItemID.Cert.IRON_BATTLEAXE, MetalBarType.IRON, 2); + putEquipment(ItemID.Cert.IRON_CHAINBODY, MetalBarType.IRON, 2); + putEquipment(ItemID.Cert.IRON_KITESHIELD, MetalBarType.IRON, 2); + putEquipment(ItemID.Cert.IRON_2H_SWORD, MetalBarType.IRON, 2); + putEquipment(ItemID.Cert.IRON_PLATELEGS, MetalBarType.IRON, 2); + putEquipment(ItemID.Cert.IRON_PLATESKIRT, MetalBarType.IRON, 2); + putEquipment(ItemID.Cert.IRON_PLATEBODY, MetalBarType.IRON, 4); + + putEquipment(ItemID.STEEL_SCIMITAR, MetalBarType.STEEL, 1); + putEquipment(ItemID.STEEL_LONGSWORD, MetalBarType.STEEL, 1); + putEquipment(ItemID.STEEL_FULL_HELM, MetalBarType.STEEL, 1); + putEquipment(ItemID.STEEL_SQ_SHIELD, MetalBarType.STEEL, 1); + putEquipment(ItemID.STEEL_CLAWS, MetalBarType.STEEL, 1); + putEquipment(ItemID.STEEL_WARHAMMER, MetalBarType.STEEL, 2); + putEquipment(ItemID.STEEL_BATTLEAXE, MetalBarType.STEEL, 2); + putEquipment(ItemID.STEEL_CHAINBODY, MetalBarType.STEEL, 2); + putEquipment(ItemID.STEEL_KITESHIELD, MetalBarType.STEEL, 2); + putEquipment(ItemID.STEEL_2H_SWORD, MetalBarType.STEEL, 2); + putEquipment(ItemID.STEEL_PLATELEGS, MetalBarType.STEEL, 2); + putEquipment(ItemID.STEEL_PLATESKIRT, MetalBarType.STEEL, 2); + putEquipment(ItemID.STEEL_PLATEBODY, MetalBarType.STEEL, 4); + putEquipment(ItemID.Cert.STEEL_SCIMITAR, MetalBarType.STEEL, 1); + putEquipment(ItemID.Cert.STEEL_LONGSWORD, MetalBarType.STEEL, 1); + putEquipment(ItemID.Cert.STEEL_FULL_HELM, MetalBarType.STEEL, 1); + putEquipment(ItemID.Cert.STEEL_SQ_SHIELD, MetalBarType.STEEL, 1); + putEquipment(ItemID.Cert.STEEL_CLAWS, MetalBarType.STEEL, 1); + putEquipment(ItemID.Cert.STEEL_WARHAMMER, MetalBarType.STEEL, 2); + putEquipment(ItemID.Cert.STEEL_BATTLEAXE, MetalBarType.STEEL, 2); + putEquipment(ItemID.Cert.STEEL_CHAINBODY, MetalBarType.STEEL, 2); + putEquipment(ItemID.Cert.STEEL_KITESHIELD, MetalBarType.STEEL, 2); + putEquipment(ItemID.Cert.STEEL_2H_SWORD, MetalBarType.STEEL, 2); + putEquipment(ItemID.Cert.STEEL_PLATELEGS, MetalBarType.STEEL, 2); + putEquipment(ItemID.Cert.STEEL_PLATESKIRT, MetalBarType.STEEL, 2); + putEquipment(ItemID.Cert.STEEL_PLATEBODY, MetalBarType.STEEL, 4); + + putEquipment(ItemID.MITHRIL_SCIMITAR, MetalBarType.MITHRIL, 1); + putEquipment(ItemID.MITHRIL_LONGSWORD, MetalBarType.MITHRIL, 1); + putEquipment(ItemID.MITHRIL_FULL_HELM, MetalBarType.MITHRIL, 1); + putEquipment(ItemID.MITHRIL_SQ_SHIELD, MetalBarType.MITHRIL, 1); + putEquipment(ItemID.MITHRIL_CLAWS, MetalBarType.MITHRIL, 1); + putEquipment(ItemID.MITHRIL_WARHAMMER, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.MITHRIL_BATTLEAXE, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.MITHRIL_CHAINBODY, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.MITHRIL_KITESHIELD, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.MITHRIL_2H_SWORD, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.MITHRIL_PLATELEGS, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.MITHRIL_PLATESKIRT, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.MITHRIL_PLATEBODY, MetalBarType.MITHRIL, 4); + putEquipment(ItemID.Cert.MITHRIL_SCIMITAR, MetalBarType.MITHRIL, 1); + putEquipment(ItemID.Cert.MITHRIL_LONGSWORD, MetalBarType.MITHRIL, 1); + putEquipment(ItemID.Cert.MITHRIL_FULL_HELM, MetalBarType.MITHRIL, 1); + putEquipment(ItemID.Cert.MITHRIL_SQ_SHIELD, MetalBarType.MITHRIL, 1); + putEquipment(ItemID.Cert.MITHRIL_CLAWS, MetalBarType.MITHRIL, 1); + putEquipment(ItemID.Cert.MITHRIL_WARHAMMER, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.Cert.MITHRIL_BATTLEAXE, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.Cert.MITHRIL_CHAINBODY, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.Cert.MITHRIL_KITESHIELD, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.Cert.MITHRIL_2H_SWORD, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.Cert.MITHRIL_PLATELEGS, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.Cert.MITHRIL_PLATESKIRT, MetalBarType.MITHRIL, 2); + putEquipment(ItemID.Cert.MITHRIL_PLATEBODY, MetalBarType.MITHRIL, 4); + + putEquipment(ItemID.ADAMANT_SCIMITAR, MetalBarType.ADAMANT, 1); + putEquipment(ItemID.ADAMANT_LONGSWORD, MetalBarType.ADAMANT, 1); + putEquipment(ItemID.ADAMANT_FULL_HELM, MetalBarType.ADAMANT, 1); + putEquipment(ItemID.ADAMANT_SQ_SHIELD, MetalBarType.ADAMANT, 1); + putEquipment(ItemID.ADAMANT_CLAWS, MetalBarType.ADAMANT, 1); + putEquipment(ItemID.ADAMNT_WARHAMMER, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.ADAMANT_BATTLEAXE, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.ADAMANT_CHAINBODY, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.ADAMANT_KITESHIELD, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.ADAMANT_2H_SWORD, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.ADAMANT_PLATELEGS, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.ADAMANT_PLATESKIRT, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.ADAMANT_PLATEBODY, MetalBarType.ADAMANT, 4); + putEquipment(ItemID.Cert.ADAMANT_SCIMITAR, MetalBarType.ADAMANT, 1); + putEquipment(ItemID.Cert.ADAMANT_LONGSWORD, MetalBarType.ADAMANT, 1); + putEquipment(ItemID.Cert.ADAMANT_FULL_HELM, MetalBarType.ADAMANT, 1); + putEquipment(ItemID.Cert.ADAMANT_SQ_SHIELD, MetalBarType.ADAMANT, 1); + putEquipment(ItemID.Cert.ADAMANT_CLAWS, MetalBarType.ADAMANT, 1); + putEquipment(ItemID.Cert.ADAMNT_WARHAMMER, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.Cert.ADAMANT_BATTLEAXE, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.Cert.ADAMANT_CHAINBODY, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.Cert.ADAMANT_KITESHIELD, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.Cert.ADAMANT_2H_SWORD, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.Cert.ADAMANT_PLATELEGS, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.Cert.ADAMANT_PLATESKIRT, MetalBarType.ADAMANT, 2); + putEquipment(ItemID.Cert.ADAMANT_PLATEBODY, MetalBarType.ADAMANT, 4); + + putEquipment(ItemID.RUNE_SCIMITAR, MetalBarType.RUNITE, 1); + putEquipment(ItemID.RUNE_LONGSWORD, MetalBarType.RUNITE, 1); + putEquipment(ItemID.RUNE_FULL_HELM, MetalBarType.RUNITE, 1); + putEquipment(ItemID.RUNE_SQ_SHIELD, MetalBarType.RUNITE, 1); + putEquipment(ItemID.RUNE_CLAWS, MetalBarType.RUNITE, 1); + putEquipment(ItemID.RUNE_WARHAMMER, MetalBarType.RUNITE, 2); + putEquipment(ItemID.RUNE_BATTLEAXE, MetalBarType.RUNITE, 2); + putEquipment(ItemID.RUNE_CHAINBODY, MetalBarType.RUNITE, 2); + putEquipment(ItemID.RUNE_KITESHIELD, MetalBarType.RUNITE, 2); + putEquipment(ItemID.RUNE_2H_SWORD, MetalBarType.RUNITE, 2); + putEquipment(ItemID.RUNE_PLATELEGS, MetalBarType.RUNITE, 2); + putEquipment(ItemID.RUNE_PLATESKIRT, MetalBarType.RUNITE, 2); + putEquipment(ItemID.RUNE_PLATEBODY, MetalBarType.RUNITE, 4); + putEquipment(ItemID.Cert.RUNE_SCIMITAR, MetalBarType.RUNITE, 1); + putEquipment(ItemID.Cert.RUNE_LONGSWORD, MetalBarType.RUNITE, 1); + putEquipment(ItemID.Cert.RUNE_FULL_HELM, MetalBarType.RUNITE, 1); + putEquipment(ItemID.Cert.RUNE_SQ_SHIELD, MetalBarType.RUNITE, 1); + putEquipment(ItemID.Cert.RUNE_CLAWS, MetalBarType.RUNITE, 1); + putEquipment(ItemID.Cert.RUNE_WARHAMMER, MetalBarType.RUNITE, 2); + putEquipment(ItemID.Cert.RUNE_BATTLEAXE, MetalBarType.RUNITE, 2); + putEquipment(ItemID.Cert.RUNE_CHAINBODY, MetalBarType.RUNITE, 2); + putEquipment(ItemID.Cert.RUNE_KITESHIELD, MetalBarType.RUNITE, 2); + putEquipment(ItemID.Cert.RUNE_2H_SWORD, MetalBarType.RUNITE, 2); + putEquipment(ItemID.Cert.RUNE_PLATELEGS, MetalBarType.RUNITE, 2); + putEquipment(ItemID.Cert.RUNE_PLATESKIRT, MetalBarType.RUNITE, 2); + putEquipment(ItemID.Cert.RUNE_PLATEBODY, MetalBarType.RUNITE, 4); + } + + @Value + public static class Record + { + MetalBarType type; + MetalBarSource source; + int value; + } + + public static Record get(int id) + { + return values.get(id); + } + + private static void putOre(int id, MetalBarType type) + { + values.put(id, new Record(type, MetalBarSource.ORE, 1)); + } + + private static void putBar(int id, MetalBarType type) + { + values.put(id, new Record(type, MetalBarSource.BAR, 1)); + } + + private static void putEquipment(int id, MetalBarType type, int value) + { + values.put(id, new Record(type, MetalBarSource.EQUIPMENT, value)); + } + + private MetalBarValues() + { + } +} diff --git a/src/main/java/com/toofifty/easygiantsfoundry/enums/MetalBarSource.java b/src/main/java/com/toofifty/easygiantsfoundry/enums/MetalBarSource.java new file mode 100644 index 0000000..4820ebf --- /dev/null +++ b/src/main/java/com/toofifty/easygiantsfoundry/enums/MetalBarSource.java @@ -0,0 +1,9 @@ +package com.toofifty.easygiantsfoundry.enums; + +public enum MetalBarSource +{ + ORE, + BAR, + EQUIPMENT, + ; +} diff --git a/src/main/java/com/toofifty/easygiantsfoundry/enums/MetalBarType.java b/src/main/java/com/toofifty/easygiantsfoundry/enums/MetalBarType.java new file mode 100644 index 0000000..9bde3e4 --- /dev/null +++ b/src/main/java/com/toofifty/easygiantsfoundry/enums/MetalBarType.java @@ -0,0 +1,12 @@ +package com.toofifty.easygiantsfoundry.enums; + +public enum MetalBarType +{ + BRONZE, + IRON, + STEEL, + MITHRIL, + ADAMANT, + RUNITE, + ; +} \ No newline at end of file