@@ -14,7 +14,7 @@ public enum LootRecordSortType implements Comparator<LootTrackerRecord>
|
||||
@Override
|
||||
public int compare(LootTrackerRecord o1, LootTrackerRecord o2)
|
||||
{
|
||||
return Math.toIntExact(o1.getTimestamp() - o2.getTimestamp());
|
||||
return Long.compare(o1.getTimestamp(), o2.getTimestamp());
|
||||
}
|
||||
},
|
||||
TOTAL_VALUE
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.awt.GridLayout;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -121,7 +120,8 @@ class LootTrackerBox extends JPanel
|
||||
private long getTotalKills()
|
||||
{
|
||||
return hideIgnoredItems
|
||||
? records.stream().filter(r -> !Arrays.stream(r.getItems()).allMatch(LootTrackerItem::isIgnored)).count()
|
||||
? records.stream().filter(
|
||||
r -> !Arrays.stream(r.getItems()).allMatch(LootTrackerItem::isIgnored)).count()
|
||||
: records.size();
|
||||
}
|
||||
|
||||
|
||||
@@ -91,5 +91,14 @@ public interface LootTrackerConfig extends Config
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ConfigItem(
|
||||
keyName = "sortType",
|
||||
name = "Sorting",
|
||||
description = "The method for sorting Loot Tracker entries"
|
||||
)
|
||||
default LootRecordSortType sortType()
|
||||
{
|
||||
return LootRecordSortType.TIMESTAMP;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
@@ -137,6 +139,9 @@ class LootTrackerPanel extends PluginPanel
|
||||
|
||||
private final JPanel displaySelector;
|
||||
|
||||
@Getter @Setter
|
||||
private LootRecordSortType lootRecordSortType = LootRecordSortType.TIMESTAMP;
|
||||
|
||||
LootTrackerPanel(final LootTrackerPlugin plugin, final ItemManager itemManager, final LootTrackerConfig config)
|
||||
{
|
||||
this.itemManager = itemManager;
|
||||
@@ -423,6 +428,7 @@ class LootTrackerPanel extends PluginPanel
|
||||
logsContainer.removeAll();
|
||||
boxes.clear();
|
||||
int start = 0;
|
||||
records.sort(lootRecordSortType);
|
||||
if (!groupLoot && records.size() > MAX_LOOT_BOXES)
|
||||
{
|
||||
start = records.size() - MAX_LOOT_BOXES;
|
||||
|
||||
@@ -256,9 +256,18 @@ public class LootTrackerPlugin extends Plugin
|
||||
{
|
||||
if (event.getGroup().equals("loottracker"))
|
||||
{
|
||||
ignoredItems = Text.fromCSV(config.getIgnoredItems());
|
||||
SwingUtilities.invokeLater(panel::updateIgnoredRecords);
|
||||
if (event.getKey().equals("ignoredItems"))
|
||||
{
|
||||
ignoredItems = Text.fromCSV(config.getIgnoredItems());
|
||||
SwingUtilities.invokeLater(panel::updateIgnoredRecords);
|
||||
}
|
||||
if (event.getKey().equals("sortType"))
|
||||
{
|
||||
panel.setLootRecordSortType(config.sortType());
|
||||
SwingUtilities.invokeLater(panel::rebuild);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -391,7 +400,7 @@ public class LootTrackerPlugin extends Plugin
|
||||
final LootTrackerItem[] entries = buildEntries(stack(items));
|
||||
String localUsername = client.getLocalPlayer().getName();
|
||||
SwingUtilities.invokeLater(() -> panel.add(name, localUsername, combat, entries));
|
||||
LootRecord lootRecord = new LootRecord(localUsername, name, LootRecordType.PLAYER,
|
||||
LootRecord lootRecord = new LootRecord( name, localUsername, LootRecordType.PLAYER,
|
||||
toGameItems(items), Instant.now());
|
||||
if (lootTrackerClient != null && config.saveLoot())
|
||||
{
|
||||
@@ -481,11 +490,11 @@ public class LootTrackerPlugin extends Plugin
|
||||
}
|
||||
|
||||
final LootTrackerItem[] entries = buildEntries(stack(items));
|
||||
SwingUtilities.invokeLater(() -> panel.add(client.getLocalPlayer().getName(), eventType, -1, entries));
|
||||
SwingUtilities.invokeLater(() -> panel.add(eventType, client.getLocalPlayer().getName(), -1, entries));
|
||||
|
||||
if (lootTrackerClient != null && config.saveLoot())
|
||||
{
|
||||
LootRecord lootRecord = new LootRecord(client.getLocalPlayer().getName(), eventType, LootRecordType.EVENT,
|
||||
LootRecord lootRecord = new LootRecord(eventType, client.getLocalPlayer().getName(), LootRecordType.EVENT,
|
||||
toGameItems(items), Instant.now());
|
||||
lootTrackerClient.submit(lootRecord);
|
||||
}
|
||||
@@ -692,11 +701,11 @@ public class LootTrackerPlugin extends Plugin
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final LootTrackerItem[] entries = buildEntries(stack(items));
|
||||
SwingUtilities.invokeLater(() -> panel.add(client.getLocalPlayer().getName(), chestType, -1, entries));
|
||||
SwingUtilities.invokeLater(() -> panel.add(chestType, client.getLocalPlayer().getName(), -1, entries));
|
||||
|
||||
if (lootTrackerClient != null && config.saveLoot())
|
||||
{
|
||||
LootRecord lootRecord = new LootRecord(client.getLocalPlayer().getName(), chestType,
|
||||
LootRecord lootRecord = new LootRecord(chestType, client.getLocalPlayer().getName(),
|
||||
LootRecordType.EVENT, toGameItems(items), Instant.now());
|
||||
lootTrackerClient.submit(lootRecord);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user