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.ProgressPieComponent;
import net.runelite.client.ui.overlay.components.TextComponent; import net.runelite.client.ui.overlay.components.TextComponent;
import net.runelite.client.util.QuantityFormatter; import net.runelite.client.util.QuantityFormatter;
import org.apache.commons.lang3.ArrayUtils;
public class GroundItemsOverlay extends Overlay 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 Duration DESPAWN_TIME_DROP = Duration.ofMinutes(3);
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 GRAARDOR_REGION = 11347;
private static final int KRIL_TSUTSAROTH_REGION = 11603;
private static final int KREEARRA_REGION = 11346;
private final Client client; private final Client client;
private final GroundItemsPlugin plugin; private final GroundItemsPlugin plugin;
@@ -410,35 +413,31 @@ public class GroundItemsOverlay extends Overlay
return null; return null;
} }
Instant despawnTime; final Instant despawnTime;
Instant now = Instant.now(); Instant now = Instant.now();
if (client.isInInstancedRegion()) if (client.isInInstancedRegion())
{ {
// Items in the Kraken instance appear to never despawn? final int playerRegionID = WorldPoint.fromLocalInstance(client, client.getLocalPlayer().getLocalLocation()).getRegionID();
if (isInKraken()) if (playerRegionID == KRAKEN_REGION)
{ {
// Items in the Kraken instance never despawn
return null; 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 // 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) if (client.getLocalPlayer().getWorldLocation().getPlane() == 0)
{ {
// Items in the KBD instance use the standard despawn timer // Items in the KBD instance use the standard despawn timer
if (groundItem.getLootType() == LootType.DROPPED) despawnTime = spawnTime.plus(groundItem.getLootType() == LootType.DROPPED
{ ? DESPAWN_TIME_DROP
despawnTime = spawnTime.plus(DESPAWN_TIME_DROP); : DESPAWN_TIME_LOOT);
}
else
{
despawnTime = spawnTime.plus(DESPAWN_TIME_LOOT);
}
} }
else else
{ {
// Dropped items in the NMZ instance appear to never despawn?
if (groundItem.getLootType() == LootType.DROPPED) if (groundItem.getLootType() == LootType.DROPPED)
{ {
// Dropped items in the NMZ instance never despawn
return null; return null;
} }
else 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 else
{ {
despawnTime = spawnTime.plus(DESPAWN_TIME_INSTANCE); despawnTime = spawnTime.plus(DESPAWN_TIME_INSTANCE);
@@ -454,14 +461,9 @@ public class GroundItemsOverlay extends Overlay
} }
else else
{ {
if (groundItem.getLootType() == LootType.DROPPED) despawnTime = spawnTime.plus(groundItem.getLootType() == LootType.DROPPED
{ ? DESPAWN_TIME_DROP
despawnTime = spawnTime.plus(DESPAWN_TIME_DROP); : DESPAWN_TIME_LOOT);
}
else
{
despawnTime = spawnTime.plus(DESPAWN_TIME_LOOT);
}
} }
if (now.isBefore(spawnTime) || now.isAfter(despawnTime)) 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);
}
} }