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;
|
||||||
@@ -182,8 +181,8 @@ public class AgilityPlugin extends Plugin
|
|||||||
Courses course = Courses.getCourse(client.getLocalPlayer().getWorldLocation().getRegionID());
|
Courses course = Courses.getCourse(client.getLocalPlayer().getWorldLocation().getRegionID());
|
||||||
if (course == null
|
if (course == null
|
||||||
|| (course.getCourseEndWorldPoints().length == 0
|
|| (course.getCourseEndWorldPoints().length == 0
|
||||||
? Math.abs(course.getLastObstacleXp() - skillGained) > 1
|
? Math.abs(course.getLastObstacleXp() - skillGained) > 1
|
||||||
: Arrays.stream(course.getCourseEndWorldPoints()).noneMatch(wp -> wp.equals(client.getLocalPlayer().getWorldLocation()))))
|
: Arrays.stream(course.getCourseEndWorldPoints()).noneMatch(wp -> wp.equals(client.getLocalPlayer().getWorldLocation()))))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -202,47 +201,31 @@ 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();
|
||||||
|
|
||||||
|
if (item.getId() == ItemID.MARK_OF_GRACE)
|
||||||
{
|
{
|
||||||
Node currentItem = itemLayer.getBottom();
|
markOfGrace = null;
|
||||||
|
|
||||||
while (currentItem instanceof Item)
|
|
||||||
{
|
|
||||||
final Item item = (Item) currentItem;
|
|
||||||
|
|
||||||
currentItem = currentItem.getNext();
|
|
||||||
|
|
||||||
if (item.getId() == ItemID.MARK_OF_GRACE)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -377,9 +360,9 @@ public class AgilityPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Obstacles.COURSE_OBSTACLE_IDS.contains(newObject.getId()) ||
|
if (Obstacles.COURSE_OBSTACLE_IDS.contains(newObject.getId()) ||
|
||||||
Obstacles.SHORTCUT_OBSTACLE_IDS.contains(newObject.getId()) ||
|
Obstacles.SHORTCUT_OBSTACLE_IDS.contains(newObject.getId()) ||
|
||||||
(Obstacles.TRAP_OBSTACLE_IDS.contains(newObject.getId())
|
(Obstacles.TRAP_OBSTACLE_IDS.contains(newObject.getId())
|
||||||
&& Obstacles.TRAP_OBSTACLE_REGIONS.contains(newObject.getWorldLocation().getRegionID())))
|
&& Obstacles.TRAP_OBSTACLE_REGIONS.contains(newObject.getWorldLocation().getRegionID())))
|
||||||
{
|
{
|
||||||
obstacles.put(newObject, tile);
|
obstacles.put(newObject, tile);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user