sorting is kinda bugged. need to wait until ground item glitch gets fixed
for easier testing Signed-off-by: PKLite <stonewall@pklite.xyz>
This commit is contained in:
@@ -3,10 +3,13 @@ package net.runelite.client.plugins.loottracker;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.IntStream;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.loottracker.LootRecordType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public enum LootRecordSortType implements Comparator<LootTrackerRecord>
|
||||
{
|
||||
TIMESTAMP
|
||||
@@ -22,9 +25,23 @@ public enum LootRecordSortType implements Comparator<LootTrackerRecord>
|
||||
@Override
|
||||
public int compare(LootTrackerRecord o1, LootTrackerRecord o2)
|
||||
{
|
||||
|
||||
// We want deaths at the bottom of the list
|
||||
if (o1.getSubTitle().equals(LootRecordType.DEATH.name()))
|
||||
{
|
||||
return Arrays.stream(o1.getItems()).flatMapToInt(lootTrackerItem ->
|
||||
IntStream.of((int) lootTrackerItem.getPrice() * lootTrackerItem.getQuantity())).sum();
|
||||
}
|
||||
if (o2.getSubTitle().equals(LootRecordType.DEATH.name()))
|
||||
{
|
||||
return Arrays.stream(o1.getItems()).flatMapToInt(lootTrackerItem ->
|
||||
IntStream.of((int) lootTrackerItem.getPrice() * lootTrackerItem.getQuantity())).sum();
|
||||
}
|
||||
int sum = Arrays.stream(o1.getItems()).flatMapToInt(lootTrackerItem ->
|
||||
IntStream.of((int) lootTrackerItem.getPrice() * lootTrackerItem.getQuantity())).sum();
|
||||
return sum - Arrays.stream(o2.getItems()).flatMapToInt(lootTrackerItem ->
|
||||
log.info(String.valueOf(sum + Arrays.stream(o2.getItems()).flatMapToInt(lootTrackerItem ->
|
||||
IntStream.of((int) lootTrackerItem.getPrice() * lootTrackerItem.getQuantity())).sum()));
|
||||
return sum + Arrays.stream(o2.getItems()).flatMapToInt(lootTrackerItem ->
|
||||
IntStream.of((int) lootTrackerItem.getPrice() * lootTrackerItem.getQuantity())).sum();
|
||||
}
|
||||
},
|
||||
@@ -33,7 +50,7 @@ public enum LootRecordSortType implements Comparator<LootTrackerRecord>
|
||||
@Override
|
||||
public int compare(LootTrackerRecord o1, LootTrackerRecord o2)
|
||||
{
|
||||
return o1.getItems().length - o2.getItems().length;
|
||||
return Integer.compare(o1.getItems().length, o2.getItems().length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,11 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.IntStream;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ImageIcon;
|
||||
@@ -435,7 +437,17 @@ class LootTrackerPanel extends PluginPanel
|
||||
}
|
||||
for (int i = start; i < records.size(); i++)
|
||||
{
|
||||
|
||||
if (this.plugin.client.getGameState().equals(GameState.LOGGED_IN))
|
||||
{
|
||||
if (!(this.plugin.client.getLocalPlayer().getName().equals(records.get(i).getLocalUsername())))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
buildBox(records.get(i));
|
||||
log.info(String.valueOf(Arrays.stream(records.get(i).getItems()).flatMapToInt(a -> IntStream.of(a.getQuantity() * (int) a.getPrice())).sum()));
|
||||
|
||||
}
|
||||
boxes.forEach(LootTrackerBox::rebuild);
|
||||
updateOverall();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.loottracker;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -184,7 +185,8 @@ public class LootTrackerPlugin extends Plugin
|
||||
private LootTrackerClient lootTrackerClient;
|
||||
private BufferedReader bufferedReader;
|
||||
private JsonStreamParser jsonStreamParser;
|
||||
private Collection<LootRecord> lootRecords = new ArrayList<>();
|
||||
@VisibleForTesting
|
||||
public Collection<LootRecord> lootRecords = new ArrayList<>();
|
||||
|
||||
private static Collection<ItemStack> stack(Collection<ItemStack> items)
|
||||
{
|
||||
@@ -736,6 +738,7 @@ public class LootTrackerPlugin extends Plugin
|
||||
return ignoredItems.contains(name);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
private LootTrackerItem buildLootTrackerItem(int itemId, int quantity)
|
||||
{
|
||||
final ItemDefinition itemComposition = itemManager.getItemDefinition(itemId);
|
||||
@@ -765,7 +768,7 @@ public class LootTrackerPlugin extends Plugin
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Collection<LootTrackerRecord> convertToLootTrackerRecord(final Collection<LootRecord> records)
|
||||
public Collection<LootTrackerRecord> convertToLootTrackerRecord(final Collection<LootRecord> records)
|
||||
{
|
||||
Collection<LootTrackerRecord> trackerRecords = new ArrayList<>();
|
||||
for (LootRecord record : records)
|
||||
|
||||
Reference in New Issue
Block a user