use of net.runelite.api.ItemComposition in project runelite by runelite.
the class EmoteClue method makeOverlayHint.
@Override
public void makeOverlayHint(PanelComponent panelComponent, ClueScrollPlugin plugin) {
panelComponent.setTitle("Emote Clue");
panelComponent.getLines().add(new PanelComponent.Line("Emotes:"));
panelComponent.getLines().add(new PanelComponent.Line(getFirstEmote().getName(), TITLED_CONTENT_COLOR));
if (getSecondEmote() != null) {
panelComponent.getLines().add(new PanelComponent.Line(getSecondEmote().getName(), TITLED_CONTENT_COLOR));
}
if (getItemIds().length != 0) {
panelComponent.setWidth(160);
panelComponent.getLines().add(new PanelComponent.Line("Equip:"));
if (plugin.getEquippedItems() != null) {
for (int itemId : getItemIds()) {
ItemComposition itemDefinition = plugin.getClient().getItemDefinition(itemId);
if (itemDefinition != null) {
if (plugin.getEquippedItems().contains(itemId)) {
panelComponent.getLines().add(new PanelComponent.Line(itemDefinition.getName(), TITLED_CONTENT_COLOR, "X", Color.GREEN));
} else {
panelComponent.getLines().add(new PanelComponent.Line(itemDefinition.getName(), TITLED_CONTENT_COLOR, "-", Color.RED));
}
}
}
}
} else {
panelComponent.setWidth(130);
panelComponent.getLines().add(new PanelComponent.Line("Items:", "None"));
}
}
use of net.runelite.api.ItemComposition in project runelite by runelite.
the class GroundItemsPlugin method buildGroundItem.
@Nullable
private GroundItem buildGroundItem(final Tile tile, final Item item) {
// Collect the data for the item
final int itemId = item.getId();
final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId;
final int alchPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT);
final String name = itemComposition.getName();
final boolean hidden = isHidden(name);
if (!isHotKeyPressed() && hidden) {
return null;
}
final boolean highlighted = isHighlighted(name);
if (config.showHighlightedOnly() && !isHotKeyPressed() && !highlighted) {
return null;
}
final GroundItem groundItem = GroundItem.builder().id(itemId).location(tile.getWorldLocation()).itemId(realItemId).quantity(item.getQuantity()).name(itemComposition.getName()).haPrice(alchPrice * item.getQuantity()).build();
// Set the correct item price
if (realItemId == COINS) {
groundItem.setHaPrice(item.getQuantity());
groundItem.setGePrice(item.getQuantity());
} else {
final ItemPrice itemPrice = itemManager.getItemPriceAsync(realItemId);
groundItem.setGePrice(itemPrice != null ? itemPrice.getPrice() * item.getQuantity() : 0);
}
return groundItem;
}
use of net.runelite.api.ItemComposition in project runelite by runelite.
the class GroundItemsPlugin method onMenuEntryAdded.
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event) {
if ((config.highlightMenuOption() || config.highlightMenuItemName()) && event.getOption().equals("Take") && event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId()) {
int itemId = event.getIdentifier();
ItemComposition itemComposition = client.getItemDefinition(itemId);
if (isHidden(itemComposition.getName())) {
return;
}
Region region = client.getRegion();
Tile tile = region.getTiles()[client.getPlane()][event.getActionParam0()][event.getActionParam1()];
ItemLayer itemLayer = tile.getItemLayer();
if (itemLayer == null) {
return;
}
MenuEntry[] menuEntries = client.getMenuEntries();
MenuEntry lastEntry = menuEntries[menuEntries.length - 1];
int quantity = 1;
Node current = itemLayer.getBottom();
while (current instanceof Item) {
Item item = (Item) current;
if (item.getId() == itemId) {
quantity = item.getQuantity();
}
current = current.getNext();
}
ItemPrice itemPrice = getItemPrice(itemComposition);
int price = itemPrice == null ? itemComposition.getPrice() : itemPrice.getPrice();
int cost = quantity * price;
Color color = overlay.getCostColor(cost, isHighlighted(itemComposition.getName()), isHidden(itemComposition.getName()));
if (!color.equals(config.defaultColor())) {
String hexColor = Integer.toHexString(color.getRGB() & 0xFFFFFF);
String colTag = "<col=" + hexColor + ">";
if (config.highlightMenuOption()) {
lastEntry.setOption(colTag + "Take");
}
if (config.highlightMenuItemName()) {
String target = lastEntry.getTarget().substring(lastEntry.getTarget().indexOf(">") + 1);
lastEntry.setTarget(colTag + target);
}
}
if (config.showMenuItemQuantities() && itemComposition.isStackable() && quantity > 1) {
lastEntry.setTarget(lastEntry.getTarget() + " (" + quantity + ")");
}
client.setMenuEntries(menuEntries);
}
}
use of net.runelite.api.ItemComposition in project runelite by runelite.
the class ChatCommandsPlugin method itemPriceLookup.
/**
* Looks up the item price and changes the original message to the
* response.
*
* @param messageNode The chat message containing the command.
* @param search The item given with the command.
*/
private void itemPriceLookup(MessageNode messageNode, String search) {
SearchResult result;
try {
result = itemManager.searchForItem(search);
} catch (ExecutionException ex) {
log.warn("Unable to search for item {}", search, ex);
return;
}
if (result != null && !result.getItems().isEmpty()) {
Item item = retrieveFromList(result.getItems(), search);
if (item == null) {
log.debug("Unable to find item {} in result {}", search, result);
return;
}
int itemId = item.getId();
ItemPrice itemPrice;
try {
itemPrice = itemManager.getItemPrice(itemId);
} catch (IOException ex) {
log.warn("Unable to fetch item price for {}", itemId, ex);
return;
}
final ChatMessageBuilder builder = new ChatMessageBuilder().append(ChatColorType.NORMAL).append("Price of ").append(ChatColorType.HIGHLIGHT).append(item.getName()).append(ChatColorType.NORMAL).append(": GE average ").append(ChatColorType.HIGHLIGHT).append(StackFormatter.formatNumber(itemPrice.getPrice()));
ItemComposition itemComposition = itemManager.getItemComposition(itemId);
if (itemComposition != null) {
int alchPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT);
builder.append(ChatColorType.NORMAL).append(" HA value ").append(ChatColorType.HIGHLIGHT).append(StackFormatter.formatNumber(alchPrice));
}
String response = builder.build();
log.debug("Setting response {}", response);
messageNode.setRuneLiteFormatMessage(response);
chatMessageManager.update(messageNode);
client.refreshChat();
}
}
use of net.runelite.api.ItemComposition in project runelite by runelite.
the class GrandExchangePlugin method startUp.
@Override
protected void startUp() throws IOException {
panel = injector.getInstance(GrandExchangePanel.class);
BufferedImage icon;
synchronized (ImageIO.class) {
icon = ImageIO.read(getClass().getResourceAsStream("ge_icon.png"));
}
button = NavigationButton.builder().name("GE Offers").icon(icon).panel(panel).build();
pluginToolbar.addNavigation(button);
itemClick = new MouseListener() {
@Override
public MouseEvent mouseClicked(MouseEvent e) {
// Check if left click + alt
if (e.getButton() == MouseEvent.BUTTON1 && e.isAltDown()) {
Point mousePosition = client.getMouseCanvasPosition();
Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY);
if (inventoryWidget != null && !inventoryWidget.isHidden()) {
for (WidgetItem item : inventoryWidget.getWidgetItems()) {
if (item.getCanvasBounds().contains(mousePosition.getX(), mousePosition.getY())) {
ItemComposition itemComp = client.getItemDefinition(item.getId());
if (itemComp != null) {
e.consume();
SwingUtilities.invokeLater(() -> {
panel.showSearch();
if (!button.isSelected()) {
button.getOnSelect().run();
}
panel.getSearchPanel().priceLookup(itemComp.getName());
});
}
break;
}
}
}
}
return super.mouseClicked(e);
}
};
if (config.quickLookup()) {
mouseManager.registerMouseListener(itemClick);
}
}
Aggregations