agility plugin: use item events
This commit is contained in:
@@ -35,8 +35,6 @@ import lombok.Getter;
|
|||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Item;
|
import net.runelite.api.Item;
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.api.ItemLayer;
|
|
||||||
import net.runelite.api.Node;
|
|
||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
import static net.runelite.api.Skill.AGILITY;
|
import static net.runelite.api.Skill.AGILITY;
|
||||||
import net.runelite.api.Tile;
|
import net.runelite.api.Tile;
|
||||||
@@ -55,7 +53,8 @@ import net.runelite.api.events.GameTick;
|
|||||||
import net.runelite.api.events.GroundObjectChanged;
|
import net.runelite.api.events.GroundObjectChanged;
|
||||||
import net.runelite.api.events.GroundObjectDespawned;
|
import net.runelite.api.events.GroundObjectDespawned;
|
||||||
import net.runelite.api.events.GroundObjectSpawned;
|
import net.runelite.api.events.GroundObjectSpawned;
|
||||||
import net.runelite.api.events.ItemLayerChanged;
|
import net.runelite.api.events.ItemDespawned;
|
||||||
|
import net.runelite.api.events.ItemSpawned;
|
||||||
import net.runelite.api.events.WallObjectChanged;
|
import net.runelite.api.events.WallObjectChanged;
|
||||||
import net.runelite.api.events.WallObjectDespawned;
|
import net.runelite.api.events.WallObjectDespawned;
|
||||||
import net.runelite.api.events.WallObjectSpawned;
|
import net.runelite.api.events.WallObjectSpawned;
|
||||||
@@ -202,48 +201,32 @@ public class AgilityPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onItemLayerChanged(ItemLayerChanged event)
|
public void onItemSpawned(ItemSpawned itemSpawned)
|
||||||
{
|
{
|
||||||
if (obstacles.isEmpty())
|
if (obstacles.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Tile tile = event.getTile();
|
final Item item = itemSpawned.getItem();
|
||||||
final ItemLayer itemLayer = tile.getItemLayer();
|
final Tile tile = itemSpawned.getTile();
|
||||||
final boolean hasMark = tileHasMark(itemLayer);
|
|
||||||
|
|
||||||
if (markOfGrace != null && tile.getWorldLocation().equals(markOfGrace.getWorldLocation()) && !hasMark)
|
if (item.getId() == ItemID.MARK_OF_GRACE)
|
||||||
{
|
|
||||||
markOfGrace = null;
|
|
||||||
}
|
|
||||||
else if (hasMark)
|
|
||||||
{
|
{
|
||||||
markOfGrace = tile;
|
markOfGrace = tile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean tileHasMark(ItemLayer itemLayer)
|
@Subscribe
|
||||||
|
public void onItemDespawned(ItemDespawned itemDespawned)
|
||||||
{
|
{
|
||||||
if (itemLayer != null)
|
final Item item = itemDespawned.getItem();
|
||||||
{
|
|
||||||
Node currentItem = itemLayer.getBottom();
|
|
||||||
|
|
||||||
while (currentItem instanceof Item)
|
|
||||||
{
|
|
||||||
final Item item = (Item) currentItem;
|
|
||||||
|
|
||||||
currentItem = currentItem.getNext();
|
|
||||||
|
|
||||||
if (item.getId() == ItemID.MARK_OF_GRACE)
|
if (item.getId() == ItemID.MARK_OF_GRACE)
|
||||||
{
|
{
|
||||||
return true;
|
markOfGrace = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameTick(GameTick tick)
|
public void onGameTick(GameTick tick)
|
||||||
|
|||||||
Reference in New Issue
Block a user