Java Code Examples for net.runelite.api.ItemID#COINS_995

The following examples show how to use net.runelite.api.ItemID#COINS_995 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HighAlchemyOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private int getHAPrice(int id)
{
	if (id == ItemID.COINS_995)
	{
		return 0;
	}

	return itemManager.getAlchValue(id);
}
 
Example 2
Source File: ItemManager.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Look up an item's price
 *
 * @param itemID item id
 * @param ignoreUntradeableMap should the price returned ignore the {@link UntradeableItemMapping}
 * @return item price
 */
public int getItemPrice(int itemID, boolean ignoreUntradeableMap)
{
	if (itemID == ItemID.COINS_995)
	{
		return 1;
	}
	if (itemID == ItemID.PLATINUM_TOKEN)
	{
		return 1000;
	}

	ItemComposition itemComposition = getItemComposition(itemID);
	if (itemComposition.getNote() != -1)
	{
		itemID = itemComposition.getLinkedNoteId();
	}
	itemID = WORN_ITEMS.getOrDefault(itemID, itemID);

	if (!ignoreUntradeableMap)
	{
		UntradeableItemMapping p = UntradeableItemMapping.map(ItemVariationMapping.map(itemID));
		if (p != null)
		{
			return getItemPrice(p.getPriceID()) * p.getQuantity();
		}
	}

	int price = 0;
	for (int mappedID : ItemMapping.map(itemID))
	{
		ItemPrice ip = itemPrices.get(mappedID);
		if (ip != null)
		{
			price += ip.getPrice();
		}
	}

	return price;
}
 
Example 3
Source File: BankPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
public ContainerPrices calculate(@Nullable Item[] items)
{
	if (items == null)
	{
		return null;
	}

	long ge = 0;
	long alch = 0;

	for (final Item item : items)
	{
		final int qty = item.getQuantity();
		final int id = item.getId();

		if (id <= 0 || qty == 0)
		{
			continue;
		}

		switch (id)
		{
			case ItemID.COINS_995:
				ge += qty;
				alch += qty;
				break;
			case ItemID.PLATINUM_TOKEN:
				ge += qty * 1000L;
				alch += qty * 1000L;
				break;
			default:
				final long storePrice = itemManager.getItemDefinition(id).getPrice();
				final long alchPrice = (long) (storePrice * Constants.HIGH_ALCHEMY_MULTIPLIER);
				alch += alchPrice * qty;
				ge += (long) itemManager.getItemPrice(id) * qty;
				break;
		}
	}

	return new ContainerPrices(ge, alch);
}
 
Example 4
Source File: ExaminePlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
void onChatMessage(ChatMessage event)
{
	ExamineType type;
	switch (event.getType())
	{
		case ITEM_EXAMINE:
			type = ExamineType.ITEM;
			break;
		case OBJECT_EXAMINE:
			type = ExamineType.OBJECT;
			break;
		case NPC_EXAMINE:
			type = ExamineType.NPC;
			break;
		case GAMEMESSAGE:
			type = ExamineType.ITEM_BANK_EQ;
			break;
		default:
			return;
	}

	if (pending.isEmpty())
	{
		log.debug("Got examine without a pending examine?");
		return;
	}

	PendingExamine pendingExamine = pending.pop();

	if (pendingExamine.getType() != type)
	{
		log.debug("Type mismatch for pending examine: {} != {}", pendingExamine.getType(), type);
		pending.clear(); // eh
		return;
	}

	log.debug("Got examine for {} {}: {}", pendingExamine.getType(), pendingExamine.getId(), event.getMessage());

	// If it is an item, show the price of it
	final ItemDefinition itemDefinition;
	if (pendingExamine.getType() == ExamineType.ITEM || pendingExamine.getType() == ExamineType.ITEM_BANK_EQ)
	{
		final int itemId = pendingExamine.getId();
		final int itemQuantity = pendingExamine.getQuantity();

		if (itemId == ItemID.COINS_995)
		{
			return;
		}

		itemDefinition = itemManager.getItemDefinition(itemId);
		getItemPrice(itemDefinition.getId(), itemDefinition, itemQuantity);
	}
	else
	{
		itemDefinition = null;
	}

	// Don't submit examine info for tradeable items, which we already have from the RS item api
	if (itemDefinition != null && itemDefinition.isTradeable())
	{
		return;
	}

	// Large quantities of items show eg. 100000 x Coins
	if (type == ExamineType.ITEM && X_PATTERN.matcher(event.getMessage()).lookingAt())
	{
		return;
	}

	CacheKey key = new CacheKey(type, pendingExamine.getId());
	Boolean cached = cache.getIfPresent(key);
	if (cached != null)
	{
		return;
	}

	cache.put(key, Boolean.TRUE);
	submitExamine(pendingExamine, event.getMessage());
}
 
Example 5
Source File: ItemPricesOverlay.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private String getItemStackValueText(Item item)
{
	int id = itemManager.canonicalize(item.getId());
	int qty = item.getQuantity();

	// Special case for coins and platinum tokens
	if (id == ItemID.COINS_995)
	{
		return QuantityFormatter.formatNumber(qty) + " gp";
	}
	else if (id == ItemID.PLATINUM_TOKEN)
	{
		return QuantityFormatter.formatNumber(qty * 1000) + " gp";
	}

	ItemDefinition itemDef = itemManager.getItemDefinition(id);

	// Only check prices for things with store prices
	if (itemDef.getPrice() <= 0)
	{
		return null;
	}

	int gePrice = 0;
	int haPrice = 0;
	int haProfit = 0;
	final int itemHaPrice = Math.round(itemDef.getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER);

	if (config.showGEPrice())
	{
		gePrice = itemManager.getItemPrice(id);
	}
	if (config.showHAValue())
	{
		haPrice = itemManager.getAlchValue(id);
	}
	if (gePrice > 0 && itemHaPrice > 0 && config.showAlchProfit())
	{
		haProfit = calculateHAProfit(itemHaPrice, gePrice);
	}

	if (gePrice > 0 || haPrice > 0)
	{
		return stackValueText(qty, gePrice, haPrice, haProfit);
	}

	return null;
}
 
Example 6
Source File: BankPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Nullable
ContainerPrices calculate(@Nullable Item[] items)
{
	if (items == null)
	{
		return null;
	}

	long ge = 0;
	long alch = 0;

	for (final Item item : items)
	{
		final int qty = item.getQuantity();
		final int id = item.getId();

		if (id <= 0 || qty == 0)
		{
			continue;
		}

		switch (id)
		{
			case ItemID.COINS_995:
				ge += qty;
				alch += qty;
				break;
			case ItemID.PLATINUM_TOKEN:
				ge += qty * 1000L;
				alch += qty * 1000L;
				break;
			default:
				final int alchPrice = itemManager.getItemComposition(id).getHaPrice();
				alch += (long) alchPrice * qty;
				ge += (long) itemManager.getItemPrice(id) * qty;
				break;
		}
	}

	return new ContainerPrices(ge, alch);
}
 
Example 7
Source File: ExaminePlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Subscribe
public void onChatMessage(ChatMessage event)
{
	ExamineType type;
	switch (event.getType())
	{
		case ITEM_EXAMINE:
			type = ExamineType.ITEM;
			break;
		case OBJECT_EXAMINE:
			type = ExamineType.OBJECT;
			break;
		case NPC_EXAMINE:
			type = ExamineType.NPC;
			break;
		case GAMEMESSAGE:
			type = ExamineType.ITEM_BANK_EQ;
			break;
		default:
			return;
	}

	if (pending.isEmpty())
	{
		log.debug("Got examine without a pending examine?");
		return;
	}

	PendingExamine pendingExamine = pending.pop();

	if (pendingExamine.getType() != type)
	{
		log.debug("Type mismatch for pending examine: {} != {}", pendingExamine.getType(), type);
		pending.clear(); // eh
		return;
	}

	log.debug("Got examine for {} {}: {}", pendingExamine.getType(), pendingExamine.getId(), event.getMessage());

	// If it is an item, show the price of it
	final ItemComposition itemComposition;
	if (pendingExamine.getType() == ExamineType.ITEM || pendingExamine.getType() == ExamineType.ITEM_BANK_EQ)
	{
		final int itemId = pendingExamine.getId();
		final int itemQuantity = pendingExamine.getQuantity();

		if (itemId == ItemID.COINS_995)
		{
			return;
		}

		itemComposition = itemManager.getItemComposition(itemId);
		getItemPrice(itemComposition.getId(), itemComposition, itemQuantity);
	}
	else
	{
		itemComposition = null;
	}

	// Don't submit examine info for tradeable items, which we already have from the RS item api
	if (itemComposition != null && itemComposition.isTradeable())
	{
		return;
	}

	// Large quantities of items show eg. 100000 x Coins
	if (type == ExamineType.ITEM && X_PATTERN.matcher(event.getMessage()).lookingAt())
	{
		return;
	}

	CacheKey key = new CacheKey(type, pendingExamine.getId());
	Boolean cached = cache.getIfPresent(key);
	if (cached != null)
	{
		return;
	}

	cache.put(key, Boolean.TRUE);
	submitExamine(pendingExamine, event.getMessage());
}
 
Example 8
Source File: ItemPricesOverlay.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private String getItemStackValueText(Item item)
{
	int id = itemManager.canonicalize(item.getId());
	int qty = item.getQuantity();

	// Special case for coins and platinum tokens
	if (id == ItemID.COINS_995)
	{
		return QuantityFormatter.formatNumber(qty) + " gp";
	}
	else if (id == ItemID.PLATINUM_TOKEN)
	{
		return QuantityFormatter.formatNumber(qty * 1000) + " gp";
	}

	ItemComposition itemDef = itemManager.getItemComposition(id);

	// Only check prices for things with store prices
	if (itemDef.getPrice() <= 0)
	{
		return null;
	}

	int gePrice = 0;
	int haPrice = 0;
	int haProfit = 0;
	final int itemHaPrice = itemDef.getHaPrice();

	if (config.showGEPrice())
	{
		gePrice = itemManager.getItemPrice(id);
	}
	if (config.showHAValue())
	{
		haPrice = itemHaPrice;
	}
	if (gePrice > 0 && itemHaPrice > 0 && config.showAlchProfit())
	{
		haProfit = calculateHAProfit(itemHaPrice, gePrice);
	}

	if (gePrice > 0 || haPrice > 0)
	{
		return stackValueText(qty, gePrice, haPrice, haProfit);
	}

	return null;
}