Merge pull request #233 from deathbeam/hide-items-under-value

Add hide items under value to GroundItems plugin
This commit is contained in:
Adam
2017-12-01 20:00:50 -05:00
committed by GitHub
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

@@ -191,13 +191,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);
}
}