Pvp loot value message (#697)

* Sends a game message that tells you the total value of the loot whenever you get a pvp kill

Signed-off-by: PKLite <stonewall@pklite.xyz>

* forgot chatmessagetype

Signed-off-by: PKLite <stonewall@pklite.xyz>

* Moves this from pvp tools to Loot Tracker

Signed-off-by: PKLite <stonewall@pklite.xyz>

* Account for new WorldType

Signed-off-by: PKLite <stonewall@pklite.xyz>

* Update LootTrackerPlugin.java
This commit is contained in:
pklite
2019-06-26 04:38:25 -04:00
committed by Kyleeld
parent 716a068b3e
commit d96e5c41d5
3 changed files with 57 additions and 44 deletions

View File

@@ -158,5 +158,15 @@ public interface LootTrackerConfig extends Config
return "";
}
@ConfigItem(
keyName = "lootValueMessage",
name = "Loot Value Messages",
description = "Sends a game message with the total value you of your loot when you get a kill",
position = 5
)
default boolean sendLootValueMessages()
{
return true;
}
}

View File

@@ -133,10 +133,6 @@ public class LootTrackerPlugin extends Plugin
5179, "Brimstone Chest",
11573, "Crystal Chest"
);
// Player deaths
public static HashSet<String> usernameSet = new HashSet<String>(Arrays.stream(new String[]{"All Records"}).collect(Collectors.toList()));
private static final File LOOT_RECORDS_FILE = new File(RuneLite.RUNELITE_DIR, "lootRecords.json");
private static final Set<Integer> RESPAWN_REGIONS = ImmutableSet.of(
12850, // Lumbridge
@@ -144,49 +140,38 @@ public class LootTrackerPlugin extends Plugin
12342, // Edgeville
11062 // Camelot
);
private boolean pvpDeath = false;
@Inject
private ClientToolbar clientToolbar;
@Inject
private ItemManager itemManager;
@Inject
private ChatMessageManager chatMessageManager;
@Inject
private SpriteManager spriteManager;
@Inject
private LootTrackerConfig config;
// Player deaths
public static HashSet<String> usernameSet = new HashSet<String>(Arrays.stream(new String[]{"All Records"}).collect(Collectors.toList()));
@Inject
public Client client;
@VisibleForTesting
public Collection<LootRecord> lootRecords = new ArrayList<>();
private boolean pvpDeath = false;
@Inject
private ClientToolbar clientToolbar;
@Inject
private ItemManager itemManager;
@Inject
private ChatMessageManager chatMessageManager;
@Inject
private SpriteManager spriteManager;
@Inject
private LootTrackerConfig config;
@Inject
private ClientThread clientThread;
@Inject
private SessionManager sessionManager;
@Inject
private ScheduledExecutorService executor;
private LootTrackerPanel panel;
private NavigationButton navButton;
private String eventType;
private List<String> ignoredItems = new ArrayList<>();
private Multiset<Integer> inventorySnapshot;
@Getter(AccessLevel.PACKAGE)
private LootTrackerClient lootTrackerClient;
private BufferedReader bufferedReader;
private JsonStreamParser jsonStreamParser;
@VisibleForTesting
public Collection<LootRecord> lootRecords = new ArrayList<>();
private static Collection<ItemStack> stack(Collection<ItemStack> items)
{
@@ -217,6 +202,13 @@ public class LootTrackerPlugin extends Plugin
return list;
}
private static Collection<GameItem> toGameItems(Collection<ItemStack> items)
{
return items.stream()
.map(item -> new GameItem(item.getId(), item.getQuantity()))
.collect(Collectors.toList());
}
@Provides
LootTrackerConfig provideConfig(ConfigManager configManager)
{
@@ -405,7 +397,6 @@ public class LootTrackerPlugin extends Plugin
}
}
@Subscribe
public void onPlayerSpawned(PlayerSpawned event)
{
@@ -418,6 +409,18 @@ public class LootTrackerPlugin extends Plugin
@Subscribe
public void onPlayerLootReceived(final PlayerLootReceived playerLootReceived)
{
if (config.sendLootValueMessages())
{
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());
chatMessageManager.queue(QueuedMessage.builder().type(ChatMessageType.CONSOLE).runeLiteFormattedMessage(
new ChatMessageBuilder().append("The total value of your loot is " + totalValue + " GP.")
.build()).build());
}
}
final Player player = playerLootReceived.getPlayer();
final Collection<ItemStack> items = playerLootReceived.getItems();
final String name = player.getName();
@@ -793,13 +796,6 @@ public class LootTrackerPlugin extends Plugin
.toArray(LootTrackerItem[]::new);
}
private static Collection<GameItem> toGameItems(Collection<ItemStack> items)
{
return items.stream()
.map(item -> new GameItem(item.getId(), item.getQuantity()))
.collect(Collectors.toList());
}
public Collection<LootTrackerRecord> convertToLootTrackerRecord(final Collection<LootRecord> records)
{
Collection<LootTrackerRecord> trackerRecords = new ArrayList<>();

View File

@@ -1,10 +1,12 @@
/*
* Copyright (c) 2019. PKLite - All Rights Reserved
* Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited.
* Proprietary and confidential. Refer to PKLite License file for more information on
* full terms of this copyright and to determine what constitutes authorized use.
* Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019
*
* ******************************************************************************
* * 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.pvptools;
@@ -44,6 +46,7 @@ import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuOpened;
import net.runelite.api.events.PlayerDespawned;
import net.runelite.api.events.PlayerSpawned;
import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.game.AsyncBufferedImage;
@@ -104,6 +107,9 @@ public class PvpToolsPlugin extends Plugin
@Inject
private ItemManager itemManager;
@Inject
private ChatMessageManager chatMessageManager;
private PvpToolsPlugin uhPvpToolsPlugin = this;
private static final String WALK_HERE = "WALK HERE";
@@ -510,6 +516,7 @@ public class PvpToolsPlugin extends Plugin
}
}
/**
* Enables or disables the fall in helper feature
*/