@@ -79,6 +79,7 @@ class LootTrackerBox extends JPanel
|
||||
final String id,
|
||||
@Nullable final String subtitle,
|
||||
final boolean hideIgnoredItems,
|
||||
@Nullable final Boolean showDate,
|
||||
final BiConsumer<String, Boolean> onItemToggle)
|
||||
{
|
||||
this.timeStamp = timeStamp;
|
||||
@@ -107,7 +108,10 @@ class LootTrackerBox extends JPanel
|
||||
dateLabel.setFont(FontManager.getRunescapeSmallFont().deriveFont(FontManager.getRunescapeSmallFont().getSize() - 2));
|
||||
dateLabel.setForeground(Color.LIGHT_GRAY);
|
||||
dateLabel.setText(new Date(timeStamp).toLocaleString());
|
||||
logTitle.add(dateLabel, BorderLayout.SOUTH);
|
||||
if (showDate)
|
||||
{
|
||||
logTitle.add(dateLabel, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
|
||||
if (!Strings.isNullOrEmpty(subtitle))
|
||||
|
||||
@@ -51,6 +51,25 @@ public interface LootTrackerConfig extends Config
|
||||
)
|
||||
void setIgnoredItems(String key);
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "ignoredNPCs",
|
||||
name = "Ignored NPCs",
|
||||
description = "Configures which NPCs should be ignored ",
|
||||
position = 1,
|
||||
group = "Filters"
|
||||
)
|
||||
default String getIgnoredNPCs()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "ignoredNPCs",
|
||||
name = "",
|
||||
description = ""
|
||||
)
|
||||
void setIgnoredNPCs(String key);
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "saveLoot",
|
||||
name = "Submit loot tracker data",
|
||||
@@ -169,4 +188,24 @@ public interface LootTrackerConfig extends Config
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showDeaths",
|
||||
name = "Show PvP Deaths",
|
||||
description = "Shows your deaths to help you calculate PvP profit"
|
||||
)
|
||||
default boolean showDeaths()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "displayDate",
|
||||
name = "Display Date",
|
||||
description = "Displays the date the loot was received"
|
||||
)
|
||||
default boolean displayDate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -506,6 +506,15 @@ class LootTrackerPanel extends PluginPanel
|
||||
for (int i = start; i < records.size(); i++)
|
||||
{
|
||||
|
||||
// Check to see if we should even show this record
|
||||
if (this.hideIgnoredItems)
|
||||
{
|
||||
if (this.plugin.isIgnoredNPC(records.get(i).getTitle()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.plugin.client.getGameState().equals(GameState.LOGGED_IN))
|
||||
{
|
||||
if (!(this.plugin.client.getLocalPlayer().getName().equals(records.get(i).getLocalUsername())))
|
||||
@@ -554,10 +563,16 @@ class LootTrackerPanel extends PluginPanel
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.dateFilter.equals(LootRecordDateFilter.ALL))
|
||||
// Check to see if we should even show this record
|
||||
if (this.hideIgnoredItems)
|
||||
{
|
||||
|
||||
if (this.plugin.isIgnoredNPC(record.getTitle()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Group all similar loot together
|
||||
if (groupLoot)
|
||||
{
|
||||
@@ -578,7 +593,7 @@ class LootTrackerPanel extends PluginPanel
|
||||
|
||||
// Create box
|
||||
final LootTrackerBox box = new LootTrackerBox(record.getTimestamp().toEpochMilli(), itemManager, record.getTitle(), record.getSubTitle(),
|
||||
hideIgnoredItems, plugin::toggleItem);
|
||||
hideIgnoredItems, config.displayDate(), plugin::toggleItem);
|
||||
box.combine(record);
|
||||
|
||||
// Create popup menu
|
||||
@@ -586,6 +601,26 @@ class LootTrackerPanel extends PluginPanel
|
||||
popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
box.setComponentPopupMenu(popupMenu);
|
||||
|
||||
// Create Hide Menu item
|
||||
|
||||
final JMenuItem hide;
|
||||
if (this.hideIgnoredItems)
|
||||
{
|
||||
hide = new JMenuItem("Hide " + box.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
hide = new JMenuItem("Unhide " + box.getId());
|
||||
}
|
||||
|
||||
hide.addActionListener(e ->
|
||||
{
|
||||
this.plugin.toggleNPC(box.getId(), this.hideIgnoredItems);
|
||||
rebuild();
|
||||
});
|
||||
|
||||
popupMenu.add(hide);
|
||||
|
||||
// Create reset menu
|
||||
final JMenuItem reset = new JMenuItem("Reset");
|
||||
reset.addActionListener(e ->
|
||||
@@ -645,7 +680,14 @@ class LootTrackerPanel extends PluginPanel
|
||||
{
|
||||
if (!record.getLocalUsername().equals(plugin.client.getLocalPlayer().getName()))
|
||||
{
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!dateFilter.equals(LootRecordDateFilter.ALL))
|
||||
{
|
||||
if (Instant.now().toEpochMilli() - record.getTimestamp().toEpochMilli()
|
||||
> this.dateFilter.getDuration().toMillis())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +167,7 @@ public class LootTrackerPlugin extends Plugin
|
||||
private NavigationButton navButton;
|
||||
private String eventType;
|
||||
private List<String> ignoredItems = new ArrayList<>();
|
||||
private List<String> ignoredNPCs = new ArrayList<>();
|
||||
private Multiset<Integer> inventorySnapshot;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private LootTrackerClient lootTrackerClient;
|
||||
@@ -268,6 +269,7 @@ public class LootTrackerPlugin extends Plugin
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
ignoredItems = Text.fromCSV(config.getIgnoredItems());
|
||||
ignoredNPCs = Text.fromCSV(config.getIgnoredNPCs());
|
||||
panel = new LootTrackerPanel(this, itemManager, config);
|
||||
spriteManager.getSpriteAsync(SpriteID.TAB_INVENTORY, 0, panel::loadHeaderIcon);
|
||||
|
||||
@@ -787,6 +789,38 @@ public class LootTrackerPlugin extends Plugin
|
||||
return ignoredItems.contains(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the hidden status for a particular record
|
||||
* @param name - The String name of the record to toggle the hidden status of
|
||||
* @param ignore - true to ignore, false to remove
|
||||
*/
|
||||
public void toggleNPC(String name, boolean ignore)
|
||||
{
|
||||
final Set<String> ignoredNPCSet = new HashSet<>(ignoredNPCs);
|
||||
|
||||
if (ignore)
|
||||
{
|
||||
ignoredNPCSet.add(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoredNPCSet.remove(name);
|
||||
}
|
||||
|
||||
config.setIgnoredNPCs(Text.toCSV(ignoredNPCSet));
|
||||
panel.rebuild();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a record name is in the list of ignored NPCs
|
||||
* @param name - The String of the name to check
|
||||
* @return - true if it is being ignored, false otherwise
|
||||
*/
|
||||
public boolean isIgnoredNPC(String name)
|
||||
{
|
||||
return ignoredNPCs.contains(name);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
private LootTrackerItem buildLootTrackerItem(int itemId, int quantity)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user