grounditems: Add despawn timer for items placed on tables
This commit is contained in:
@@ -75,6 +75,7 @@ public class GroundItemsOverlay extends Overlay
|
|||||||
private static final Duration DESPAWN_TIME_INSTANCE = Duration.ofMinutes(30);
|
private static final Duration DESPAWN_TIME_INSTANCE = Duration.ofMinutes(30);
|
||||||
private static final Duration DESPAWN_TIME_LOOT = Duration.ofMinutes(2);
|
private static final Duration DESPAWN_TIME_LOOT = Duration.ofMinutes(2);
|
||||||
private static final Duration DESPAWN_TIME_DROP = Duration.ofMinutes(3);
|
private static final Duration DESPAWN_TIME_DROP = Duration.ofMinutes(3);
|
||||||
|
private static final Duration DESPAWN_TIME_TABLE = Duration.ofMinutes(10);
|
||||||
private static final int KRAKEN_REGION = 9116;
|
private static final int KRAKEN_REGION = 9116;
|
||||||
private static final int KBD_NMZ_REGION = 9033;
|
private static final int KBD_NMZ_REGION = 9033;
|
||||||
private static final int ZILYANA_REGION = 11602;
|
private static final int ZILYANA_REGION = 11602;
|
||||||
@@ -397,8 +398,11 @@ public class GroundItemsOverlay extends Overlay
|
|||||||
|
|
||||||
private Instant calculateDespawnTime(GroundItem groundItem)
|
private Instant calculateDespawnTime(GroundItem groundItem)
|
||||||
{
|
{
|
||||||
// We can only accurately guess despawn times for our own pvm loot and dropped items
|
// We can only accurately guess despawn times for our own pvm loot, dropped items,
|
||||||
if (groundItem.getLootType() != LootType.PVM && groundItem.getLootType() != LootType.DROPPED)
|
// and items we placed on tables
|
||||||
|
if (groundItem.getLootType() != LootType.PVM
|
||||||
|
&& groundItem.getLootType() != LootType.DROPPED
|
||||||
|
&& groundItem.getLootType() != LootType.TABLE)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -461,9 +465,18 @@ public class GroundItemsOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
despawnTime = spawnTime.plus(groundItem.getLootType() == LootType.DROPPED
|
switch (groundItem.getLootType())
|
||||||
? DESPAWN_TIME_DROP
|
{
|
||||||
: DESPAWN_TIME_LOOT);
|
case DROPPED:
|
||||||
|
despawnTime = spawnTime.plus(DESPAWN_TIME_DROP);
|
||||||
|
break;
|
||||||
|
case TABLE:
|
||||||
|
despawnTime = spawnTime.plus(DESPAWN_TIME_TABLE);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
despawnTime = spawnTime.plus(DESPAWN_TIME_LOOT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now.isBefore(spawnTime) || now.isAfter(despawnTime))
|
if (now.isBefore(spawnTime) || now.isAfter(despawnTime))
|
||||||
@@ -477,8 +490,11 @@ public class GroundItemsOverlay extends Overlay
|
|||||||
|
|
||||||
private Color getItemTimerColor(GroundItem groundItem)
|
private Color getItemTimerColor(GroundItem groundItem)
|
||||||
{
|
{
|
||||||
// We can only accurately guess despawn times for our own pvm loot and dropped items
|
// We can only accurately guess despawn times for our own pvm loot, dropped items,
|
||||||
if (groundItem.getLootType() != LootType.PVM && groundItem.getLootType() != LootType.DROPPED)
|
// and items we placed on tables
|
||||||
|
if (groundItem.getLootType() != LootType.PVM
|
||||||
|
&& groundItem.getLootType() != LootType.DROPPED
|
||||||
|
&& groundItem.getLootType() != LootType.TABLE)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,10 @@ import lombok.Setter;
|
|||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
|
import net.runelite.api.InventoryID;
|
||||||
|
import net.runelite.api.Item;
|
||||||
import net.runelite.api.ItemComposition;
|
import net.runelite.api.ItemComposition;
|
||||||
|
import net.runelite.api.ItemContainer;
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
@@ -180,6 +183,7 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
private LoadingCache<NamedQuantity, Boolean> highlightedItems;
|
private LoadingCache<NamedQuantity, Boolean> highlightedItems;
|
||||||
private LoadingCache<NamedQuantity, Boolean> hiddenItems;
|
private LoadingCache<NamedQuantity, Boolean> hiddenItems;
|
||||||
private final Queue<Integer> droppedItemQueue = EvictingQueue.create(16); // recently dropped items
|
private final Queue<Integer> droppedItemQueue = EvictingQueue.create(16); // recently dropped items
|
||||||
|
private int lastUsedItem;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
GroundItemsConfig provideConfig(ConfigManager configManager)
|
GroundItemsConfig provideConfig(ConfigManager configManager)
|
||||||
@@ -194,6 +198,7 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
mouseManager.registerMouseListener(inputListener);
|
mouseManager.registerMouseListener(inputListener);
|
||||||
keyManager.registerKeyListener(inputListener);
|
keyManager.registerKeyListener(inputListener);
|
||||||
executor.execute(this::reset);
|
executor.execute(this::reset);
|
||||||
|
lastUsedItem = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -384,6 +389,7 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId;
|
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId;
|
||||||
final int alchPrice = itemComposition.getHaPrice();
|
final int alchPrice = itemComposition.getHaPrice();
|
||||||
final boolean dropped = tile.getWorldLocation().equals(client.getLocalPlayer().getWorldLocation()) && droppedItemQueue.remove(itemId);
|
final boolean dropped = tile.getWorldLocation().equals(client.getLocalPlayer().getWorldLocation()) && droppedItemQueue.remove(itemId);
|
||||||
|
final boolean table = itemId == lastUsedItem && tile.getItemLayer().getHeight() > 0;
|
||||||
|
|
||||||
final GroundItem groundItem = GroundItem.builder()
|
final GroundItem groundItem = GroundItem.builder()
|
||||||
.id(itemId)
|
.id(itemId)
|
||||||
@@ -394,12 +400,11 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
.haPrice(alchPrice)
|
.haPrice(alchPrice)
|
||||||
.height(tile.getItemLayer().getHeight())
|
.height(tile.getItemLayer().getHeight())
|
||||||
.tradeable(itemComposition.isTradeable())
|
.tradeable(itemComposition.isTradeable())
|
||||||
.lootType(dropped ? LootType.DROPPED : LootType.UNKNOWN)
|
.lootType(dropped ? LootType.DROPPED : (table ? LootType.TABLE : LootType.UNKNOWN))
|
||||||
.spawnTime(Instant.now())
|
.spawnTime(Instant.now())
|
||||||
.stackable(itemComposition.isStackable())
|
.stackable(itemComposition.isStackable())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
// Update item price in case it is coins
|
// Update item price in case it is coins
|
||||||
if (realItemId == COINS)
|
if (realItemId == COINS)
|
||||||
{
|
{
|
||||||
@@ -687,5 +692,21 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
// item spawns that are drops
|
// item spawns that are drops
|
||||||
droppedItemQueue.add(itemId);
|
droppedItemQueue.add(itemId);
|
||||||
}
|
}
|
||||||
|
else if (menuOptionClicked.getMenuAction() == MenuAction.ITEM_USE_ON_GAME_OBJECT)
|
||||||
|
{
|
||||||
|
final ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY);
|
||||||
|
if (inventory == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Item clickedItem = inventory.getItem(menuOptionClicked.getSelectedItemIndex());
|
||||||
|
if (clickedItem == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastUsedItem = clickedItem.getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ package net.runelite.client.plugins.grounditems;
|
|||||||
enum LootType
|
enum LootType
|
||||||
{
|
{
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
|
TABLE,
|
||||||
DROPPED,
|
DROPPED,
|
||||||
PVP,
|
PVP,
|
||||||
PVM;
|
PVM;
|
||||||
|
|||||||
Reference in New Issue
Block a user