Add hide items under value to GroundItems plugin

Add option to hide items under either Grand Exchange or High Alchemy
value to GroundItems plugin. Also ensure that items with 0 or no GE
price are shown anyway, as they are probably untradeables or inactive.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2017-12-02 01:05:32 +01:00
parent 4fc1395827
commit 663cb8e69f
2 changed files with 35 additions and 4 deletions

View File

@@ -85,4 +85,24 @@ public interface GroundItemsConfig extends Config
{
return "";
}
@ConfigItem(
keyName = "hideUnderGeValue",
name = "Hide < GE Value",
description = "Configures hidden ground items under GE value"
)
default int getHideUnderGeValue()
{
return 0;
}
@ConfigItem(
keyName = "hideUnderHaValue",
name = "Hide < HA Value",
description = "Configures hidden ground items under High Alch value"
)
default int getHideUnderHAValue()
{
return 0;
}
}

View File

@@ -205,13 +205,24 @@ public class GroundItemsOverlay extends Overlay
Integer currentQuantity = items.get(itemId);
if (!hiddenItems.contains(itemDefinition.getName().toLowerCase()))
{
if (currentQuantity == null)
if (itemDefinition.getNote() != -1)
{
items.put(itemId, itemQuantity);
itemId = itemDefinition.getLinkedNoteId();
}
else
int quantity = currentQuantity == null
? itemQuantity
: currentQuantity + itemQuantity;
ItemPrice itemPrice = itemManager.get(itemId);
int gePrice = itemPrice == null ? 0 : itemPrice.getPrice() * quantity;
int alchPrice = Math.round(itemDefinition.getPrice() * HIGH_ALCHEMY_CONSTANT);
if (gePrice == 0 || ((gePrice >= config.getHideUnderGeValue()) &&
(alchPrice >= config.getHideUnderHAValue())))
{
items.put(itemId, currentQuantity + itemQuantity);
items.put(itemId, quantity);
}
}