Skip to content

Commit

Permalink
mta plugin: use item events
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed Jul 16, 2018
1 parent 216d24e commit ca4616b
Showing 1 changed file with 21 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
import net.runelite.api.GameState;
import net.runelite.api.Item;
import net.runelite.api.ItemID;
import net.runelite.api.ItemLayer;
import net.runelite.api.Player;
import net.runelite.api.Tile;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.ItemLayerChanged;
import net.runelite.api.events.ItemDespawned;
import net.runelite.api.events.ItemSpawned;
import net.runelite.client.plugins.mta.MTAConfig;
import net.runelite.client.plugins.mta.MTARoom;

Expand All @@ -61,12 +61,9 @@ private EnchantmentRoom(MTAConfig config, Client client)
@Subscribe
public void onGameStateChanged(GameStateChanged gameStateChanged)
{
if (gameStateChanged.getGameState() == GameState.LOGGED_IN)
if (gameStateChanged.getGameState() == GameState.LOADING)
{
if (!inside())
{
dragonstones.clear();
}
dragonstones.clear();
}
}

Expand Down Expand Up @@ -103,42 +100,30 @@ private WorldPoint findNearestStone()
}

@Subscribe
public void onItemLayerChanged(ItemLayerChanged event)
public void onItemSpawned(ItemSpawned itemSpawned)
{
if (!inside())
{
return;
}

Tile changed = event.getTile();
ItemLayer itemLayer = changed.getItemLayer();
WorldPoint worldPoint = changed.getWorldLocation();
final Item item = itemSpawned.getItem();
final Tile tile = itemSpawned.getTile();

List<Item> groundItems = changed.getGroundItems();
if (groundItems == null)
if (item.getId() == ItemID.DRAGONSTONE_6903)
{
boolean removed = dragonstones.remove(worldPoint);
if (removed)
{
log.debug("Removed dragonstone at {}", worldPoint);
}
return;
WorldPoint location = tile.getWorldLocation();
log.debug("Adding dragonstone at {}", location);
dragonstones.add(location);
}
}

for (Item item : changed.getGroundItems())
{
if (item.getId() == ItemID.DRAGONSTONE_6903)
{
log.debug("Adding dragonstone at {}", worldPoint);
dragonstones.add(worldPoint);
return;
}
}
@Subscribe
public void onItemDespawned(ItemDespawned itemDespawned)
{
final Item item = itemDespawned.getItem();
final Tile tile = itemDespawned.getTile();

boolean removed = dragonstones.remove(worldPoint);
if (removed)
if (item.getId() == ItemID.DRAGONSTONE_6903)
{
log.debug("Removed dragonstone at {}", worldPoint);
WorldPoint location = tile.getWorldLocation();
log.debug("Removed dragonstone at {}", location);
dragonstones.remove(location);
}
}

Expand Down

0 comments on commit ca4616b

Please sign in to comment.