Merge pull request #681 from pklite/loot-tracker-reset
lootracker: added additional functionality [wip]
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* * Copyright (c) 2019 RuneLitePlus
|
||||
* * Redistributions and modifications of this software are permitted as long as this notice remains in its original unmodified state at the top of this file.
|
||||
* * If there are any questions comments, or feedback about this software, please direct all inquiries directly to the file authors:
|
||||
* * ST0NEWALL#9112
|
||||
* * RuneLitePlus Discord: https://discord.gg/Q7wFtCe
|
||||
* * RuneLitePlus website: https://runelitepl.us
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.loottracker;
|
||||
|
||||
|
||||
import java.time.Duration;
|
||||
import lombok.Getter;
|
||||
|
||||
public enum LootRecordDateFilter
|
||||
{
|
||||
HOUR("Hour", Duration.ofHours(1)),
|
||||
DAY("Day", Duration.ofDays(1)),
|
||||
WEEK("Week", Duration.ofDays(7)),
|
||||
MONTH("Month", Duration.ofDays(30)),
|
||||
YEAR("Year", Duration.ofDays(365)),
|
||||
ALL("All", Duration.ZERO);
|
||||
|
||||
private final String name;
|
||||
@Getter
|
||||
private final Duration duration;
|
||||
|
||||
private LootRecordDateFilter(String name, Duration duration)
|
||||
{
|
||||
this.name = name;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public enum LootRecordSortType implements Comparator<LootTrackerRecord>
|
||||
@Override
|
||||
public int compare(LootTrackerRecord o1, LootTrackerRecord o2)
|
||||
{
|
||||
return Long.compare(o1.getTimestamp(), o2.getTimestamp());
|
||||
return Long.compare(o1.getTimestamp().toEpochMilli(), o2.getTimestamp().toEpochMilli());
|
||||
}
|
||||
},
|
||||
TOTAL_VALUE
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.awt.GridLayout;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -59,6 +60,7 @@ class LootTrackerBox extends JPanel
|
||||
private final JPanel itemContainer = new JPanel();
|
||||
private final JLabel priceLabel = new JLabel();
|
||||
private final JLabel subTitleLabel = new JLabel();
|
||||
private final JLabel dateLabel = new JLabel();
|
||||
private final ItemManager itemManager;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final String id;
|
||||
@@ -67,16 +69,20 @@ class LootTrackerBox extends JPanel
|
||||
private final List<LootTrackerRecord> records = new ArrayList<>();
|
||||
|
||||
private long totalPrice;
|
||||
private final boolean hideIgnoredItems;
|
||||
private final BiConsumer<String, Boolean> onItemToggle;
|
||||
private boolean hideIgnoredItems;
|
||||
private BiConsumer<String, Boolean> onItemToggle;
|
||||
private final long timeStamp;
|
||||
|
||||
LootTrackerBox(
|
||||
final long timeStamp,
|
||||
final ItemManager itemManager,
|
||||
final String id,
|
||||
@Nullable final String subtitle,
|
||||
final boolean hideIgnoredItems,
|
||||
@Nullable final Boolean showDate,
|
||||
final BiConsumer<String, Boolean> onItemToggle)
|
||||
{
|
||||
this.timeStamp = timeStamp;
|
||||
this.id = id;
|
||||
this.itemManager = itemManager;
|
||||
this.onItemToggle = onItemToggle;
|
||||
@@ -99,6 +105,15 @@ class LootTrackerBox extends JPanel
|
||||
subTitleLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
||||
logTitle.add(subTitleLabel, BorderLayout.CENTER);
|
||||
|
||||
dateLabel.setFont(FontManager.getRunescapeSmallFont().deriveFont(FontManager.getRunescapeSmallFont().getSize() - 2));
|
||||
dateLabel.setForeground(Color.LIGHT_GRAY);
|
||||
dateLabel.setText(new Date(timeStamp).toLocaleString());
|
||||
if (showDate)
|
||||
{
|
||||
logTitle.add(dateLabel, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
|
||||
if (!Strings.isNullOrEmpty(subtitle))
|
||||
{
|
||||
subTitleLabel.setText(subtitle);
|
||||
@@ -110,6 +125,7 @@ class LootTrackerBox extends JPanel
|
||||
|
||||
add(logTitle, BorderLayout.NORTH);
|
||||
add(itemContainer, BorderLayout.CENTER);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,14 +32,18 @@ import java.awt.GridLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Vector;
|
||||
import javax.inject.Singleton;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
@@ -77,6 +81,10 @@ class LootTrackerPanel extends PluginPanel
|
||||
private static final ImageIcon VISIBLE_ICON_HOVER;
|
||||
private static final ImageIcon INVISIBLE_ICON;
|
||||
private static final ImageIcon INVISIBLE_ICON_HOVER;
|
||||
private static final ImageIcon RESET_ICON;
|
||||
private static final ImageIcon RESET_ICON_FADED;
|
||||
private static final ImageIcon RESET_ICON_HOVER;
|
||||
|
||||
|
||||
private static final String HTML_LABEL_TEMPLATE =
|
||||
"<html><body style='color:%s'>%s<span style='color:white'>%s</span></body></html>";
|
||||
@@ -100,6 +108,8 @@ class LootTrackerPanel extends PluginPanel
|
||||
private final JLabel viewHiddenBtn = new JLabel();
|
||||
private final JLabel singleLootBtn = new JLabel();
|
||||
private final JLabel groupedLootBtn = new JLabel();
|
||||
private final JLabel resetIcon = new JLabel();
|
||||
private JComboBox dateFilterComboBox = new JComboBox<>(new Vector<LootRecordDateFilter>(Arrays.asList(LootRecordDateFilter.values())));
|
||||
|
||||
// Log collection
|
||||
private final List<LootTrackerRecord> records = new ArrayList<>();
|
||||
@@ -110,6 +120,7 @@ class LootTrackerPanel extends PluginPanel
|
||||
private final LootTrackerConfig config;
|
||||
|
||||
private boolean groupLoot;
|
||||
private LootRecordDateFilter dateFilter = LootRecordDateFilter.ALL;
|
||||
private boolean hideIgnoredItems;
|
||||
private String currentView;
|
||||
|
||||
@@ -120,11 +131,17 @@ class LootTrackerPanel extends PluginPanel
|
||||
final BufferedImage backArrowImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "back_icon.png");
|
||||
final BufferedImage visibleImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "visible_icon.png");
|
||||
final BufferedImage invisibleImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "invisible_icon.png");
|
||||
final BufferedImage resetImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "reset.png");
|
||||
|
||||
SINGLE_LOOT_VIEW = new ImageIcon(singleLootImg);
|
||||
SINGLE_LOOT_VIEW_FADED = new ImageIcon(ImageUtil.alphaOffset(singleLootImg, -180));
|
||||
SINGLE_LOOT_VIEW_HOVER = new ImageIcon(ImageUtil.alphaOffset(singleLootImg, -220));
|
||||
|
||||
RESET_ICON = new ImageIcon(resetImg);
|
||||
RESET_ICON_FADED = new ImageIcon(ImageUtil.alphaOffset(resetImg, -180));
|
||||
RESET_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(resetImg, -220));
|
||||
|
||||
|
||||
GROUPED_LOOT_VIEW = new ImageIcon(groupedLootImg);
|
||||
GROUPED_LOOT_VIEW_FADED = new ImageIcon(ImageUtil.alphaOffset(groupedLootImg, -180));
|
||||
GROUPED_LOOT_VIEW_HOVER = new ImageIcon(ImageUtil.alphaOffset(groupedLootImg, -220));
|
||||
@@ -164,7 +181,7 @@ class LootTrackerPanel extends PluginPanel
|
||||
actionsContainer.setBorder(new EmptyBorder(5, 5, 5, 10));
|
||||
actionsContainer.setVisible(false);
|
||||
|
||||
final JPanel viewControls = new JPanel(new GridLayout(1, 3, 10, 0));
|
||||
final JPanel viewControls = new JPanel(new GridLayout(1, 5, 5, 0));
|
||||
viewControls.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
|
||||
singleLootBtn.setIcon(SINGLE_LOOT_VIEW);
|
||||
@@ -236,6 +253,43 @@ class LootTrackerPanel extends PluginPanel
|
||||
}
|
||||
});
|
||||
|
||||
resetIcon.setIcon(RESET_ICON);
|
||||
resetIcon.setToolTipText("Resets all locally saved data (cannot be undone)");
|
||||
resetIcon.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e)
|
||||
{
|
||||
resetRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e)
|
||||
{
|
||||
resetIcon.setIcon(RESET_ICON_HOVER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e)
|
||||
{
|
||||
resetIcon.setIcon(records.isEmpty() ? RESET_ICON_FADED : RESET_ICON);
|
||||
}
|
||||
});
|
||||
|
||||
dateFilterComboBox.setSelectedItem(LootRecordDateFilter.ALL);
|
||||
dateFilterComboBox.setToolTipText("Filter the displayed loot records by date");
|
||||
dateFilterComboBox.setMaximumSize(new Dimension(15, 0));
|
||||
dateFilterComboBox.setMaximumRowCount(3);
|
||||
dateFilterComboBox.addItemListener(e ->
|
||||
{
|
||||
final LootRecordDateFilter dateFilterSelected = (LootRecordDateFilter) e.getItem();
|
||||
dateFilter = dateFilterSelected;
|
||||
rebuild();
|
||||
}
|
||||
);
|
||||
|
||||
//viewControls.add(dateFilterComboBox);
|
||||
viewControls.add(resetIcon);
|
||||
viewControls.add(groupedLootBtn);
|
||||
viewControls.add(singleLootBtn);
|
||||
viewControls.add(viewHiddenBtn);
|
||||
@@ -276,6 +330,7 @@ class LootTrackerPanel extends PluginPanel
|
||||
leftTitleContainer.add(backBtn, BorderLayout.WEST);
|
||||
leftTitleContainer.add(detailsTitle, BorderLayout.CENTER);
|
||||
|
||||
actionsContainer.add(dateFilterComboBox);
|
||||
actionsContainer.add(leftTitleContainer, BorderLayout.WEST);
|
||||
actionsContainer.add(viewControls, BorderLayout.EAST);
|
||||
|
||||
@@ -355,7 +410,7 @@ class LootTrackerPanel extends PluginPanel
|
||||
void add(final String eventName, final String localUsername, final int actorLevel, LootTrackerItem[] items)
|
||||
{
|
||||
final String subTitle = actorLevel > -1 ? "(lvl-" + actorLevel + ")" : "";
|
||||
final LootTrackerRecord record = new LootTrackerRecord( eventName, localUsername, subTitle, items, System.currentTimeMillis());
|
||||
final LootTrackerRecord record = new LootTrackerRecord( eventName, localUsername, subTitle, items, Instant.now());
|
||||
records.add(record);
|
||||
LootTrackerBox box = buildBox(record);
|
||||
if (box != null)
|
||||
@@ -399,6 +454,21 @@ class LootTrackerPanel extends PluginPanel
|
||||
viewHiddenBtn.setIcon(hideIgnoredItems ? VISIBLE_ICON : INVISIBLE_ICON);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all loaded records. This will also attempt to delete the local storage file
|
||||
*/
|
||||
private void resetRecords()
|
||||
{
|
||||
records.clear();
|
||||
boxes.clear();
|
||||
logsContainer.removeAll();
|
||||
logsContainer.repaint();
|
||||
if (config.localPersistence())
|
||||
{
|
||||
plugin.deleteLocalRecords();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* After an item changed it's ignored state, iterate all the records and make
|
||||
* sure all items of the same name also get updated
|
||||
@@ -407,6 +477,7 @@ class LootTrackerPanel extends PluginPanel
|
||||
{
|
||||
for (LootTrackerRecord r : records)
|
||||
{
|
||||
if (plugin.isIgnoredNPC(r.getTitle()))
|
||||
for (LootTrackerItem item : r.getItems())
|
||||
{
|
||||
if (plugin.isIgnored(item.getName()) != item.isIgnored())
|
||||
@@ -436,6 +507,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())))
|
||||
@@ -443,7 +523,15 @@ class LootTrackerPanel extends PluginPanel
|
||||
continue;
|
||||
}
|
||||
}
|
||||
buildBox(records.get(i));
|
||||
if (this.dateFilter.equals(LootRecordDateFilter.ALL))
|
||||
{
|
||||
buildBox(records.get(i));
|
||||
continue;
|
||||
}
|
||||
if (Instant.now().toEpochMilli() - records.get(i).getTimestamp().toEpochMilli() <= this.dateFilter.getDuration().toMillis())
|
||||
{
|
||||
buildBox(records.get(i));
|
||||
}
|
||||
|
||||
}
|
||||
boxes.forEach(LootTrackerBox::rebuild);
|
||||
@@ -476,6 +564,16 @@ class LootTrackerPanel extends PluginPanel
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
@@ -495,8 +593,8 @@ class LootTrackerPanel extends PluginPanel
|
||||
overallPanel.setVisible(true);
|
||||
|
||||
// Create box
|
||||
final LootTrackerBox box = new LootTrackerBox(itemManager, record.getTitle(), record.getSubTitle(),
|
||||
hideIgnoredItems, plugin::toggleItem);
|
||||
final LootTrackerBox box = new LootTrackerBox(record.getTimestamp().toEpochMilli(), itemManager, record.getTitle(), record.getSubTitle(),
|
||||
hideIgnoredItems, config.displayDate(), plugin::toggleItem);
|
||||
box.combine(record);
|
||||
|
||||
// Create popup menu
|
||||
@@ -504,6 +602,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 ->
|
||||
@@ -563,7 +681,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +169,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;
|
||||
@@ -269,6 +270,11 @@ public class LootTrackerPlugin extends Plugin
|
||||
ignoredItems = Text.fromCSV(this.getIgnoredItems);
|
||||
SwingUtilities.invokeLater(panel::updateIgnoredRecords);
|
||||
}
|
||||
if (event.getKey().equals("ignoredNPCs"))
|
||||
{
|
||||
ignoredNPCs = Text.fromCSV(config.getIgnoredNPCs());
|
||||
SwingUtilities.invokeLater(panel::updateIgnoredRecords);
|
||||
}
|
||||
if (event.getKey().equals("sortType"))
|
||||
{
|
||||
panel.setLootRecordSortType(this.sortType);
|
||||
@@ -281,9 +287,9 @@ public class LootTrackerPlugin extends Plugin
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
ignoredItems = Text.fromCSV(config.getIgnoredItems());
|
||||
ignoredNPCs = Text.fromCSV(config.getIgnoredNPCs());
|
||||
updateConfig();
|
||||
|
||||
ignoredItems = Text.fromCSV(this.getIgnoredItems);
|
||||
panel = new LootTrackerPanel(this, itemManager, config);
|
||||
spriteManager.getSpriteAsync(SpriteID.TAB_INVENTORY, 0, panel::loadHeaderIcon);
|
||||
|
||||
@@ -315,7 +321,6 @@ public class LootTrackerPlugin extends Plugin
|
||||
|
||||
executor.submit(() ->
|
||||
{
|
||||
|
||||
if (this.syncPanel && lootTrackerClient != null)
|
||||
{
|
||||
if (accountSession != null)
|
||||
@@ -406,7 +411,7 @@ public class LootTrackerPlugin extends Plugin
|
||||
LootRecord lootRecord = new LootRecord(name, localUsername, LootRecordType.NPC,
|
||||
toGameItems(items), Instant.now());
|
||||
|
||||
if (lootTrackerClient != null && this.saveLoot)
|
||||
if (config.saveLoot() && lootTrackerClient != null)
|
||||
{
|
||||
lootTrackerClient.submit(lootRecord);
|
||||
}
|
||||
@@ -430,7 +435,8 @@ public class LootTrackerPlugin extends Plugin
|
||||
{
|
||||
if (this.sendLootValueMessages)
|
||||
{
|
||||
if (WorldType.isDeadmanWorld(client.getWorldType()) || WorldType.isHighRiskWorld(client.getWorldType()) || WorldType.isPvpWorld(client.getWorldType()) || client.getVar(Varbits.IN_WILDERNESS) == 1)
|
||||
if (WorldType.isDeadmanWorld(client.getWorldType()) || WorldType.isHighRiskWorld(client.getWorldType()) ||
|
||||
WorldType.isPvpWorld(client.getWorldType()) || client.getVar(Varbits.IN_WILDERNESS) == 1)
|
||||
{
|
||||
final String totalValue = StackFormatter.quantityToRSStackSize(playerLootReceived.getItems().stream()
|
||||
.mapToInt(itemStack -> itemManager.getItemPrice(itemStack.getId()) * itemStack.getQuantity()).sum());
|
||||
@@ -453,7 +459,7 @@ public class LootTrackerPlugin extends Plugin
|
||||
{
|
||||
lootTrackerClient.submit(lootRecord);
|
||||
}
|
||||
if (this.localPersistence && lootTrackerClient == null)
|
||||
if (config.localPersistence())
|
||||
{
|
||||
saveLocalLootRecord(lootRecord);
|
||||
}
|
||||
@@ -537,14 +543,19 @@ public class LootTrackerPlugin extends Plugin
|
||||
}
|
||||
|
||||
final LootTrackerItem[] entries = buildEntries(stack(items));
|
||||
|
||||
SwingUtilities.invokeLater(() -> panel.add(eventType, client.getLocalPlayer().getName(), -1, entries));
|
||||
LootRecord lootRecord = new LootRecord(eventType, client.getLocalPlayer().getName(), LootRecordType.EVENT,
|
||||
toGameItems(items), Instant.now());
|
||||
|
||||
if (lootTrackerClient != null && this.saveLoot)
|
||||
{
|
||||
LootRecord lootRecord = new LootRecord(eventType, client.getLocalPlayer().getName(), LootRecordType.EVENT,
|
||||
toGameItems(items), Instant.now());
|
||||
lootTrackerClient.submit(lootRecord);
|
||||
}
|
||||
if (config.localPersistence())
|
||||
{
|
||||
saveLocalLootRecord(lootRecord);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -698,6 +709,20 @@ public class LootTrackerPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteLocalRecords()
|
||||
{
|
||||
try
|
||||
{
|
||||
lootRecords.clear();
|
||||
Files.deleteIfExists(LOOT_RECORDS_FILE.toPath());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.debug("Error deleting local loot records file.");
|
||||
log.debug(Arrays.toString(e.getStackTrace()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a snapshot of the local player's inventory and equipment right before respawn.
|
||||
*/
|
||||
@@ -748,13 +773,18 @@ public class LootTrackerPlugin extends Plugin
|
||||
final LootTrackerItem[] entries = buildEntries(stack(items));
|
||||
SwingUtilities.invokeLater(() -> panel.add(chestType, client.getLocalPlayer().getName(), -1, entries));
|
||||
|
||||
if (lootTrackerClient != null && this.saveLoot)
|
||||
LootRecord lootRecord = new LootRecord(chestType, client.getLocalPlayer().getName(),
|
||||
LootRecordType.EVENT, toGameItems(items), Instant.now());
|
||||
if (lootTrackerClient != null && config.saveLoot())
|
||||
{
|
||||
LootRecord lootRecord = new LootRecord(chestType, client.getLocalPlayer().getName(),
|
||||
LootRecordType.EVENT, toGameItems(items), Instant.now());
|
||||
lootTrackerClient.submit(lootRecord);
|
||||
}
|
||||
|
||||
if (config.localPersistence())
|
||||
{
|
||||
saveLocalLootRecord(lootRecord);
|
||||
}
|
||||
|
||||
inventorySnapshot = null;
|
||||
}
|
||||
}
|
||||
@@ -782,6 +812,37 @@ 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)
|
||||
{
|
||||
@@ -824,7 +885,7 @@ public class LootTrackerPlugin extends Plugin
|
||||
).toArray(LootTrackerItem[]::new);
|
||||
|
||||
trackerRecords.add(new LootTrackerRecord(record.getEventId(), record.getUsername(),
|
||||
"", drops, -1));
|
||||
"", drops, record.getTime()));
|
||||
}
|
||||
|
||||
return trackerRecords;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package net.runelite.client.plugins.loottracker;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.time.Instant;
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
@@ -35,7 +36,7 @@ class LootTrackerRecord
|
||||
private final String subTitle;
|
||||
@SerializedName("item_records")
|
||||
private final LootTrackerItem[] items;
|
||||
private final long timestamp;
|
||||
private final Instant timestamp;
|
||||
|
||||
/**
|
||||
* Checks if this record matches specified id
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 275 B |
Reference in New Issue
Block a user