inventorysetups: Use interface instead of type

This commit is contained in:
sdburns1998
2019-07-07 14:54:35 +02:00
parent db1df81bdd
commit f0bf873429
6 changed files with 27 additions and 20 deletions

View File

@@ -26,6 +26,7 @@
package net.runelite.client.plugins.inventorysetups;
import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -33,7 +34,7 @@ import lombok.Getter;
public class InventorySetup
{
@Getter
private ArrayList<InventorySetupItem> inventory;
private List<InventorySetupItem> inventory;
@Getter
private ArrayList<InventorySetupItem> equipment;
private List<InventorySetupItem> equipment;
}

View File

@@ -33,6 +33,7 @@ import java.awt.image.BufferedImage;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.inject.Inject;
@@ -205,8 +206,8 @@ public class InventorySetupPlugin extends Plugin
clientThread.invoke(() ->
{
ArrayList<InventorySetupItem> inv = getNormalizedContainer(InventoryID.INVENTORY);
ArrayList<InventorySetupItem> eqp = getNormalizedContainer(InventoryID.EQUIPMENT);
List<InventorySetupItem> inv = getNormalizedContainer(InventoryID.INVENTORY);
List<InventorySetupItem> eqp = getNormalizedContainer(InventoryID.EQUIPMENT);
final InventorySetup invSetup = new InventorySetup(inv, eqp);
SwingUtilities.invokeLater(() ->
@@ -333,13 +334,13 @@ public class InventorySetupPlugin extends Plugin
if (container == client.getItemContainer(InventoryID.INVENTORY))
{
ArrayList<InventorySetupItem> normContainer = getNormalizedContainer(InventoryID.INVENTORY);
List<InventorySetupItem> normContainer = getNormalizedContainer(InventoryID.INVENTORY);
final InventorySetup setup = inventorySetups.get(selectedInventorySetup);
panel.highlightDifferences(normContainer, setup, InventoryID.INVENTORY);
}
else if (container == client.getItemContainer(InventoryID.EQUIPMENT))
{
ArrayList<InventorySetupItem> normContainer = getNormalizedContainer(InventoryID.EQUIPMENT);
List<InventorySetupItem> normContainer = getNormalizedContainer(InventoryID.EQUIPMENT);
final InventorySetup setup = inventorySetups.get(selectedInventorySetup);
panel.highlightDifferences(normContainer, setup, InventoryID.EQUIPMENT);
}
@@ -371,13 +372,13 @@ public class InventorySetupPlugin extends Plugin
}
}
public ArrayList<InventorySetupItem> getNormalizedContainer(final InventoryID id)
public List<InventorySetupItem> getNormalizedContainer(final InventoryID id)
{
assert id == InventoryID.INVENTORY || id == InventoryID.EQUIPMENT : "invalid inventory ID";
final ItemContainer container = client.getItemContainer(id);
ArrayList<InventorySetupItem> newContainer = new ArrayList<>();
List<InventorySetupItem> newContainer = new ArrayList<>();
Item[] items = null;
if (container != null)

View File

@@ -28,6 +28,7 @@ package net.runelite.client.plugins.inventorysetups.ui;
import java.awt.BorderLayout;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Singleton;
import javax.swing.JLabel;
import javax.swing.JPanel;
@@ -73,7 +74,7 @@ abstract class InventorySetupContainerPanel extends JPanel
void setContainerSlot(int index,
final InventorySetupSlot containerSlot,
final ArrayList<InventorySetupItem> items)
final List<InventorySetupItem> items)
{
if (index >= items.size() || items.get(index).getId() == -1)
{

View File

@@ -28,6 +28,8 @@ package net.runelite.client.plugins.inventorysetups.ui;
import java.awt.GridLayout;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Singleton;
import javax.swing.JPanel;
import net.runelite.api.EquipmentInventorySlot;
@@ -40,7 +42,7 @@ import net.runelite.client.ui.ColorScheme;
@Singleton
public class InventorySetupEquipmentPanel extends InventorySetupContainerPanel
{
private HashMap<EquipmentInventorySlot, InventorySetupSlot> equipmentSlots;
private Map<EquipmentInventorySlot, InventorySetupSlot> equipmentSlots;
InventorySetupEquipmentPanel(final ItemManager itemManager, final InventorySetupPlugin plugin)
{
@@ -80,7 +82,7 @@ public class InventorySetupEquipmentPanel extends InventorySetupContainerPanel
void setEquipmentSetupSlots(final InventorySetup setup)
{
final ArrayList<InventorySetupItem> equipment = setup.getEquipment();
final List<InventorySetupItem> equipment = setup.getEquipment();
for (final EquipmentInventorySlot slot : EquipmentInventorySlot.values())
{
@@ -93,9 +95,9 @@ public class InventorySetupEquipmentPanel extends InventorySetupContainerPanel
}
void highlightDifferences(final ArrayList<InventorySetupItem> currEquipment, final InventorySetup inventorySetup)
void highlightDifferences(final List<InventorySetupItem> currEquipment, final InventorySetup inventorySetup)
{
final ArrayList<InventorySetupItem> equipToCheck = inventorySetup.getEquipment();
final List<InventorySetupItem> equipToCheck = inventorySetup.getEquipment();
assert currEquipment.size() == equipToCheck.size() : "size mismatch";

View File

@@ -27,6 +27,7 @@ package net.runelite.client.plugins.inventorysetups.ui;
import java.awt.GridLayout;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Singleton;
import javax.swing.JPanel;
import net.runelite.client.game.ItemManager;
@@ -40,7 +41,7 @@ public class InventorySetupInventoryPanel extends InventorySetupContainerPanel
private static final int ITEMS_PER_ROW = 4;
private static final int NUM_INVENTORY_ITEMS = 28;
private ArrayList<InventorySetupSlot> inventorySlots;
private List<InventorySetupSlot> inventorySlots;
InventorySetupInventoryPanel(final ItemManager itemManager, final InventorySetupPlugin plugin)
{
@@ -67,7 +68,7 @@ public class InventorySetupInventoryPanel extends InventorySetupContainerPanel
void setInventorySetupSlots(final InventorySetup setup)
{
ArrayList<InventorySetupItem> inventory = setup.getInventory();
List<InventorySetupItem> inventory = setup.getInventory();
for (int i = 0; i < NUM_INVENTORY_ITEMS; i++)
{
@@ -79,10 +80,10 @@ public class InventorySetupInventoryPanel extends InventorySetupContainerPanel
}
void highlightDifferentSlots(final ArrayList<InventorySetupItem> currInventory, final InventorySetup inventorySetup)
void highlightDifferentSlots(final List<InventorySetupItem> currInventory, final InventorySetup inventorySetup)
{
final ArrayList<InventorySetupItem> inventoryToCheck = inventorySetup.getInventory();
final List<InventorySetupItem> inventoryToCheck = inventorySetup.getInventory();
assert currInventory.size() == inventoryToCheck.size() : "size mismatch";

View File

@@ -34,6 +34,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Singleton;
import javax.swing.Box;
import javax.swing.BoxLayout;
@@ -254,8 +255,8 @@ public class InventorySetupPluginPanel extends PluginPanel
if (plugin.getHighlightDifference())
{
final ArrayList<InventorySetupItem> normInv = plugin.getNormalizedContainer(InventoryID.INVENTORY);
final ArrayList<InventorySetupItem> normEqp = plugin.getNormalizedContainer(InventoryID.EQUIPMENT);
final List<InventorySetupItem> normInv = plugin.getNormalizedContainer(InventoryID.INVENTORY);
final List<InventorySetupItem> normEqp = plugin.getNormalizedContainer(InventoryID.EQUIPMENT);
highlightDifferences(normInv, inventorySetup, InventoryID.INVENTORY);
highlightDifferences(normEqp, inventorySetup, InventoryID.EQUIPMENT);
@@ -287,7 +288,7 @@ public class InventorySetupPluginPanel extends PluginPanel
repaint();
}
public void highlightDifferences(final ArrayList<InventorySetupItem> container,
public void highlightDifferences(final List<InventorySetupItem> container,
final InventorySetup setupToCheck,
final InventoryID type)
{