loottracker: fix order on client reload

The panel is currently rebuilt with the earliest loots at the top.
For the sake of consistency, it should be the other way around.

Closes #9575
This commit is contained in:
dekvall
2019-08-10 12:23:20 +02:00
parent ef4c628068
commit 1abadb0c9c

View File

@@ -37,6 +37,7 @@ import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -607,17 +608,17 @@ public class LootTrackerPlugin extends Plugin
private Collection<LootTrackerRecord> convertToLootTrackerRecord(final Collection<LootRecord> records) private Collection<LootTrackerRecord> convertToLootTrackerRecord(final Collection<LootRecord> records)
{ {
Collection<LootTrackerRecord> trackerRecords = new ArrayList<>(); return records.stream()
for (LootRecord record : records) .sorted(Comparator.comparing(LootRecord::getTime))
{ .map(record ->
LootTrackerItem[] drops = record.getDrops().stream().map(itemStack -> {
buildLootTrackerItem(itemStack.getId(), itemStack.getQty()) LootTrackerItem[] drops = record.getDrops().stream().map(itemStack ->
).toArray(LootTrackerItem[]::new); buildLootTrackerItem(itemStack.getId(), itemStack.getQty())
).toArray(LootTrackerItem[]::new);
trackerRecords.add(new LootTrackerRecord(record.getEventId(), "", drops)); return new LootTrackerRecord(record.getEventId(), "", drops);
} })
.collect(Collectors.toCollection(ArrayList::new));
return trackerRecords;
} }
/** /**