Merge pull request #3084 from devLotto/emoteclue-improvements

emoteclues: display when item is in inventory
This commit is contained in:
Tomas Slusny
2018-05-23 13:19:29 +02:00
committed by GitHub
2 changed files with 29 additions and 11 deletions

View File

@@ -112,6 +112,9 @@ public class ClueScrollPlugin extends Plugin
@Getter @Getter
private Item[] equippedItems; private Item[] equippedItems;
@Getter
private Item[] inventoryItems;
@Getter @Getter
private Instant clueTimeout; private Instant clueTimeout;
@@ -260,6 +263,7 @@ public class ClueScrollPlugin extends Plugin
npcsToMark = null; npcsToMark = null;
objectsToMark = null; objectsToMark = null;
equippedItems = null; equippedItems = null;
inventoryItems = null;
if (clue instanceof LocationsClueScroll) if (clue instanceof LocationsClueScroll)
{ {
@@ -346,11 +350,18 @@ public class ClueScrollPlugin extends Plugin
if (clue instanceof EmoteClue) if (clue instanceof EmoteClue)
{ {
ItemContainer container = client.getItemContainer(InventoryID.EQUIPMENT); ItemContainer equipment = client.getItemContainer(InventoryID.EQUIPMENT);
if (container != null) if (equipment != null)
{ {
equippedItems = container.getItems(); equippedItems = equipment.getItems();
}
ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY);
if (inventory != null)
{
inventoryItems = inventory.getItems();
} }
} }

View File

@@ -609,25 +609,32 @@ public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClu
{ {
panelComponent.getChildren().add(LineComponent.builder().left("Equip:").build()); panelComponent.getChildren().add(LineComponent.builder().left("Equip:").build());
Item[] items = plugin.getEquippedItems(); Item[] equipment = plugin.getEquippedItems();
Item[] inventory = plugin.getInventoryItems();
// If items is null, the player is wearing nothing // If equipment is null, the player is wearing nothing
if (items == null) if (equipment == null)
{ {
items = new Item[0]; equipment = new Item[0];
}
// If inventory is null, the player has nothing in their inventory
if (inventory == null)
{
inventory = new Item[0];
} }
for (ItemRequirement requirement : getItemRequirements()) for (ItemRequirement requirement : getItemRequirements())
{ {
boolean found = requirement.fulfilledBy(items); boolean equipmentFulfilled = requirement.fulfilledBy(equipment);
boolean inventoryFulfilled = requirement.fulfilledBy(inventory);
panelComponent.getChildren().add(LineComponent.builder() panelComponent.getChildren().add(LineComponent.builder()
.left(requirement.getCollectiveName(plugin.getClient())) .left(requirement.getCollectiveName(plugin.getClient()))
.leftColor(TITLED_CONTENT_COLOR) .leftColor(TITLED_CONTENT_COLOR)
.right(found ? "X" : "-") .right(equipmentFulfilled || inventoryFulfilled ? "\u2713" : "\u2717")
.rightColor(found ? Color.GREEN : Color.RED) .rightColor(equipmentFulfilled ? Color.GREEN : (inventoryFulfilled ? Color.ORANGE : Color.RED))
.build()); .build());
} }
} }
} }