ground items: add despawn time for gwd instances

This commit is contained in:
Adam
2021-01-22 13:16:21 -05:00
parent 2653c7fada
commit 5360bfd121

View File

@@ -58,7 +58,6 @@ import net.runelite.client.ui.overlay.components.BackgroundComponent;
import net.runelite.client.ui.overlay.components.ProgressPieComponent;
import net.runelite.client.ui.overlay.components.TextComponent;
import net.runelite.client.util.QuantityFormatter;
import org.apache.commons.lang3.ArrayUtils;
public class GroundItemsOverlay extends Overlay
{
@@ -78,6 +77,10 @@ public class GroundItemsOverlay extends Overlay
private static final Duration DESPAWN_TIME_DROP = Duration.ofMinutes(3);
private static final int KRAKEN_REGION = 9116;
private static final int KBD_NMZ_REGION = 9033;
private static final int ZILYANA_REGION = 11602;
private static final int GRAARDOR_REGION = 11347;
private static final int KRIL_TSUTSAROTH_REGION = 11603;
private static final int KREEARRA_REGION = 11346;
private final Client client;
private final GroundItemsPlugin plugin;
@@ -410,35 +413,31 @@ public class GroundItemsOverlay extends Overlay
return null;
}
Instant despawnTime;
final Instant despawnTime;
Instant now = Instant.now();
if (client.isInInstancedRegion())
{
// Items in the Kraken instance appear to never despawn?
if (isInKraken())
final int playerRegionID = WorldPoint.fromLocalInstance(client, client.getLocalPlayer().getLocalLocation()).getRegionID();
if (playerRegionID == KRAKEN_REGION)
{
// Items in the Kraken instance never despawn
return null;
}
else if (isInKBDorNMZ())
else if (playerRegionID == KBD_NMZ_REGION)
{
// NMZ and the KBD lair uses the same region ID but NMZ uses planes 1-3 and KBD uses plane 0
if (client.getLocalPlayer().getWorldLocation().getPlane() == 0)
{
// Items in the KBD instance use the standard despawn timer
if (groundItem.getLootType() == LootType.DROPPED)
{
despawnTime = spawnTime.plus(DESPAWN_TIME_DROP);
}
else
{
despawnTime = spawnTime.plus(DESPAWN_TIME_LOOT);
}
despawnTime = spawnTime.plus(groundItem.getLootType() == LootType.DROPPED
? DESPAWN_TIME_DROP
: DESPAWN_TIME_LOOT);
}
else
{
// Dropped items in the NMZ instance appear to never despawn?
if (groundItem.getLootType() == LootType.DROPPED)
{
// Dropped items in the NMZ instance never despawn
return null;
}
else
@@ -447,6 +446,14 @@ public class GroundItemsOverlay extends Overlay
}
}
}
else if (playerRegionID == ZILYANA_REGION || playerRegionID == GRAARDOR_REGION ||
playerRegionID == KRIL_TSUTSAROTH_REGION || playerRegionID == KREEARRA_REGION)
{
// GWD instances use the normal despawn timers
despawnTime = spawnTime.plus(groundItem.getLootType() == LootType.DROPPED
? DESPAWN_TIME_DROP
: DESPAWN_TIME_LOOT);
}
else
{
despawnTime = spawnTime.plus(DESPAWN_TIME_INSTANCE);
@@ -454,14 +461,9 @@ public class GroundItemsOverlay extends Overlay
}
else
{
if (groundItem.getLootType() == LootType.DROPPED)
{
despawnTime = spawnTime.plus(DESPAWN_TIME_DROP);
}
else
{
despawnTime = spawnTime.plus(DESPAWN_TIME_LOOT);
}
despawnTime = spawnTime.plus(groundItem.getLootType() == LootType.DROPPED
? DESPAWN_TIME_DROP
: DESPAWN_TIME_LOOT);
}
if (now.isBefore(spawnTime) || now.isAfter(despawnTime))
@@ -561,14 +563,4 @@ public class GroundItemsOverlay extends Overlay
}
}
private boolean isInKraken()
{
return ArrayUtils.contains(client.getMapRegions(), KRAKEN_REGION);
}
private boolean isInKBDorNMZ()
{
return ArrayUtils.contains(client.getMapRegions(), KBD_NMZ_REGION);
}
}