mixins/api: fix broken mixin + more

mixins/api: fix broken mixin + more

fix broken mixins

add new mixins

add new api support
This commit is contained in:
Kyle
2021-02-24 12:13:56 +00:00
parent 11dd1cdb41
commit 512140fc3a
4 changed files with 63 additions and 3 deletions

View File

@@ -103,4 +103,14 @@ public interface TileObject extends Locatable
*/
@Nullable
Shape getClickbox();
/**
* Gets the name of the object
*/
String getName();
/**
* Gets the menu actions of the object
*/
String[] getActions();
}

View File

@@ -74,6 +74,42 @@ public abstract class TileObjectQuery<EntityType extends TileObject, QueryType>
return (QueryType) this;
}
public QueryType nameEquals(String... names)
{
predicate = and(object ->
{
for (String name : names)
{
String objectName = object.getName();
if (objectName != null && objectName.equals(name))
{
return true;
}
}
return false;
});
return (QueryType) this;
}
public QueryType actionEquals(String... actions)
{
predicate = and(object ->
{
for (String action : actions)
{
String[] objectActions = object.getActions();
for (String objectAction : objectActions)
{
if (objectAction != null && objectAction.equals(action))
{
return true;
}
}
}
return false;
});
return (QueryType) this;
}
@SuppressWarnings("unchecked")
public QueryType idEquals(Collection<Integer> ids)

View File

@@ -253,7 +253,7 @@ public abstract class RSClientMixin implements RSClient
private boolean isMirrored = false;
@Inject
private boolean comparingAppearance = false;
private Integer comparingAppearance = 0;
@Inject
private List<String> outdatedScripts = new ArrayList<>();
@@ -2017,14 +2017,14 @@ public abstract class RSClientMixin implements RSClient
@Override
public boolean isComparingAppearance()
{
return comparingAppearance;
return comparingAppearance > 0;
}
@Inject
@Override
public void setComparingAppearance(boolean comparingAppearance)
{
this.comparingAppearance = comparingAppearance;
this.comparingAppearance += comparingAppearance ? 1 : -1;
}
@Inject

View File

@@ -38,6 +38,20 @@ public abstract class RSTileObjectMixin implements TileObject
return (int) (hash >>> 17 & 4294967295L);
}
@Override
@Inject
public String getName()
{
return client.getObjectDefinition(getId()).getName();
}
@Override
@Inject
public String[] getActions()
{
return client.getObjectDefinition(getId()).getActions();
}
@Override
@Inject
public WorldPoint getWorldLocation()