Added high alch values to price command

This commit is contained in:
l2-
2017-07-17 21:14:28 -04:00
committed by Adam
parent 634a7dc2ce
commit 990acf1f89

View File

@@ -40,6 +40,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.http.api.item.ItemClient;
import net.runelite.http.api.item.ItemPrice;
import net.runelite.http.api.item.SearchResult;
import net.runelite.rs.api.ItemComposition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,6 +54,8 @@ public class PriceCommands extends Plugin
private final RuneLite runelite = RuneLite.getRunelite();
private final Client client = RuneLite.getClient();
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
@Override
protected void startUp() throws Exception
{
@@ -143,13 +146,20 @@ public class PriceCommands extends Plugin
return;
}
int cost = itemPrice.getPrice();
String response = "Price of " + item.getName() + ": GE average " + String.format("%,d", cost);
StringBuilder builder = new StringBuilder();
builder.append("Price of ").append(item.getName()).append(": GE average ").append(String.format("%,d", itemPrice.getPrice()));
logger.debug("Setting response {}", response);
ItemComposition itemComposition = client.getItemDefinition(itemId);
if (itemComposition != null)
{
int alchPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT);
builder.append(" HA value ").append(alchPrice);
}
logger.debug("Setting response {}", builder.toString());
// XXX hopefully messageNode hasn't been reused yet?
messageNode.setValue(response);
messageNode.setValue(builder.toString());
client.refreshChat();
}
}