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 @Nullable
Shape getClickbox(); 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; 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") @SuppressWarnings("unchecked")
public QueryType idEquals(Collection<Integer> ids) public QueryType idEquals(Collection<Integer> ids)

View File

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

View File

@@ -37,6 +37,20 @@ public abstract class RSTileObjectMixin implements TileObject
long hash = getHash(); long hash = getHash();
return (int) (hash >>> 17 & 4294967295L); 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 @Override
@Inject @Inject