Merge pull request #5970 from Nightfirecat/remove-deprecated-api-code
Remove deprecated API code
This commit is contained in:
@@ -29,7 +29,6 @@ import lombok.Value;
|
|||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import static net.runelite.api.Constants.CHUNK_SIZE;
|
import static net.runelite.api.Constants.CHUNK_SIZE;
|
||||||
import net.runelite.api.Perspective;
|
import net.runelite.api.Perspective;
|
||||||
import net.runelite.api.Point;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A three-dimensional point representing the coordinate of a Tile.
|
* A three-dimensional point representing the coordinate of a Tile.
|
||||||
@@ -273,12 +272,6 @@ public class WorldPoint
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public Point toPoint()
|
|
||||||
{
|
|
||||||
return new Point(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ID of the region containing this tile.
|
* Gets the ID of the region containing this tile.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.api.queries;
|
|
||||||
|
|
||||||
import static java.lang.Math.abs;
|
|
||||||
import net.runelite.api.Actor;
|
|
||||||
import net.runelite.api.Query;
|
|
||||||
import net.runelite.api.coords.LocalPoint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for getting players in view,deprecated as of existence of Actor spawn events
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract class ActorQuery<EntityType extends Actor, QueryType> extends Query<EntityType, QueryType>
|
|
||||||
{
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType nameEquals(String... names)
|
|
||||||
{
|
|
||||||
predicate = and(actor ->
|
|
||||||
{
|
|
||||||
for (String name : names)
|
|
||||||
{
|
|
||||||
String actorName = actor.getName();
|
|
||||||
if (actorName != null && actorName.equals(name))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType nameContains(String... names)
|
|
||||||
{
|
|
||||||
predicate = and(actor ->
|
|
||||||
{
|
|
||||||
for (String name : names)
|
|
||||||
{
|
|
||||||
String actorName = actor.getName();
|
|
||||||
if (actorName != null && actorName.contains(name))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType atLocalLocation(LocalPoint location)
|
|
||||||
{
|
|
||||||
predicate = and(actor -> actor.getLocalLocation().equals(location));
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType isLevel(int level)
|
|
||||||
{
|
|
||||||
predicate = and(actor -> actor.getCombatLevel() == level);
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType animationEquals(int animation)
|
|
||||||
{
|
|
||||||
predicate = and(actor -> actor.getAnimation() == animation);
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType isInteractingWith(Actor actor)
|
|
||||||
{
|
|
||||||
predicate = and(a -> a.getInteracting().equals(actor));
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType isWithinDistance(LocalPoint to, int distance)
|
|
||||||
{
|
|
||||||
predicate = and(a -> a.getLocalLocation().distanceTo(to) <= distance);
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType isWithinArea(LocalPoint from, int area)
|
|
||||||
{
|
|
||||||
predicate = and(a ->
|
|
||||||
{
|
|
||||||
LocalPoint localLocation = a.getLocalLocation();
|
|
||||||
return abs(localLocation.getX() - from.getX()) < area
|
|
||||||
&& abs(localLocation.getY() - from.getY()) < area;
|
|
||||||
});
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.api.queries;
|
|
||||||
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.DecorativeObject;
|
|
||||||
import net.runelite.api.Tile;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for getting decorative objects in view, deprecated as of existence of DecorativeObject spawn events
|
|
||||||
*
|
|
||||||
* @see net.runelite.api.events.DecorativeObjectSpawned
|
|
||||||
* @see net.runelite.api.events.DecorativeObjectDespawned
|
|
||||||
* @see net.runelite.api.events.DecorativeObjectChanged
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class DecorativeObjectQuery extends TileObjectQuery<DecorativeObject, DecorativeObjectQuery>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public DecorativeObject[] result(Client client)
|
|
||||||
{
|
|
||||||
return getDecorativeObjects(client).stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(predicate)
|
|
||||||
.distinct()
|
|
||||||
.toArray(DecorativeObject[]::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Collection<DecorativeObject> getDecorativeObjects(Client client)
|
|
||||||
{
|
|
||||||
Collection<DecorativeObject> objects = new ArrayList<>();
|
|
||||||
for (Tile tile : getTiles(client))
|
|
||||||
{
|
|
||||||
objects.add(tile.getDecorativeObject());
|
|
||||||
}
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.api.queries;
|
|
||||||
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.GameObject;
|
|
||||||
import net.runelite.api.Tile;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for getting game objects in view,deprecated as of existence of GameObject spawn events
|
|
||||||
*
|
|
||||||
* @see net.runelite.api.events.GameObjectSpawned
|
|
||||||
* @see net.runelite.api.events.GameObjectDespawned
|
|
||||||
* @see net.runelite.api.events.GameObjectChanged
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class GameObjectQuery extends TileObjectQuery<GameObject, GameObjectQuery>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public GameObject[] result(Client client)
|
|
||||||
{
|
|
||||||
return getGameObjects(client).stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(predicate)
|
|
||||||
.distinct()
|
|
||||||
.toArray(GameObject[]::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Collection<GameObject> getGameObjects(Client client)
|
|
||||||
{
|
|
||||||
Collection<GameObject> objects = new ArrayList<>();
|
|
||||||
for (Tile tile : getTiles(client))
|
|
||||||
{
|
|
||||||
GameObject[] gameObjects = tile.getGameObjects();
|
|
||||||
if (gameObjects != null)
|
|
||||||
{
|
|
||||||
objects.addAll(Arrays.asList(gameObjects));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.api.queries;
|
|
||||||
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.GroundObject;
|
|
||||||
import net.runelite.api.Tile;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for getting ground objects in view,deprecated as of existence of Item spawn events
|
|
||||||
*
|
|
||||||
* @see net.runelite.api.events.ItemSpawned
|
|
||||||
* @see net.runelite.api.events.ItemDespawned
|
|
||||||
* @see net.runelite.api.events.ItemQuantityChanged
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class GroundObjectQuery extends TileObjectQuery<GroundObject, GroundObjectQuery>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public GroundObject[] result(Client client)
|
|
||||||
{
|
|
||||||
return getGroundObjects(client).stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(predicate)
|
|
||||||
.distinct()
|
|
||||||
.toArray(GroundObject[]::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Collection<GroundObject> getGroundObjects(Client client)
|
|
||||||
{
|
|
||||||
Collection<GroundObject> objects = new ArrayList<>();
|
|
||||||
for (Tile tile : getTiles(client))
|
|
||||||
{
|
|
||||||
objects.add(tile.getGroundObject());
|
|
||||||
}
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016-2018, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.api.queries;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Objects;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.InventoryID;
|
|
||||||
import net.runelite.api.Item;
|
|
||||||
import net.runelite.api.ItemContainer;
|
|
||||||
import net.runelite.api.Query;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for getting inventory items,deprecated as of existence of item container changed events
|
|
||||||
*
|
|
||||||
* @see net.runelite.api.events.ItemContainerChanged
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class InventoryItemQuery extends Query<Item, InventoryItemQuery>
|
|
||||||
{
|
|
||||||
private final InventoryID inventory;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Item[] result(Client client)
|
|
||||||
{
|
|
||||||
ItemContainer container = client.getItemContainer(inventory);
|
|
||||||
if (container == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return Arrays.stream(container.getItems())
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(predicate)
|
|
||||||
.toArray(Item[]::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InventoryItemQuery idEquals(int... ids)
|
|
||||||
{
|
|
||||||
predicate = and(item ->
|
|
||||||
{
|
|
||||||
for (int id : ids)
|
|
||||||
{
|
|
||||||
if (item.getId() == id)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.api.queries;
|
|
||||||
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.NPC;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for getting NPCs in view,deprecated as of existence of NPC spawn events
|
|
||||||
*
|
|
||||||
* @see net.runelite.api.events.NpcSpawned
|
|
||||||
* @see net.runelite.api.events.NpcDespawned
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class NPCQuery extends ActorQuery<NPC, NPCQuery>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public NPC[] result(Client client)
|
|
||||||
{
|
|
||||||
return client.getNpcs().stream()
|
|
||||||
.filter(predicate)
|
|
||||||
.toArray(NPC[]::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public NPCQuery idEquals(int... ids)
|
|
||||||
{
|
|
||||||
predicate = and(object ->
|
|
||||||
{
|
|
||||||
for (int id : ids)
|
|
||||||
{
|
|
||||||
if (object.getId() == id)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
return (NPCQuery) this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.api.queries;
|
|
||||||
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for getting players in view,deprecated as of existence of Player spawn events
|
|
||||||
*
|
|
||||||
* @see net.runelite.api.events.PlayerSpawned
|
|
||||||
* @see net.runelite.api.events.PlayerDespawned
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class PlayerQuery extends ActorQuery<Player, PlayerQuery>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Player[] result(Client client)
|
|
||||||
{
|
|
||||||
return client.getPlayers().stream()
|
|
||||||
.filter(predicate)
|
|
||||||
.toArray(Player[]::new);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.api.queries;
|
|
||||||
|
|
||||||
import static java.lang.Math.abs;
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.Constants;
|
|
||||||
import net.runelite.api.Query;
|
|
||||||
import net.runelite.api.Scene;
|
|
||||||
import net.runelite.api.Tile;
|
|
||||||
import net.runelite.api.TileObject;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import net.runelite.api.coords.LocalPoint;
|
|
||||||
import net.runelite.api.coords.WorldPoint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for getting decorative objects in view, deprecated as of existence of Object* spawn events
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract class TileObjectQuery<EntityType extends TileObject, QueryType> extends Query<EntityType, QueryType>
|
|
||||||
{
|
|
||||||
protected List<Tile> getTiles(Client client)
|
|
||||||
{
|
|
||||||
List<Tile> tilesList = new ArrayList<>();
|
|
||||||
Scene scene = client.getScene();
|
|
||||||
Tile[][][] tiles = scene.getTiles();
|
|
||||||
int z = client.getPlane();
|
|
||||||
for (int x = 0; x < Constants.SCENE_SIZE; ++x)
|
|
||||||
{
|
|
||||||
for (int y = 0; y < Constants.SCENE_SIZE; ++y)
|
|
||||||
{
|
|
||||||
Tile tile = tiles[z][x][y];
|
|
||||||
if (tile == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
tilesList.add(tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tilesList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType idEquals(int... ids)
|
|
||||||
{
|
|
||||||
predicate = and(object ->
|
|
||||||
{
|
|
||||||
for (int id : ids)
|
|
||||||
{
|
|
||||||
if (object.getId() == id)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType atWorldLocation(WorldPoint location)
|
|
||||||
{
|
|
||||||
predicate = and(object -> object.getWorldLocation().equals(location));
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType atLocalLocation(LocalPoint location)
|
|
||||||
{
|
|
||||||
predicate = and(object -> object.getLocalLocation().equals(location));
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType isWithinDistance(LocalPoint to, int distance)
|
|
||||||
{
|
|
||||||
predicate = and(a -> a.getLocalLocation().distanceTo(to) <= distance);
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public QueryType isWithinArea(LocalPoint from, int area)
|
|
||||||
{
|
|
||||||
predicate = and(a ->
|
|
||||||
{
|
|
||||||
LocalPoint localLocation = a.getLocalLocation();
|
|
||||||
return abs(localLocation.getX() - from.getX()) < area
|
|
||||||
&& abs(localLocation.getY() - from.getY()) < area;
|
|
||||||
});
|
|
||||||
return (QueryType) this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.api.queries;
|
|
||||||
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.Tile;
|
|
||||||
import net.runelite.api.WallObject;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for getting wall objects in view,deprecated as of existence of Wall object spawn events
|
|
||||||
*
|
|
||||||
* @see net.runelite.api.events.WallObjectSpawned
|
|
||||||
* @see net.runelite.api.events.WallObjectDespawned
|
|
||||||
* @see net.runelite.api.events.WallObjectChanged
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class WallObjectQuery extends TileObjectQuery<WallObject, WallObjectQuery>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public WallObject[] result(Client client)
|
|
||||||
{
|
|
||||||
return getWallObjects(client).stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(predicate)
|
|
||||||
.distinct()
|
|
||||||
.toArray(WallObject[]::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Collection<WallObject> getWallObjects(Client client)
|
|
||||||
{
|
|
||||||
Collection<WallObject> objects = new ArrayList<>();
|
|
||||||
for (Tile tile : getTiles(client))
|
|
||||||
{
|
|
||||||
objects.add(tile.getWallObject());
|
|
||||||
}
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -25,13 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.fishing;
|
package net.runelite.client.plugins.fishing;
|
||||||
|
|
||||||
import com.google.common.primitives.Ints;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@@ -54,8 +54,8 @@ import net.runelite.api.events.GameTick;
|
|||||||
import net.runelite.api.events.InteractingChanged;
|
import net.runelite.api.events.InteractingChanged;
|
||||||
import net.runelite.api.events.ItemContainerChanged;
|
import net.runelite.api.events.ItemContainerChanged;
|
||||||
import net.runelite.api.events.NpcDespawned;
|
import net.runelite.api.events.NpcDespawned;
|
||||||
|
import net.runelite.api.events.NpcSpawned;
|
||||||
import net.runelite.api.events.VarbitChanged;
|
import net.runelite.api.events.VarbitChanged;
|
||||||
import net.runelite.api.queries.NPCQuery;
|
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
@@ -64,7 +64,6 @@ import net.runelite.client.plugins.PluginDependency;
|
|||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.xptracker.XpTrackerPlugin;
|
import net.runelite.client.plugins.xptracker.XpTrackerPlugin;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.client.util.QueryRunner;
|
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Fishing",
|
name = "Fishing",
|
||||||
@@ -85,10 +84,10 @@ public class FishingPlugin extends Plugin
|
|||||||
private final FishingSession session = new FishingSession();
|
private final FishingSession session = new FishingSession();
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private Map<Integer, MinnowSpot> minnowSpots = new HashMap<>();
|
private final Map<Integer, MinnowSpot> minnowSpots = new HashMap<>();
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private NPC[] fishingSpots;
|
private final List<NPC> fishingSpots = new ArrayList<>();
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private FishingSpot currentSpot;
|
private FishingSpot currentSpot;
|
||||||
@@ -96,9 +95,6 @@ public class FishingPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private QueryRunner queryRunner;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Notifier notifier;
|
private Notifier notifier;
|
||||||
|
|
||||||
@@ -141,6 +137,7 @@ public class FishingPlugin extends Plugin
|
|||||||
overlayManager.remove(overlay);
|
overlayManager.remove(overlay);
|
||||||
overlayManager.remove(spotOverlay);
|
overlayManager.remove(spotOverlay);
|
||||||
overlayManager.remove(fishingSpotMinimapOverlay);
|
overlayManager.remove(fishingSpotMinimapOverlay);
|
||||||
|
fishingSpots.clear();
|
||||||
minnowSpots.clear();
|
minnowSpots.clear();
|
||||||
trawlerNotificationSent = false;
|
trawlerNotificationSent = false;
|
||||||
currentSpot = null;
|
currentSpot = null;
|
||||||
@@ -266,36 +263,19 @@ public class FishingPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final LocalPoint cameraPoint = new LocalPoint(client.getCameraX(), client.getCameraY());
|
inverseSortSpotDistanceFromPlayer();
|
||||||
|
|
||||||
final NPCQuery query = new NPCQuery()
|
for (NPC npc : fishingSpots)
|
||||||
.idEquals(Ints.toArray(FishingSpot.getSPOTS().keySet()));
|
|
||||||
NPC[] spots = queryRunner.runQuery(query);
|
|
||||||
// -1 to make closer things draw last (on top of farther things)
|
|
||||||
Arrays.sort(spots, Comparator.comparing(npc -> -1 * npc.getLocalLocation().distanceTo(cameraPoint)));
|
|
||||||
fishingSpots = spots;
|
|
||||||
|
|
||||||
// process minnows
|
|
||||||
for (NPC npc : spots)
|
|
||||||
{
|
{
|
||||||
FishingSpot spot = FishingSpot.getSPOTS().get(npc.getId());
|
if (FishingSpot.getSPOTS().get(npc.getId()) == FishingSpot.MINNOW && config.showMinnowOverlay())
|
||||||
|
|
||||||
if (spot == null)
|
|
||||||
{
|
{
|
||||||
continue;
|
final int id = npc.getIndex();
|
||||||
}
|
final MinnowSpot minnowSpot = minnowSpots.get(id);
|
||||||
|
|
||||||
if (spot == FishingSpot.MINNOW && config.showMinnowOverlay())
|
|
||||||
{
|
|
||||||
int id = npc.getIndex();
|
|
||||||
MinnowSpot minnowSpot = minnowSpots.get(id);
|
|
||||||
// create the minnow spot if it doesn't already exist
|
// create the minnow spot if it doesn't already exist
|
||||||
if (minnowSpot == null)
|
// or if it was moved, reset it
|
||||||
{
|
if (minnowSpot == null
|
||||||
minnowSpots.put(id, new MinnowSpot(npc.getWorldLocation(), Instant.now()));
|
|| !minnowSpot.getLoc().equals(npc.getWorldLocation()))
|
||||||
}
|
|
||||||
// if moved, reset
|
|
||||||
else if (!minnowSpot.getLoc().equals(npc.getWorldLocation()))
|
|
||||||
{
|
{
|
||||||
minnowSpots.put(id, new MinnowSpot(npc.getWorldLocation(), Instant.now()));
|
minnowSpots.put(id, new MinnowSpot(npc.getWorldLocation(), Instant.now()));
|
||||||
}
|
}
|
||||||
@@ -303,10 +283,27 @@ public class FishingPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onNpcSpawned(NpcSpawned event)
|
||||||
|
{
|
||||||
|
final NPC npc = event.getNpc();
|
||||||
|
|
||||||
|
if (!FishingSpot.getSPOTS().containsKey(npc.getId()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fishingSpots.add(npc);
|
||||||
|
inverseSortSpotDistanceFromPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onNpcDespawned(NpcDespawned npcDespawned)
|
public void onNpcDespawned(NpcDespawned npcDespawned)
|
||||||
{
|
{
|
||||||
NPC npc = npcDespawned.getNpc();
|
final NPC npc = npcDespawned.getNpc();
|
||||||
|
|
||||||
|
fishingSpots.remove(npc);
|
||||||
|
|
||||||
MinnowSpot minnowSpot = minnowSpots.remove(npc.getIndex());
|
MinnowSpot minnowSpot = minnowSpots.remove(npc.getIndex());
|
||||||
if (minnowSpot != null)
|
if (minnowSpot != null)
|
||||||
{
|
{
|
||||||
@@ -338,4 +335,10 @@ public class FishingPlugin extends Plugin
|
|||||||
trawlerNotificationSent = false;
|
trawlerNotificationSent = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void inverseSortSpotDistanceFromPlayer()
|
||||||
|
{
|
||||||
|
final LocalPoint cameraPoint = new LocalPoint(client.getCameraX(), client.getCameraY());
|
||||||
|
fishingSpots.sort(Comparator.comparing(npc -> -1 * npc.getLocalLocation().distanceTo(cameraPoint)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,13 +62,7 @@ class FishingSpotMinimapOverlay extends Overlay
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
NPC[] fishingSpots = plugin.getFishingSpots();
|
for (NPC npc : plugin.getFishingSpots())
|
||||||
if (fishingSpots == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (NPC npc : fishingSpots)
|
|
||||||
{
|
{
|
||||||
FishingSpot spot = FishingSpot.getSPOTS().get(npc.getId());
|
FishingSpot spot = FishingSpot.getSPOTS().get(npc.getId());
|
||||||
|
|
||||||
|
|||||||
@@ -79,13 +79,7 @@ class FishingSpotOverlay extends Overlay
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
NPC[] fishingSpots = plugin.getFishingSpots();
|
for (NPC npc : plugin.getFishingSpots())
|
||||||
if (fishingSpots == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (NPC npc : fishingSpots)
|
|
||||||
{
|
{
|
||||||
FishingSpot spot = FishingSpot.getSPOTS().get(npc.getId());
|
FishingSpot spot = FishingSpot.getSPOTS().get(npc.getId());
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ public class MTAPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
eventBus.unregister(room);
|
eventBus.unregister(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
telekineticRoom.resetRoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,11 @@ import java.awt.Color;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Polygon;
|
import java.awt.Polygon;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -52,11 +54,12 @@ import net.runelite.api.coords.Direction;
|
|||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
import net.runelite.api.coords.WorldArea;
|
import net.runelite.api.coords.WorldArea;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
|
import net.runelite.api.events.GroundObjectSpawned;
|
||||||
import net.runelite.api.events.NpcDespawned;
|
import net.runelite.api.events.NpcDespawned;
|
||||||
import net.runelite.api.events.NpcSpawned;
|
import net.runelite.api.events.NpcSpawned;
|
||||||
import net.runelite.api.queries.GroundObjectQuery;
|
import net.runelite.api.events.WallObjectSpawned;
|
||||||
import net.runelite.api.queries.WallObjectQuery;
|
|
||||||
import net.runelite.api.widgets.WidgetID;
|
import net.runelite.api.widgets.WidgetID;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.plugins.mta.MTAConfig;
|
import net.runelite.client.plugins.mta.MTAConfig;
|
||||||
@@ -71,9 +74,12 @@ public class TelekineticRoom extends MTARoom
|
|||||||
|
|
||||||
private final Client client;
|
private final Client client;
|
||||||
|
|
||||||
|
private final List<WallObject> telekineticWalls = new ArrayList<>();
|
||||||
|
|
||||||
private Stack<Direction> moves = new Stack<>();
|
private Stack<Direction> moves = new Stack<>();
|
||||||
private LocalPoint destination;
|
private LocalPoint destination;
|
||||||
private WorldPoint location;
|
private WorldPoint location;
|
||||||
|
private WorldPoint finishLocation;
|
||||||
private Rectangle bounds;
|
private Rectangle bounds;
|
||||||
private NPC guardian;
|
private NPC guardian;
|
||||||
private Maze maze;
|
private Maze maze;
|
||||||
@@ -85,6 +91,45 @@ public class TelekineticRoom extends MTARoom
|
|||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetRoom()
|
||||||
|
{
|
||||||
|
finishLocation = null;
|
||||||
|
telekineticWalls.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onWallObjectSpawned(WallObjectSpawned event)
|
||||||
|
{
|
||||||
|
final WallObject wall = event.getWallObject();
|
||||||
|
if (wall.getId() != TELEKINETIC_WALL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
telekineticWalls.add(wall);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onGameStateChanged(GameStateChanged event)
|
||||||
|
{
|
||||||
|
if (event.getGameState() == GameState.LOADING)
|
||||||
|
{
|
||||||
|
// Game objects are nulled when loading new scenes, thus never trigger their respective
|
||||||
|
// ObjectDespawned events.
|
||||||
|
resetRoom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onGroundObjectSpawned(GroundObjectSpawned event)
|
||||||
|
{
|
||||||
|
final GroundObject object = event.getGroundObject();
|
||||||
|
if (object.getId() == TELEKINETIC_FINISH)
|
||||||
|
{
|
||||||
|
finishLocation = object.getWorldLocation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameTick(GameTick event)
|
public void onGameTick(GameTick event)
|
||||||
{
|
{
|
||||||
@@ -97,15 +142,10 @@ public class TelekineticRoom extends MTARoom
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WallObjectQuery qry = new WallObjectQuery()
|
if (maze == null || telekineticWalls.size() != maze.getWalls())
|
||||||
.idEquals(TELEKINETIC_WALL);
|
|
||||||
WallObject[] result = qry.result(client);
|
|
||||||
int length = result.length;
|
|
||||||
|
|
||||||
if (maze == null || length != maze.getWalls())
|
|
||||||
{
|
{
|
||||||
bounds = getBounds(result);
|
bounds = getBounds(telekineticWalls.toArray(new WallObject[0]));
|
||||||
maze = Maze.fromWalls(length);
|
maze = Maze.fromWalls(telekineticWalls.size());
|
||||||
client.clearHintArrow();
|
client.clearHintArrow();
|
||||||
}
|
}
|
||||||
else if (guardian != null)
|
else if (guardian != null)
|
||||||
@@ -131,9 +171,8 @@ public class TelekineticRoom extends MTARoom
|
|||||||
log.debug("Updating guarding location {} -> {}", location, current);
|
log.debug("Updating guarding location {} -> {}", location, current);
|
||||||
|
|
||||||
location = current;
|
location = current;
|
||||||
final LocalPoint finish = finish();
|
|
||||||
|
|
||||||
if (finish != null && location.equals(WorldPoint.fromLocal(client, finish)))
|
if (location.equals(finishLocation))
|
||||||
{
|
{
|
||||||
client.clearHintArrow();
|
client.clearHintArrow();
|
||||||
}
|
}
|
||||||
@@ -310,8 +349,6 @@ public class TelekineticRoom extends MTARoom
|
|||||||
|
|
||||||
private Stack<Direction> build(WorldPoint start)
|
private Stack<Direction> build(WorldPoint start)
|
||||||
{
|
{
|
||||||
LocalPoint finish = finish();
|
|
||||||
|
|
||||||
Queue<WorldPoint> visit = new LinkedList<>();
|
Queue<WorldPoint> visit = new LinkedList<>();
|
||||||
Set<WorldPoint> closed = new HashSet<>();
|
Set<WorldPoint> closed = new HashSet<>();
|
||||||
Map<WorldPoint, Integer> scores = new HashMap<>();
|
Map<WorldPoint, Integer> scores = new HashMap<>();
|
||||||
@@ -351,7 +388,7 @@ public class TelekineticRoom extends MTARoom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return build(edges, WorldPoint.fromLocal(client, finish));
|
return build(edges, finishLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stack<Direction> build(Map<WorldPoint, WorldPoint> edges, WorldPoint finish)
|
private Stack<Direction> build(Map<WorldPoint, WorldPoint> edges, WorldPoint finish)
|
||||||
@@ -435,21 +472,6 @@ public class TelekineticRoom extends MTARoom
|
|||||||
return LocalPoint.fromWorld(client, worldPoint);
|
return LocalPoint.fromWorld(client, worldPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocalPoint finish()
|
|
||||||
{
|
|
||||||
GroundObjectQuery qry = new GroundObjectQuery()
|
|
||||||
.idEquals(TELEKINETIC_FINISH);
|
|
||||||
|
|
||||||
GroundObject[] result = qry.result(client);
|
|
||||||
|
|
||||||
if (result.length > 0)
|
|
||||||
{
|
|
||||||
return result[0].getLocalLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rectangle getBounds(WallObject[] walls)
|
private Rectangle getBounds(WallObject[] walls)
|
||||||
{
|
{
|
||||||
int minX = Integer.MAX_VALUE;
|
int minX = Integer.MAX_VALUE;
|
||||||
|
|||||||
@@ -30,15 +30,12 @@ import java.awt.Dimension;
|
|||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.Arrays;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.Query;
|
|
||||||
import net.runelite.api.queries.NPCQuery;
|
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import static net.runelite.client.plugins.pestcontrol.Portal.BLUE;
|
import static net.runelite.client.plugins.pestcontrol.Portal.BLUE;
|
||||||
@@ -48,12 +45,11 @@ import static net.runelite.client.plugins.pestcontrol.Portal.YELLOW;
|
|||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||||
import net.runelite.client.util.QueryRunner;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PestControlOverlay extends Overlay
|
public class PestControlOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private final QueryRunner queryRunner;
|
private final PestControlPlugin plugin;
|
||||||
private final Client client;
|
private final Client client;
|
||||||
|
|
||||||
// Pest control game
|
// Pest control game
|
||||||
@@ -61,10 +57,10 @@ public class PestControlOverlay extends Overlay
|
|||||||
private Game game;
|
private Game game;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PestControlOverlay(QueryRunner queryRunner, Client client)
|
public PestControlOverlay(PestControlPlugin plugin, Client client)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
this.queryRunner = queryRunner;
|
this.plugin = plugin;
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,9 +93,10 @@ public class PestControlOverlay extends Overlay
|
|||||||
|
|
||||||
private void renderSpinners(Graphics2D graphics)
|
private void renderSpinners(Graphics2D graphics)
|
||||||
{
|
{
|
||||||
Query query = new NPCQuery().nameEquals("Spinner");
|
for (NPC npc : plugin.getSpinners())
|
||||||
NPC[] result = queryRunner.runQuery(query);
|
{
|
||||||
Arrays.stream(result).forEach(npc -> OverlayUtil.renderActorOverlay(graphics, npc, npc.getName(), Color.CYAN));
|
OverlayUtil.renderActorOverlay(graphics, npc, npc.getName(), Color.CYAN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderPortalWidgets(Graphics2D graphics)
|
private void renderPortalWidgets(Graphics2D graphics)
|
||||||
|
|||||||
@@ -24,13 +24,23 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.pestcontrol;
|
package net.runelite.client.plugins.pestcontrol;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Getter;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.NPC;
|
||||||
|
import net.runelite.api.NpcID;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
|
import net.runelite.api.events.NpcDespawned;
|
||||||
|
import net.runelite.api.events.NpcSpawned;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
@@ -42,8 +52,19 @@ import net.runelite.client.ui.overlay.OverlayManager;
|
|||||||
)
|
)
|
||||||
public class PestControlPlugin extends Plugin
|
public class PestControlPlugin extends Plugin
|
||||||
{
|
{
|
||||||
|
private static final Set<Integer> SPINNER_IDS = ImmutableSet.of(
|
||||||
|
NpcID.SPINNER,
|
||||||
|
NpcID.SPINNER_1710,
|
||||||
|
NpcID.SPINNER_1711,
|
||||||
|
NpcID.SPINNER_1712,
|
||||||
|
NpcID.SPINNER_1713
|
||||||
|
);
|
||||||
|
|
||||||
private final Pattern SHIELD_DROP = Pattern.compile("The ([a-z]+), [^ ]+ portal shield has dropped!", Pattern.CASE_INSENSITIVE);
|
private final Pattern SHIELD_DROP = Pattern.compile("The ([a-z]+), [^ ]+ portal shield has dropped!", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
@Getter(AccessLevel.PACKAGE)
|
||||||
|
private List<NPC> spinners = new ArrayList<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
@@ -63,6 +84,7 @@ public class PestControlPlugin extends Plugin
|
|||||||
protected void shutDown() throws Exception
|
protected void shutDown() throws Exception
|
||||||
{
|
{
|
||||||
overlayManager.remove(overlay);
|
overlayManager.remove(overlay);
|
||||||
|
spinners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -77,4 +99,20 @@ public class PestControlPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onNpcSpawned(NpcSpawned event)
|
||||||
|
{
|
||||||
|
final NPC npc = event.getNpc();
|
||||||
|
if (SPINNER_IDS.contains(npc.getId()))
|
||||||
|
{
|
||||||
|
spinners.add(npc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onNpcDespawned(NpcDespawned event)
|
||||||
|
{
|
||||||
|
spinners.remove(event.getNpc());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,11 +24,14 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.runecraft;
|
package net.runelite.client.plugins.runecraft;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -41,16 +44,15 @@ import net.runelite.api.Item;
|
|||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.NpcID;
|
import net.runelite.api.NpcID;
|
||||||
import net.runelite.api.Query;
|
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
import net.runelite.api.events.ConfigChanged;
|
import net.runelite.api.events.ConfigChanged;
|
||||||
import net.runelite.api.events.DecorativeObjectDespawned;
|
import net.runelite.api.events.DecorativeObjectDespawned;
|
||||||
import net.runelite.api.events.DecorativeObjectSpawned;
|
import net.runelite.api.events.DecorativeObjectSpawned;
|
||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.ItemContainerChanged;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
import net.runelite.api.events.MenuOptionClicked;
|
||||||
import net.runelite.api.queries.InventoryItemQuery;
|
import net.runelite.api.events.NpcDespawned;
|
||||||
import net.runelite.api.queries.NPCQuery;
|
import net.runelite.api.events.NpcSpawned;
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
@@ -59,7 +61,6 @@ import net.runelite.client.eventbus.Subscribe;
|
|||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.client.util.QueryRunner;
|
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Runecraft",
|
name = "Runecraft",
|
||||||
@@ -72,6 +73,11 @@ public class RunecraftPlugin extends Plugin
|
|||||||
private static final String POUCH_DECAYED_NOTIFICATION_MESSAGE = "Your rune pouch has decayed.";
|
private static final String POUCH_DECAYED_NOTIFICATION_MESSAGE = "Your rune pouch has decayed.";
|
||||||
private static final String POUCH_DECAYED_MESSAGE = "Your pouch has decayed through use.";
|
private static final String POUCH_DECAYED_MESSAGE = "Your pouch has decayed through use.";
|
||||||
private static final int DESTROY_ITEM_WIDGET_ID = WidgetInfo.DESTROY_ITEM_YES.getId();
|
private static final int DESTROY_ITEM_WIDGET_ID = WidgetInfo.DESTROY_ITEM_YES.getId();
|
||||||
|
private static final List<Integer> DEGRADED_POUCHES = ImmutableList.of(
|
||||||
|
ItemID.MEDIUM_POUCH_5511,
|
||||||
|
ItemID.LARGE_POUCH_5513,
|
||||||
|
ItemID.GIANT_POUCH_5515
|
||||||
|
);
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private final Set<DecorativeObject> abyssObjects = new HashSet<>();
|
private final Set<DecorativeObject> abyssObjects = new HashSet<>();
|
||||||
@@ -94,9 +100,6 @@ public class RunecraftPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private AbyssOverlay abyssOverlay;
|
private AbyssOverlay abyssOverlay;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private QueryRunner queryRunner;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RunecraftConfig config;
|
private RunecraftConfig config;
|
||||||
|
|
||||||
@@ -233,29 +236,34 @@ public class RunecraftPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameTick(GameTick event)
|
public void onItemContainerChanged(ItemContainerChanged event)
|
||||||
{
|
{
|
||||||
darkMage = null;
|
if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY))
|
||||||
|
|
||||||
if (!config.hightlightDarkMage())
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Query inventoryQuery = new InventoryItemQuery(InventoryID.INVENTORY).idEquals(
|
final Item[] items = event.getItemContainer().getItems();
|
||||||
ItemID.MEDIUM_POUCH_5511,
|
degradedPouchInInventory = Stream.of(items).anyMatch(i -> DEGRADED_POUCHES.contains(i.getId()));
|
||||||
ItemID.LARGE_POUCH_5513,
|
}
|
||||||
ItemID.GIANT_POUCH_5515
|
|
||||||
);
|
|
||||||
|
|
||||||
Item[] items = queryRunner.runQuery(inventoryQuery);
|
@Subscribe
|
||||||
degradedPouchInInventory = items != null && items.length > 0;
|
public void onNpcSpawned(NpcSpawned event)
|
||||||
|
{
|
||||||
if (degradedPouchInInventory)
|
final NPC npc = event.getNpc();
|
||||||
|
if (npc.getId() == NpcID.DARK_MAGE)
|
||||||
{
|
{
|
||||||
Query darkMageQuery = new NPCQuery().idEquals(NpcID.DARK_MAGE);
|
darkMage = npc;
|
||||||
NPC[] result = queryRunner.runQuery(darkMageQuery);
|
}
|
||||||
darkMage = result.length >= 1 ? result[0] : null;
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onNpcDespawned(NpcDespawned event)
|
||||||
|
{
|
||||||
|
final NPC npc = event.getNpc();
|
||||||
|
if (npc == darkMage)
|
||||||
|
{
|
||||||
|
darkMage = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user